Repository: softlayer/softlayer-python
Pull request #1134 (2019-04-12 20:02:38)

Change encrypt parameters for importing of images.


Patch:
diff --git a/SoftLayer/CLI/image/import.py b/SoftLayer/CLI/image/import.py
index 7f1b1e83..53082c9a 100644
--- a/SoftLayer/CLI/image/import.py
+++ b/SoftLayer/CLI/image/import.py
@@ -25,17 +25,14 @@
                    "creating this key see https://console.bluemix.net/docs/"
                    "services/cloud-object-storage/iam/users-serviceids.html"
                    "#serviceidapikeys")
-@click.option('--root-key-id',
+@click.option('--root-key-crn',
               default=None,
-              help="ID of the root key in Key Protect")
+              help="CRN of the root key in your KMS instance")
 @click.option('--wrapped-dek',
               default=None,
               help="Wrapped Data Encryption Key provided by IBM KeyProtect. "
                    "For more info see https://console.bluemix.net/docs/"
                    "services/key-protect/wrap-keys.html#wrap-keys")
-@click.option('--kp-id',
-              default=None,
-              help="ID of the IBM Key Protect Instance")
 @click.option('--cloud-init',
               is_flag=True,
               help="Specifies if image is cloud-init")
@@ -46,8 +43,8 @@
               is_flag=True,
               help="Specifies if image is encrypted")
 @environment.pass_env
-def cli(env, name, note, os_code, uri, ibm_api_key, root_key_id, wrapped_dek,
-        kp_id, cloud_init, byol, is_encrypted):
+def cli(env, name, note, os_code, uri, ibm_api_key, root_key_crn, wrapped_dek,
+        cloud_init, byol, is_encrypted):
     """Import an image.
 
     The URI for an object storage object (.vhd/.iso file) of the format:
@@ -63,9 +60,8 @@ def cli(env, name, note, os_code, uri, ibm_api_key, root_key_id, wrapped_dek,
         os_code=os_code,
         uri=uri,
         ibm_api_key=ibm_api_key,
-        root_key_id=root_key_id,
+        root_key_crn=root_key_crn,
         wrapped_dek=wrapped_dek,
-        kp_id=kp_id,
         cloud_init=cloud_init,
         byol=byol,
         is_encrypted=is_encrypted
diff --git a/SoftLayer/managers/image.py b/SoftLayer/managers/image.py
index 2eb4bc98..34efb36b 100644
--- a/SoftLayer/managers/image.py
+++ b/SoftLayer/managers/image.py
@@ -121,8 +121,8 @@ def edit(self, image_id, name=None, note=None, tag=None):
         return bool(name or note or tag)
 
     def import_image_from_uri(self, name, uri, os_code=None, note=None,
-                              ibm_api_key=None, root_key_id=None,
-                              wrapped_dek=None, kp_id=None, cloud_init=False,
+                              ibm_api_key=None, root_key_crn=None,
+                              wrapped_dek=None, cloud_init=False,
                               byol=False, is_encrypted=False):
         """Import a new image from object storage.
 
@@ -136,11 +136,14 @@ def import_image_from_uri(self, name, uri, os_code=None, note=None,
         :param string os_code: The reference code of the operating system
         :param string note: Note to add to the image
         :param string ibm_api_key: Ibm Api Key needed to communicate with ICOS
-            and Key Protect
-        :param string root_key_id: ID of the root key in Key Protect
+            and your KMS
+        :param string root_key_crn: CRN of the root key in your KMS. Go to your
+            KMS (Key Protect or Hyper Protect) provider to get the CRN for your
+            root key.  An example CRN:
+            crn:v1:bluemix:public:hs-crypto:us-south:acctID:serviceID:key:keyID'
+            Used only when is_encrypted is True.
         :param string wrapped_dek: Wrapped Data Encryption Key provided by
-            IBM KeyProtect
-        :param string kp_id: ID of the IBM Key Protect Instance
+            your KMS. Used only when is_encrypted is True.
         :param boolean cloud_init: Specifies if image is cloud-init
         :param boolean byol: Specifies if image is bring your own license
         :param boolean is_encrypted: Specifies if image is encrypted
@@ -152,9 +155,8 @@ def import_image_from_uri(self, name, uri, os_code=None, note=None,
                 'operatingSystemReferenceCode': os_code,
                 'uri': uri,
                 'ibmApiKey': ibm_api_key,
-                'rootKeyId': root_key_id,
+                'crkCrn': root_key_crn,
                 'wrappedDek': wrapped_dek,
-                'keyProtectId': kp_id,
                 'cloudInit': cloud_init,
                 'byol': byol,
                 'isEncrypted': is_encrypted


Test patch:
diff --git a/tests/managers/image_tests.py b/tests/managers/image_tests.py
index 50a08198..b36deea7 100644
--- a/tests/managers/image_tests.py
+++ b/tests/managers/image_tests.py
@@ -151,9 +151,8 @@ def test_import_image_cos(self):
                                          uri='cos://some_uri',
                                          os_code='UBUNTU_LATEST',
                                          ibm_api_key='some_ibm_key',
-                                         root_key_id='some_root_key_id',
+                                         root_key_crn='some_root_key_crn',
                                          wrapped_dek='some_dek',
-                                         kp_id='some_id',
                                          cloud_init=False,
                                          byol=False,
                                          is_encrypted=False
@@ -167,9 +166,8 @@ def test_import_image_cos(self):
                    'operatingSystemReferenceCode': 'UBUNTU_LATEST',
                    'uri': 'cos://some_uri',
                    'ibmApiKey': 'some_ibm_key',
-                   'rootKeyId': 'some_root_key_id',
+                   'crkCrn': 'some_root_key_crn',
                    'wrappedDek': 'some_dek',
-                   'keyProtectId': 'some_id',
                    'cloudInit': False,
                    'byol': False,
                    'isEncrypted': False