CloudVE/cloudbridge

Problem listing anything but zones in Azure

asmerovski opened this issue · 9 comments

Hi guys, I have problems getting anything from this module. I couldn't find any forum for cloudbridge or whom to ask for help, but I have this piece of code:

from cloudbridge.factory import CloudProviderFactory, ProviderList

provider = CloudProviderFactory().create_provider(ProviderList.AZURE, {})

imgs = provider.compute.images.list() #RETURNS NOTHING
vm_types = provider.compute.vm_types.list() # RETURNS 356 VM TYPES
insts = provider.compute.instances.list() # RETURNS NOTHING
regs = provider.compute.regions.list() # RETURNS 41 REGIONS

How can I get my instances and images listed on subscription level on Azure?
Also, if this is not a right place to post a question (I suppose it is not), please let me know so I can post a question there.

@asmerovski You're in the right place. Have you exported all of the following env vars?

export AZURE_SUBSCRIPTION_ID
export AZURE_CLIENT_ID
export AZURE_SECRET
export AZURE_TENANT
export AZURE_RESOURCE_GROUP
export AZURE_STORAGE_ACCOUNT

Hi, thanks you your prompt response!

I got some variables in .cloudbridge file in my home folder.
[azure]
azure_subscription_id: ****
azure_client_id: ****
azure_secret: ****
azure_tenant: ****

I ommited the values for security reasons.

I added resource group and storage account in my .cloudbridge file, and now I can list VMs running in my resource group.
Still cannot list public or private images.

I managed to list some other images, by changing a resource group in .cloudbridge file.

But how do I get images on a direcory level, and how to get publicly available images, to list SKU's on azure ? I tried to create VM with these parameters:

img = provider.compute.images.get('ol8_2-gen2') # public image sku for oracle linux 8
inst = provider.compute.instances.create(
label='cb-machine', image=img, vm_type='Standard_B1ms',
subnet='default', key_pair=kp, vm_firewalls='cb-nsg')

But it says that no image is available.

@asmerovski
The id format should be as follows:

img = provider.compute.images.get('Canonical:UbuntuServer:16.04.0-LTS:latest')
print(img)

You can also list Azure Gallery image by turning off filter_by_owner when listing images.

imgs = provider.compute.images.list(filter_by_owner=False)
print(imgs)

Also check the docs here, which has a more detailed example: http://cloudbridge.cloudve.org/en/latest/topics/azure_mapping.html

Hey nuwang, thanks for pointing out that page of docs. It worked without problems!
Now, following tutorial I made everything until the point where I need to create a VM.
I am getting following error:
CloudBridgeBaseException: 403 Client Error: Forbidden for url: https://management.azure.com/subscriptions/xxxxxxxxxx/resourceGroups/xxxxxxxx/providers/Microsoft.Compute/virtualMachines/ta-cb-instance-d55183?api-version=2018-06-01 from exception type: <class 'msrestazure.azure_exceptions.CloudError'>

This looks like some permission error. Ring a bell?

One more question: are windows supported for this module, as I get installation errors ewven after installing visual studio build tool.?

@asmerovski I can't say it does, perhaps a lack of permissions for the IAM credentials you are using? @almahmoud Any thoughts?

Regarding Windows - we've never really tested cloudbridge on Windows, so we don't really know. All of the dependencies are on standard cloud provider libraries, so if those work on Windows, I can't think of a reason why cloudbridge wouldn't. Would be great to hear back if you get things working as expected.

Yeah, about that CloudBridgeBaseException: 403 Client Error: Forbidden for url, I managed to solve it. Resources were added in eastus region, but I tried to create a VM in westeurope region. After I set everything to one region, the problem was solved and VM was created.
Maybe you can add it to your truobleshooting section :).
Also got similar errors when creating a VM with size that is not available in that region.

As for support on Windows, a lot of modules do not support Windows, and have the same error. Response from developers for those modules were that they do not support. Following a logic, that means that developers need to implement something in the module, I don't know.

Managed to install cloudbridge module on windows. You need to install visual studio tools.
image

You can add this to your installation docs.