How can I manipulate my VPC(Virtual Private Cloud) instance with COS in a Python application ? (IBM Cloud)

146 views Asked by At

I'm trying to write an algorithm with Python that gets a file from COS(IBM Cloud Object Store) and transfer it to a VPC(Virtual private Cloud). .

I'm using this code to try to do this process:

 from ibm_vpc import VpcV1
from ibm_cloud_sdk_core.authenticators import IAMAuthenticator
from ibm_cloud_sdk_core import ApiException
import logging


authenticator = IAMAuthenticator("")
service = VpcV1(authenticator=authenticator)


image_file_prototype_model = {}
image_file_prototype_model['href']= "cos://us-south/cos-vm-migration/maquina-windows.qcow2"
logging.getLogger('image_file_prototype_model')



operating_system_identity_model = {}
operating_system_identity_model['name'] = 'ubuntu-16-amd64'

resource_group_identity_model = {}
resource_group_identity_model['id'] = 'bfe34d16c974497aa0b009a430b04de8'


image_prototype_model = {}

image_prototype_model['name'] = 'my-migration-vms'
print(image_prototype_model['name'])
image_prototype_model['resource_group'] = resource_group_identity_model
image_prototype_model['file'] = image_file_prototype_model
image_prototype_model[
    'operating_system'] = operating_system_identity_model

image_prototype = image_prototype_model

response = service.create_image(image_prototype)

But, I keep getting this error:

 Traceback (most recent call last):
  File "ibm-vpc.py", line 35, in <module>
    response = service.create_image(image_prototype)
  File "/home/caique/.local/lib/python3.6/site-packages/ibm_vpc/vpc_v1.py", line 2569, in create_image
    response = self.send(request)
  File "/home/caique/.local/lib/python3.6/site-packages/ibm_cloud_sdk_core/base_service.py", line 302, in send
    raise ApiException(response.status_code, http_response=response)
ibm_cloud_sdk_core.api_exception.ApiException: Error: Please check whether the resource you are requesting exists., Code: 400

This line is complaining saying that I don't have a COS service, But I do have a COS service

 ibm_cloud_sdk_core.api_exception.ApiException: Error: Please check whether the resource you are requesting exists., Code: 400

Someone could help me with this !?

0

There are 0 answers