Skip to content

Commit 6431e68

Browse files
Resolve conflicts
2 parents 7af9400 + e12230d commit 6431e68

41 files changed

Lines changed: 3071 additions & 320 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/e2e-test-pr.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@ on:
22
pull_request:
33
workflow_dispatch:
44
inputs:
5+
run_aclp_logs_stream_tests:
6+
description: 'Set this parameter to "true" to run ACLP logs stream related test cases'
7+
required: false
8+
default: 'false'
9+
type: choice
10+
options:
11+
- 'true'
12+
- 'false'
513
run_db_fork_tests:
614
description: 'Set this parameter to "true" to run fork database related test cases'
715
required: false
@@ -104,7 +112,7 @@ jobs:
104112
run: |
105113
timestamp=$(date +'%Y%m%d%H%M')
106114
report_filename="${timestamp}_sdk_test_report.xml"
107-
make test-int RUN_DB_FORK_TESTS=${{ github.event.inputs.run_db_fork_tests }} RUN_DB_TESTS=${{ github.event.inputs.run_db_tests }} TEST_ARGS="--junitxml=${report_filename}" TEST_SUITE="${{ github.event.inputs.test_suite }}"
115+
make test-int RUN_DB_FORK_TESTS=${{ github.event.inputs.run_db_fork_tests }} RUN_DB_TESTS=${{ github.event.inputs.run_db_tests }} RUN_ACLP_LOGS_STREAM_TESTS=${{ github.event.inputs.run_aclp_logs_stream_tests }} TEST_ARGS="--junitxml=${report_filename}" TEST_SUITE="${{ github.event.inputs.test_suite }}"
108116
env:
109117
LINODE_TOKEN: ${{ secrets.LINODE_TOKEN }}
110118

.github/workflows/e2e-test.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@ name: Integration Tests
33
on:
44
workflow_dispatch:
55
inputs:
6+
run_aclp_logs_stream_tests:
7+
description: 'Set this parameter to "true" to run ACLP logs stream related test cases'
8+
required: false
9+
default: 'false'
10+
type: choice
11+
options:
12+
- 'true'
13+
- 'false'
614
run_db_fork_tests:
715
description: 'Set this parameter to "true" to run fork database related test cases'
816
required: false
@@ -99,7 +107,7 @@ jobs:
99107
run: |
100108
timestamp=$(date +'%Y%m%d%H%M')
101109
report_filename="${timestamp}_sdk_test_report.xml"
102-
make test-int RUN_DB_FORK_TESTS=${{ github.event.inputs.run_db_fork_tests }} RUN_DB_TESTS=${{ github.event.inputs.run_db_tests }} TEST_SUITE="${{ github.event.inputs.test_suite }}" TEST_ARGS="--junitxml=${report_filename}"
110+
make test-int RUN_DB_FORK_TESTS=${{ github.event.inputs.run_db_fork_tests }} RUN_DB_TESTS=${{ github.event.inputs.run_db_tests }} RUN_ACLP_LOGS_STREAM_TESTS=${{ github.event.inputs.run_aclp_logs_stream_tests }} TEST_SUITE="${{ github.event.inputs.test_suite }}" TEST_ARGS="--junitxml=${report_filename}"
103111
env:
104112
LINODE_TOKEN: ${{ env.LINODE_TOKEN }}
105113

linode_api4/groups/linode.py

Lines changed: 54 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,10 @@ def instance_create(
162162
interface_generation: Optional[Union[InterfaceGeneration, str]] = None,
163163
network_helper: Optional[bool] = None,
164164
maintenance_policy: Optional[str] = None,
165+
root_pass: Optional[str] = None,
166+
kernel: Optional[str] = None,
167+
boot_size: Optional[int] = None,
168+
authorized_users: Optional[List[str]] = None,
165169
ipv4: Optional[List[str]] = None,
166170
**kwargs,
167171
):
@@ -173,27 +177,26 @@ def instance_create(
173177
To create an Instance from an :any:`Image`, call `instance_create` with
174178
a :any:`Type`, a :any:`Region`, and an :any:`Image`. All three of
175179
these fields may be provided as either the ID or the appropriate object.
176-
In this mode, a root password will be generated and returned with the
177-
new Instance object.
180+
When an Image is provided, at least one of ``root_pass``, ``authorized_users``, or
181+
``authorized_keys`` must also be given.
178182
179183
For example::
180184
181-
new_linode, password = client.linode.instance_create(
185+
new_linode = client.linode.instance_create(
182186
"g6-standard-2",
183187
"us-east",
184-
image="linode/debian9")
188+
image="linode/debian13",
189+
root_pass="aComplex@Password123")
185190
186191
ltype = client.linode.types().first()
187192
region = client.regions().first()
188193
image = client.images().first()
189194
190-
another_linode, password = client.linode.instance_create(
195+
another_linode = client.linode.instance_create(
191196
ltype,
192197
region,
193-
image=image)
194-
195-
To output the password from the above example:
196-
print(password)
198+
image=image,
199+
authorized_keys="ssh-rsa AAAA")
197200
198201
To output the first IPv4 address of the new Linode:
199202
print(new_linode.ipv4[0])
@@ -211,10 +214,11 @@ def instance_create(
211214
212215
stackscript = StackScript(client, 10079)
213216
214-
new_linode, password = client.linode.instance_create(
217+
new_linode = client.linode.instance_create(
215218
"g6-standard-2",
216219
"us-east",
217-
image="linode/debian9",
220+
image="linode/debian13",
221+
root_pass="aComplex@Password123",
218222
stackscript=stackscript,
219223
stackscript_data={"gh_username": "example"})
220224
@@ -245,10 +249,11 @@ def instance_create(
245249
To create a new Instance with explicit interfaces, provide list of
246250
LinodeInterfaceOptions objects or dicts to the "interfaces" field::
247251
248-
linode, password = client.linode.instance_create(
252+
linode = client.linode.instance_create(
249253
"g6-standard-1",
250254
"us-mia",
251255
image="linode/ubuntu24.04",
256+
root_pass="aComplex@Password123",
252257
253258
# This can be configured as an account-wide default
254259
interface_generation=InterfaceGeneration.LINODE,
@@ -281,10 +286,14 @@ def instance_create(
281286
:type ltype: str or Type
282287
:param region: The Region in which we are creating the Instance
283288
:type region: str or Region
284-
:param image: The Image to deploy to this Instance. If this is provided
285-
and no root_pass is given, a password will be generated
286-
and returned along with the new Instance.
289+
:param image: The Image to deploy to this Instance. If this is provided,
290+
at least one of root_pass, authorized_users, or authorized_keys must also be
291+
provided.
287292
:type image: str or Image
293+
:param root_pass: The root password for the new Instance. Required when
294+
an image is provided and neither authorized_users nor
295+
authorized_keys are given.
296+
:type root_pass: str
288297
:param stackscript: The StackScript to deploy to the new Instance. If
289298
provided, "image" is required and must be compatible
290299
with the chosen StackScript.
@@ -301,6 +310,11 @@ def instance_create(
301310
be a single key, or a path to a file containing
302311
the key.
303312
:type authorized_keys: list or str
313+
:param authorized_users: A list of usernames whose keys should be installed
314+
as trusted for the root user. These user's keys
315+
should already be set up, see :any:`ProfileGroup.ssh_keys`
316+
for details.
317+
:type authorized_users: list[str]
304318
:param label: The display label for the new Instance
305319
:type label: str
306320
:param group: The display group for the new Instance
@@ -336,29 +350,42 @@ def instance_create(
336350
:param maintenance_policy: The slug of the maintenance policy to apply during maintenance.
337351
If not provided, the default policy (linode/migrate) will be applied.
338352
:type maintenance_policy: str
353+
:param kernel: The kernel to boot the Instance with. If provided, this will be used as the
354+
kernel for the default configuration profile.
355+
:type kernel: str
356+
:param boot_size: The size of the boot disk in MB. If provided, this will be used to create
357+
the boot disk for the Instance.
358+
:type boot_size: int
339359
:param ipv4: A list of reserved IPv4 addresses to assign to this Instance.
340360
NOTE: Reserved IP feature may not currently be available to all users.
341361
:type ipv4: list[str]
342362
343-
:returns: A new Instance object, or a tuple containing the new Instance and
344-
the generated password.
345-
:rtype: Instance or tuple(Instance, str)
363+
:returns: A new Instance object
364+
:rtype: Instance
346365
:raises ApiError: If contacting the API fails
347366
:raises UnexpectedResponseError: If the API response is somehow malformed.
348367
This usually indicates that you are using
349368
an outdated library.
350369
"""
351370

352-
ret_pass = None
353-
if image and not "root_pass" in kwargs:
354-
ret_pass = Instance.generate_root_password()
355-
kwargs["root_pass"] = ret_pass
371+
if (
372+
image
373+
and not root_pass
374+
and not authorized_keys
375+
and not authorized_users
376+
):
377+
raise ValueError(
378+
"When creating an Instance from an Image, at least one of "
379+
"root_pass, authorized_users, or authorized_keys must be provided."
380+
)
356381

357382
params = {
358383
"type": ltype,
359384
"region": region,
360385
"image": image,
386+
"root_pass": root_pass,
361387
"authorized_keys": load_and_validate_keys(authorized_keys),
388+
"authorized_users": authorized_users,
362389
# These will automatically be flattened below
363390
"firewall_id": firewall,
364391
"backup_id": backup,
@@ -376,6 +403,8 @@ def instance_create(
376403
"interfaces": interfaces,
377404
"interface_generation": interface_generation,
378405
"network_helper": network_helper,
406+
"kernel": kernel,
407+
"boot_size": boot_size,
379408
"ipv4": ipv4,
380409
}
381410

@@ -391,10 +420,7 @@ def instance_create(
391420
"Unexpected response when creating linode!", json=result
392421
)
393422

394-
l = Instance(self.client, result["id"], result)
395-
if not ret_pass:
396-
return l
397-
return l, ret_pass
423+
return Instance(self.client, result["id"], result)
398424

399425
@staticmethod
400426
def build_instance_metadata(user_data=None, encode_user_data=True):
@@ -403,10 +429,11 @@ def build_instance_metadata(user_data=None, encode_user_data=True):
403429
the :any:`instance_create` method. This helper can also be used
404430
when cloning and rebuilding Instances.
405431
**Creating an Instance with User Data**::
406-
new_linode, password = client.linode.instance_create(
432+
new_linode = client.linode.instance_create(
407433
"g6-standard-2",
408434
"us-east",
409435
image="linode/ubuntu22.04",
436+
root_pass="aComplex@Password123",
410437
metadata=client.linode.build_instance_metadata(user_data="myuserdata")
411438
)
412439
:param user_data: User-defined data to provide to the Linode Instance through

0 commit comments

Comments
 (0)