Skip to content

Commit df0f47f

Browse files
committed
Fix manager and add CLI support
1 parent 0b1f637 commit df0f47f

File tree

3 files changed

+46
-8
lines changed

3 files changed

+46
-8
lines changed

SoftLayer/CLI/image/export.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,23 @@
1212
@click.command()
1313
@click.argument('identifier')
1414
@click.argument('uri')
15+
@click.option('--ibm_api_key',
16+
default="",
17+
help="The IBM Cloud API Key with access to IBM Cloud Object "
18+
"Storage instance.")
1519
@environment.pass_env
16-
def cli(env, identifier, uri):
20+
def cli(env, identifier, uri, ibm_api_key):
1721
"""Export an image to object storage.
1822
1923
The URI for an object storage object (.vhd/.iso file) of the format:
2024
swift://<objectStorageAccount>@<cluster>/<container>/<objectPath>
25+
or cos://<clusterName>/<bucketName>/<objectPath> if using IBM Cloud
26+
Object Storage
2127
"""
2228

2329
image_mgr = SoftLayer.ImageManager(env.client)
2430
image_id = helpers.resolve_id(image_mgr.resolve_ids, identifier, 'image')
25-
result = image_mgr.export_image_to_uri(image_id, uri)
31+
result = image_mgr.export_image_to_uri(image_id, uri, ibm_api_key)
2632

2733
if not result:
2834
raise exceptions.CLIAbort("Failed to export Image")

SoftLayer/CLI/image/import.py

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,38 @@
1818
@click.option('--os-code',
1919
default="",
2020
help="The referenceCode of the operating system software"
21-
" description for the imported VHD")
21+
" description for the imported VHD, ISO, or RAW image")
22+
@click.option('--ibm-api-key',
23+
default="",
24+
help="The IBM Cloud API Key with access to IBM Cloud Object "
25+
"Storage instance.")
26+
@click.option('--root-key-id',
27+
default="",
28+
help="ID of the root key in Key Protect")
29+
@click.option('--wrapped-dek',
30+
default="",
31+
help="Wrapped Decryption Key provided by IBM KeyProtect")
32+
@click.option('--kp-id',
33+
default="",
34+
help="ID of the IBM Key Protect Instance")
35+
@click.option('--cloud-init',
36+
default="",
37+
help="Specifies if image is cloud init")
38+
@click.option('--byol',
39+
default="",
40+
help="Specifies if image is bring your own license")
41+
@click.option('--is-encrypted',
42+
default="",
43+
help="Specifies if image is encrypted")
2244
@environment.pass_env
23-
def cli(env, name, note, os_code, uri):
45+
def cli(env, name, note, os_code, uri, ibm_api_key, root_key_id, wrapped_dek,
46+
kp_id, cloud_init, byol, is_encrypted):
2447
"""Import an image.
2548
2649
The URI for an object storage object (.vhd/.iso file) of the format:
2750
swift://<objectStorageAccount>@<cluster>/<container>/<objectPath>
51+
or cos://<clusterName>/<bucketName>/<objectPath> if using IBM Cloud
52+
Object Storage
2853
"""
2954

3055
image_mgr = SoftLayer.ImageManager(env.client)
@@ -33,6 +58,13 @@ def cli(env, name, note, os_code, uri):
3358
note=note,
3459
os_code=os_code,
3560
uri=uri,
61+
ibm_api_key=ibm_api_key,
62+
root_key_id=root_key_id,
63+
wrapped_dek=wrapped_dek,
64+
kp_id=kp_id,
65+
cloud_init=cloud_init,
66+
byol=byol,
67+
is_encrypted=is_encrypted
3668
)
3769

3870
if not result:

SoftLayer/managers/image.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,9 @@ def import_image_from_uri(self, name, uri, os_code=None, note=None,
141141
:param string wrapped_dek: Wrapped Decryption Key provided by IBM
142142
KeyProtect
143143
:param string kp_id: ID of the IBM Key Protect Instance
144-
:param bool cloud_init: Specifies if image is cloud init
145-
:param bool byol: Specifies if image is bring your own license
146-
:param bool is_encrypted: Specifies if image is encrypted
144+
:param boolean cloud_init: Specifies if image is cloud init
145+
:param boolean byol: Specifies if image is bring your own license
146+
:param boolean is_encrypted: Specifies if image is encrypted
147147
"""
148148
if 'cos://' in uri:
149149
return self.vgbdtg.createFromIcos({
@@ -152,7 +152,7 @@ def import_image_from_uri(self, name, uri, os_code=None, note=None,
152152
'operatingSystemReferenceCode': os_code,
153153
'uri': uri,
154154
'ibmApiKey': ibm_api_key,
155-
'rootKeyid': root_key_id,
155+
'rootKeyId': root_key_id,
156156
'wrappedDek': wrapped_dek,
157157
'keyProtectId': kp_id,
158158
'cloudInit': cloud_init,

0 commit comments

Comments
 (0)