@@ -71,7 +71,9 @@ def wait_until(linode_id: "str", timeout, status: "str", period=5):
7171 return False
7272
7373
74- def create_linode (firewall_id : "str" , test_region = DEFAULT_REGION ):
74+ def create_linode (
75+ firewall_id : "str" , test_region = DEFAULT_REGION , disk_encryption = False
76+ ):
7577 # create linode
7678 linode_id = (
7779 exec_test_command (
@@ -89,6 +91,8 @@ def create_linode(firewall_id: "str", test_region=DEFAULT_REGION):
8991 DEFAULT_RANDOM_PASS ,
9092 "--firewall_id" ,
9193 firewall_id ,
94+ "--disk_encryption" ,
95+ "enabled" if disk_encryption else "disabled" ,
9296 "--format=id" ,
9397 "--text" ,
9498 "--no-headers" ,
@@ -183,73 +187,40 @@ def create_linode_and_wait(
183187 test_plan = DEFAULT_LINODE_TYPE ,
184188 test_image = DEFAULT_TEST_IMAGE ,
185189 test_region = DEFAULT_REGION ,
190+ disk_encryption = False ,
186191):
187- linode_type = test_plan
188-
189- # key_pair = generate_random_ssh_key()
192+ # Base command
193+ command = [
194+ "linode-cli" ,
195+ "linodes" ,
196+ "create" ,
197+ "--type" ,
198+ test_plan ,
199+ "--region" ,
200+ test_region ,
201+ "--image" ,
202+ test_image ,
203+ "--root_pass" ,
204+ DEFAULT_RANDOM_PASS ,
205+ "--firewall_id" ,
206+ firewall_id ,
207+ "--format=id" ,
208+ "--backups_enabled" ,
209+ "true" ,
210+ "--disk_encryption" ,
211+ "enabled" if disk_encryption else "disabled" ,
212+ "--text" ,
213+ "--no-headers" ,
214+ ]
190215
191- output = ""
192- # if ssh key is successfully generated
216+ # Add SSH key if provided
193217 if ssh_key :
194- output = (
195- exec_test_command (
196- [
197- "linode-cli" ,
198- "linodes" ,
199- "create" ,
200- "--type" ,
201- linode_type ,
202- "--region" ,
203- test_region ,
204- "--image" ,
205- test_image ,
206- "--root_pass" ,
207- DEFAULT_RANDOM_PASS ,
208- "--authorized_keys" ,
209- ssh_key ,
210- "--firewall_id" ,
211- firewall_id ,
212- "--format=id" ,
213- "--backups_enabled" ,
214- "true" ,
215- "--text" ,
216- "--no-headers" ,
217- ]
218- )
219- .stdout .decode ()
220- .rstrip ()
221- )
222- else :
223- output = (
224- exec_test_command (
225- [
226- "linode-cli" ,
227- "linodes" ,
228- "create" ,
229- "--type" ,
230- linode_type ,
231- "--region" ,
232- "us-ord" ,
233- "--image" ,
234- test_image ,
235- "--root_pass" ,
236- DEFAULT_RANDOM_PASS ,
237- "--firewall_id" ,
238- firewall_id ,
239- "--format=id" ,
240- "--backups_enabled" ,
241- "true" ,
242- "--text" ,
243- "--no-headers" ,
244- ]
245- )
246- .stdout .decode ()
247- .rstrip ()
248- )
249- linode_id = output
218+ command .extend (["--authorized_keys" , ssh_key ])
219+
220+ linode_id = exec_test_command (command ).stdout .decode ().strip ()
250221
251222 # wait until linode is running, wait_until returns True when it is in running state
252- result = ( wait_until (linode_id = linode_id , timeout = 240 , status = "running" ), )
223+ result = wait_until (linode_id = linode_id , timeout = 240 , status = "running" )
253224
254225 assert result , "linode failed to change status to running"
255226
@@ -275,3 +246,24 @@ def set_backups_enabled_in_account_settings(toggle: bool):
275246 result = exec_test_command (command ).stdout .decode ().rstrip ()
276247
277248 return result
249+
250+
251+ def get_disk_ids (linode_id ):
252+ disk_ids = (
253+ exec_test_command (
254+ BASE_CMD
255+ + [
256+ "disks-list" ,
257+ linode_id ,
258+ "--text" ,
259+ "--no-headers" ,
260+ "--format" ,
261+ "id" ,
262+ ]
263+ )
264+ .stdout .decode ()
265+ .rstrip ()
266+ .splitlines ()
267+ )
268+
269+ return disk_ids
0 commit comments