Skip to content

Commit ff8396c

Browse files
Fix missed conflict
1 parent a233124 commit ff8396c

File tree

1 file changed

+155
-158
lines changed

1 file changed

+155
-158
lines changed

linode_api4/groups/linode.py

Lines changed: 155 additions & 158 deletions
Original file line numberDiff line numberDiff line change
@@ -167,190 +167,187 @@ def instance_create(
167167
**kwargs,
168168
):
169169
"""
170-
Creates a new Linode Instance. This function has several modes of operation:
170+
Creates a new Linode Instance. This function has several modes of operation:
171171
172-
**Create an Instance from an Image**
172+
**Create an Instance from an Image**
173173
174-
To create an Instance from an :any:`Image`, call `instance_create` with
175-
a :any:`Type`, a :any:`Region`, and an :any:`Image`. All three of
176-
these fields may be provided as either the ID or the appropriate object.
177-
In this mode, a root password will be generated and returned with the
178-
new Instance object.
174+
To create an Instance from an :any:`Image`, call `instance_create` with
175+
a :any:`Type`, a :any:`Region`, and an :any:`Image`. All three of
176+
these fields may be provided as either the ID or the appropriate object.
177+
In this mode, a root password will be generated and returned with the
178+
new Instance object.
179179
180-
For example::
180+
For example::
181181
182-
new_linode, password = client.linode.instance_create(
183-
"g6-standard-2",
184-
"us-east",
185-
image="linode/debian9")
182+
new_linode, password = client.linode.instance_create(
183+
"g6-standard-2",
184+
"us-east",
185+
image="linode/debian9")
186186
187-
ltype = client.linode.types().first()
188-
region = client.regions().first()
189-
image = client.images().first()
187+
ltype = client.linode.types().first()
188+
region = client.regions().first()
189+
image = client.images().first()
190190
191-
another_linode, password = client.linode.instance_create(
192-
ltype,
193-
region,
194-
image=image)
191+
another_linode, password = client.linode.instance_create(
192+
ltype,
193+
region,
194+
image=image)
195195
196-
To output the password from the above example:
197-
print(password)
196+
To output the password from the above example:
197+
print(password)
198198
199-
To output the first IPv4 address of the new Linode:
200-
print(new_linode.ipv4[0])
199+
To output the first IPv4 address of the new Linode:
200+
print(new_linode.ipv4[0])
201201
202-
To delete the new_linode (WARNING: this immediately destroys the Linode):
203-
new_linode.delete()
202+
To delete the new_linode (WARNING: this immediately destroys the Linode):
203+
new_linode.delete()
204204
205-
**Create an Instance from StackScript**
205+
**Create an Instance from StackScript**
206206
207-
When creating an Instance from a :any:`StackScript`, an :any:`Image` that
208-
the StackScript support must be provided.. You must also provide any
209-
required StackScript data for the script's User Defined Fields.. For
210-
example, if deploying `StackScript 10079`_ (which deploys a new Instance
211-
with a user created from keys on `github`_::
207+
When creating an Instance from a :any:`StackScript`, an :any:`Image` that
208+
the StackScript support must be provided.. You must also provide any
209+
required StackScript data for the script's User Defined Fields.. For
210+
example, if deploying `StackScript 10079`_ (which deploys a new Instance
211+
with a user created from keys on `github`_::
212212
213-
stackscript = StackScript(client, 10079)
213+
stackscript = StackScript(client, 10079)
214214
215-
new_linode, password = client.linode.instance_create(
216-
"g6-standard-2",
217-
"us-east",
218-
image="linode/debian9",
219-
stackscript=stackscript,
220-
stackscript_data={"gh_username": "example"})
215+
new_linode, password = client.linode.instance_create(
216+
"g6-standard-2",
217+
"us-east",
218+
image="linode/debian9",
219+
stackscript=stackscript,
220+
stackscript_data={"gh_username": "example"})
221221
222-
In the above example, "gh_username" is the name of a User Defined Field
223-
in the chosen StackScript. For more information on StackScripts, see
224-
the `StackScript guide`_.
222+
In the above example, "gh_username" is the name of a User Defined Field
223+
in the chosen StackScript. For more information on StackScripts, see
224+
the `StackScript guide`_.
225225
226-
.. _`StackScript 10079`: https://www.linode.com/stackscripts/view/10079
227-
.. _`github`: https://github.com
228-
.. _`StackScript guide`: https://www.linode.com/docs/platform/stackscripts/
226+
.. _`StackScript 10079`: https://www.linode.com/stackscripts/view/10079
227+
.. _`github`: https://github.com
228+
.. _`StackScript guide`: https://www.linode.com/docs/platform/stackscripts/
229229
230-
**Create an Instance from a Backup**
230+
**Create an Instance from a Backup**
231231
232-
To create a new Instance by restoring a :any:`Backup` to it, provide a
233-
:any:`Type`, a :any:`Region`, and the :any:`Backup` to restore. You
234-
may provide either IDs or objects for all of these fields::
232+
To create a new Instance by restoring a :any:`Backup` to it, provide a
233+
:any:`Type`, a :any:`Region`, and the :any:`Backup` to restore. You
234+
may provide either IDs or objects for all of these fields::
235235
236-
existing_linode = Instance(client, 123)
237-
snapshot = existing_linode.available_backups.snapshot.current
236+
existing_linode = Instance(client, 123)
237+
snapshot = existing_linode.available_backups.snapshot.current
238238
239-
new_linode = client.linode.instance_create(
240-
"g6-standard-2",
241-
"us-east",
242-
backup=snapshot)
239+
new_linode = client.linode.instance_create(
240+
"g6-standard-2",
241+
"us-east",
242+
backup=snapshot)
243243
244-
**Create an Instance with explicit interfaces:**
244+
**Create an Instance with explicit interfaces:**
245245
246-
To create a new Instance with explicit interfaces, provide list of
247-
LinodeInterfaceOptions objects or dicts to the "interfaces" field::
246+
To create a new Instance with explicit interfaces, provide list of
247+
LinodeInterfaceOptions objects or dicts to the "interfaces" field::
248248
249-
linode, password = client.linode.instance_create(
250-
"g6-standard-1",
251-
"us-mia",
252-
image="linode/ubuntu24.04",
249+
linode, password = client.linode.instance_create(
250+
"g6-standard-1",
251+
"us-mia",
252+
image="linode/ubuntu24.04",
253253
254-
# This can be configured as an account-wide default
255-
interface_generation=InterfaceGeneration.LINODE,
254+
# This can be configured as an account-wide default
255+
interface_generation=InterfaceGeneration.LINODE,
256256
257-
interfaces=[
258-
LinodeInterfaceOptions(
259-
default_route=LinodeInterfaceDefaultRouteOptions(
260-
ipv4=True,
261-
ipv6=True
262-
),
263-
public=LinodeInterfacePublicOptions
264-
)
265-
]
257+
interfaces=[
258+
LinodeInterfaceOptions(
259+
default_route=LinodeInterfaceDefaultRouteOptions(
260+
ipv4=True,
261+
ipv6=True
262+
),
263+
public=LinodeInterfacePublicOptions
266264
)
265+
]
266+
)
267267
268-
**Create an empty Instance**
269-
270-
If you want to create an empty Instance that you will configure manually,
271-
simply call `instance_create` with a :any:`Type` and a :any:`Region`::
272-
273-
empty_linode = client.linode.instance_create("g6-standard-2", "us-east")
274-
275-
When created this way, the Instance will not be booted and cannot boot
276-
successfully until disks and configs are created, or it is otherwise
277-
configured.
278-
279-
API Documentation: https://techdocs.akamai.com/linode-api/reference/post-linode-instance
280-
281-
:param ltype: The Instance Type we are creating
282-
:type ltype: str or Type
283-
:param region: The Region in which we are creating the Instance
284-
:type region: str or Region
285-
:param image: The Image to deploy to this Instance. If this is provided
286-
and no root_pass is given, a password will be generated
287-
and returned along with the new Instance.
288-
:type image: str or Image
289-
:param stackscript: The StackScript to deploy to the new Instance. If
290-
provided, "image" is required and must be compatible
291-
with the chosen StackScript.
292-
:type stackscript: int or StackScript
293-
:param stackscript_data: Values for the User Defined Fields defined in
294-
the chosen StackScript. Does nothing if
295-
StackScript is not provided.
296-
:type stackscript_data: dict
297-
:param backup: The Backup to restore to the new Instance. May not be
298-
provided if "image" is given.
299-
:type backup: int of Backup
300-
:param authorized_keys: The ssh public keys to install in the linode's
301-
/root/.ssh/authorized_keys file. Each entry may
302-
be a single key, or a path to a file containing
303-
the key.
304-
:type authorized_keys: list or str
305-
:param label: The display label for the new Instance
306-
:type label: str
307-
:param group: The display group for the new Instance
308-
:type group: str
309-
:param booted: Whether the new Instance should be booted. This will
310-
default to True if the Instance is deployed from an Image
311-
or Backup.
312-
:type booted: bool
313-
:param tags: A list of tags to apply to the new instance. If any of the
314-
tags included do not exist, they will be created as part of
315-
this operation.
316-
:type tags: list[str]
317-
:param private_ip: Whether the new Instance should have private networking
318-
enabled and assigned a private IPv4 address.
319-
:type private_ip: bool
320-
:param metadata: Metadata-related fields to use when creating the new Instance.
321-
The contents of this field can be built using the
322-
:any:`build_instance_metadata` method.
323-
:type metadata: dict
324-
:param firewall: The firewall to attach this Linode to.
325-
:type firewall: int or Firewall
326-
:param disk_encryption: The disk encryption policy for this Linode.
327-
NOTE: Disk encryption may not currently be available to all users.
328-
:type disk_encryption: InstanceDiskEncryptionType or str
329-
:param interfaces: An array of Network Interfaces to add to this Linode’s Configuration Profile.
330-
At least one and up to three Interface objects can exist in this array.
331-
:type interfaces: List[LinodeInterfaceOptions], List[NetworkInterface], or List[dict[str, Any]]
332-
:param placement_group: A Placement Group to create this Linode under.
333-
:type placement_group: Union[InstancePlacementGroupAssignment, PlacementGroup, Dict[str, Any], int]
334-
:param interface_generation: The generation of network interfaces this Linode uses.
335-
:type interface_generation: InterfaceGeneration or str
336-
:param network_helper: Whether this instance should have Network Helper enabled.
337-
:type network_helper: bool
338-
<<<<<<< HEAD
339-
=======
340-
:param maintenance_policy: The slug of the maintenance policy to apply during maintenance.
341-
If not provided, the default policy (linode/migrate) will be applied.
342-
NOTE: This field is in beta and may only
343-
function if base_url is set to `https://api.linode.com/v4beta`.
344-
:type maintenance_policy: str
345-
>>>>>>> fed436bb516bf1b08966058cb418ad3959e9b405
346-
347-
:returns: A new Instance object, or a tuple containing the new Instance and
348-
the generated password.
349-
:rtype: Instance or tuple(Instance, str)
350-
:raises ApiError: If contacting the API fails
351-
:raises UnexpectedResponseError: If the API response is somehow malformed.
352-
This usually indicates that you are using
353-
an outdated library.
268+
**Create an empty Instance**
269+
270+
If you want to create an empty Instance that you will configure manually,
271+
simply call `instance_create` with a :any:`Type` and a :any:`Region`::
272+
273+
empty_linode = client.linode.instance_create("g6-standard-2", "us-east")
274+
275+
When created this way, the Instance will not be booted and cannot boot
276+
successfully until disks and configs are created, or it is otherwise
277+
configured.
278+
279+
API Documentation: https://techdocs.akamai.com/linode-api/reference/post-linode-instance
280+
281+
:param ltype: The Instance Type we are creating
282+
:type ltype: str or Type
283+
:param region: The Region in which we are creating the Instance
284+
:type region: str or Region
285+
:param image: The Image to deploy to this Instance. If this is provided
286+
and no root_pass is given, a password will be generated
287+
and returned along with the new Instance.
288+
:type image: str or Image
289+
:param stackscript: The StackScript to deploy to the new Instance. If
290+
provided, "image" is required and must be compatible
291+
with the chosen StackScript.
292+
:type stackscript: int or StackScript
293+
:param stackscript_data: Values for the User Defined Fields defined in
294+
the chosen StackScript. Does nothing if
295+
StackScript is not provided.
296+
:type stackscript_data: dict
297+
:param backup: The Backup to restore to the new Instance. May not be
298+
provided if "image" is given.
299+
:type backup: int of Backup
300+
:param authorized_keys: The ssh public keys to install in the linode's
301+
/root/.ssh/authorized_keys file. Each entry may
302+
be a single key, or a path to a file containing
303+
the key.
304+
:type authorized_keys: list or str
305+
:param label: The display label for the new Instance
306+
:type label: str
307+
:param group: The display group for the new Instance
308+
:type group: str
309+
:param booted: Whether the new Instance should be booted. This will
310+
default to True if the Instance is deployed from an Image
311+
or Backup.
312+
:type booted: bool
313+
:param tags: A list of tags to apply to the new instance. If any of the
314+
tags included do not exist, they will be created as part of
315+
this operation.
316+
:type tags: list[str]
317+
:param private_ip: Whether the new Instance should have private networking
318+
enabled and assigned a private IPv4 address.
319+
:type private_ip: bool
320+
:param metadata: Metadata-related fields to use when creating the new Instance.
321+
The contents of this field can be built using the
322+
:any:`build_instance_metadata` method.
323+
:type metadata: dict
324+
:param firewall: The firewall to attach this Linode to.
325+
:type firewall: int or Firewall
326+
:param disk_encryption: The disk encryption policy for this Linode.
327+
NOTE: Disk encryption may not currently be available to all users.
328+
:type disk_encryption: InstanceDiskEncryptionType or str
329+
:param interfaces: An array of Network Interfaces to add to this Linode’s Configuration Profile.
330+
At least one and up to three Interface objects can exist in this array.
331+
:type interfaces: List[LinodeInterfaceOptions], List[NetworkInterface], or List[dict[str, Any]]
332+
:param placement_group: A Placement Group to create this Linode under.
333+
:type placement_group: Union[InstancePlacementGroupAssignment, PlacementGroup, Dict[str, Any], int]
334+
:param interface_generation: The generation of network interfaces this Linode uses.
335+
:type interface_generation: InterfaceGeneration or str
336+
:param network_helper: Whether this instance should have Network Helper enabled.
337+
:type network_helper: bool
338+
:param maintenance_policy: The slug of the maintenance policy to apply during maintenance.
339+
If not provided, the default policy (linode/migrate) will be applied.
340+
NOTE: This field is in beta and may only
341+
function if base_url is set to `https://api.linode.com/v4beta`.
342+
:type maintenance_policy: str
343+
344+
:returns: A new Instance object, or a tuple containing the new Instance and
345+
the generated password.
346+
:rtype: Instance or tuple(Instance, str)
347+
:raises ApiError: If contacting the API fails
348+
:raises UnexpectedResponseError: If the API response is somehow malformed.
349+
This usually indicates that you are using
350+
an outdated library.
354351
"""
355352

356353
ret_pass = None

0 commit comments

Comments
 (0)