@@ -120,28 +120,68 @@ def edit(self, image_id, name=None, note=None, tag=None):
120120
121121 return bool (name or note or tag )
122122
123- def import_image_from_uri (self , name , uri , os_code = None , note = None ):
123+ def import_image_from_uri (self , name , uri , os_code = None , note = None ,
124+ ibm_api_key = None , root_key_id = None ,
125+ wrapped_dek = None , kp_id = None , cloud_init = None ,
126+ byol = None , is_encrypted = None ):
124127 """Import a new image from object storage.
125128
126129 :param string name: Name of the new image
127130 :param string uri: The URI for an object storage object
128131 (.vhd/.iso file) of the format:
129132 swift://<objectStorageAccount>@<cluster>/<container>/<objectPath>
133+ or (.vhd/.iso/.raw file) of the format:
134+ cos://<clusterName>/<bucketName>/<objectPath> if using IBM Cloud
135+ Object Storage
130136 :param string os_code: The reference code of the operating system
131137 :param string note: Note to add to the image
138+ :param string ibm_api_key: Ibm Api Key needed to communicate with ICOS
139+ and Key Protect
140+ :param string root_key_id: ID of the root key in Key Protect
141+ :param string wrapped_dek: Wrapped Decryption Key provided by IBM
142+ KeyProtect
143+ :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
132147 """
133- return self .vgbdtg .createFromExternalSource ({
134- 'name' : name ,
135- 'note' : note ,
136- 'operatingSystemReferenceCode' : os_code ,
137- 'uri' : uri ,
138- })
139-
140- def export_image_to_uri (self , image_id , uri ):
148+ if 'cos://' in uri :
149+ return self .vgbdtg .createFromIcos ({
150+ 'name' : name ,
151+ 'note' : note ,
152+ 'operatingSystemReferenceCode' : os_code ,
153+ 'uri' : uri ,
154+ 'ibmApiKey' : ibm_api_key ,
155+ 'rootKeyid' : root_key_id ,
156+ 'wrappedDek' : wrapped_dek ,
157+ 'keyProtectId' : kp_id ,
158+ 'cloudInit' : cloud_init ,
159+ 'byol' : byol ,
160+ 'isEncrypted' : is_encrypted
161+ })
162+ else :
163+ return self .vgbdtg .createFromExternalSource ({
164+ 'name' : name ,
165+ 'note' : note ,
166+ 'operatingSystemReferenceCode' : os_code ,
167+ 'uri' : uri ,
168+ })
169+
170+ def export_image_to_uri (self , image_id , uri , ibm_api_key = None ):
141171 """Export image into the given object storage
142172
143173 :param int image_id: The ID of the image
144174 :param string uri: The URI for object storage of the format
145175 swift://<objectStorageAccount>@<cluster>/<container>/<objectPath>
176+ or cos://<clusterName>/<bucketName>/<objectPath> if using IBM Cloud
177+ Object Storage
178+ :param string ibm_api_key: Ibm Api Key needed to communicate with IBM
179+ Cloud Object Storage
146180 """
147- return self .vgbdtg .copyToExternalSource ({'uri' : uri }, id = image_id )
181+ if 'cos://' in uri :
182+ return self .vgbdtg .copyToIcos ({
183+ 'uri' : uri ,
184+ 'ibmApiKey' : ibm_api_key
185+ }, id = image_id )
186+ else :
187+ return self .vgbdtg .copyToExternalSource ({'uri' : uri }, id = image_id )
0 commit comments