EzDevInfo.com

libcloud

Apache Libcloud is a Python library which hides differences between different cloud provider APIs and allows you to manage different cloud resources through a unified and easy to use API Apache Libcloud is a standard Python library that abstracts away differences among multiple cloud provider APIs | Apache Libcloud python library for interacting with many of the popular cloud service providers using a unified api.

Creating sshKeys for gce instance using libcloud

I need help! I am trying to create sshKeys(protocol pub_key username) for gce instance using libcloud API create_node with parameter ex_metadata while creating an instance. But username value is not getting saved when I check in google cloud console after the creation of instance.

Is there any different format to send sshKeys for metadata? I am sending data like this,

metadata = {"items": [{"value": value, "key": "sshKeys"}]}

Source: (StackOverflow)

Libcloud library in python equivalent to nodejs

we can use libcloud in python as api interface services since its a cloud library .so like this how can we use this library in nodejs language? Any idea guys,as far I know there is one library SDK but its an was official one.any other guys? Thanks,Indu


Source: (StackOverflow)

Advertisements

Ansible - Create GCE node with fixed IP

I want to create a GCE node with ansible and attach it a fixed IP. My problem is ansible doesn't seem to purpose this option.

After googling and searching in source code, I can't find where is the code which deploy instances.

If anyone has an idea ?


Source: (StackOverflow)

upload to google cloud storage using libcloud

I wish to to upload files to google cloud storage. I created a service account, converted the p12 file to a pem file, then referenced the service account email address and pem file in my driver:

from libcloud.storage.types import Provider
from libcloud.storage.providers import get_driver


CloudStorage = get_driver(Provider.GOOGLE_STORAGE)
driver = CloudStorage(
    '...@developer.gserviceaccount.com',
    os.path.expanduser('~/.ssh/my.pem'),
    project='my_project',
)

however, when I do

driver.list_containers()

I get

<?xml version='1.0' encoding='UTF-8'?><Error><Code>InvalidSecurity</Code><Message>The provided security credentials are not valid.</Message><Details>Incorrect Authorization header</Details></Error>

Source: (StackOverflow)

Create a vm or cloud service on azure using libcloud?

I’m having a problem with libcloud/drivers/azure.py when I create a VM or a cloud service, I receive always a 400 bad request without a body. Could someone help me out of this please?

Here is my code:

# connectHandler use my pem file to create a connection with the server, return a AzureNodeDriver objet
conn = _connectHandler.api_connect(compute_ressource)
try:
    result = conn.ex_create_cloud_service(name= "testCloudServiceZT200", location= "Central US")
except Exception as e:
    logger.error(e)
else:
    return result

and here is what I got in return: <LibcloudError in <libcloud.compute.drivers.azure.AzureNodeDriver object at 0x7fceaeb457d0> 'Message: Bad Request, Body: , Status code: 400'>

Could someone please tell me why this error, and maybe give me some examples of azure.py, it will be very grateful. thx!!


Source: (StackOverflow)

python libcloud create VM inside vAPP

i am able to create a node(vAPP) in cloud using libcloud, however the API does not mention a way to create a VM inside an existing vAPP. Has anyone tried this?

http://libcloud.readthedocs.org/en/latest/compute/drivers/vcloud.html

from libcloud.compute.types import Provider
from libcloud.compute.providers import get_driver

import libcloud.security  

def testConnection():
    #libcloud.security.VERIFY_SSL_CERT = True
    vcloud = get_driver(Provider.VCLOUD)
    driver = vcloud("user@org", "xxxxx", host='portal.local', api_version='5.1')   

    nodes = driver.list_nodes()    
    for i in nodes:
        print i      
    images = driver.list_images()    
    image = [i for i in images if i.name == "New Base VM vApp"][0]
    print image   

    locations = driver.list_locations()
    print locations

    vdcs = driver.vdcs
    vdc = [i for i in vdcs if "VDC_NAME" in i.name ][0]    
    for i in vdcs:
        if "VDC_NAME" in i.name:
            print "VDC\n"
            print i
            dev_test_vdc = i.name
            print i    
    print "creating node"
    node = driver.create_node(name="test_vAPP", image=image,  ex_vdc=dev_test_vdc, ex_clone_timeout=500)

def main():
    testConnection()

if __name__ == "__main__":
    main()

Source: (StackOverflow)

apache-libcloud create temporary url

I would like to generate a temporary download url using cloudlib.

I understand how to create the link by manually contructing the url, but I would like to use libcloud if possible so I can easily swap out google cloud storage.


Source: (StackOverflow)

How do I test if provider credentials are valid in apache libcloud?

I was trying to create a driver for openstack using apache libcloud. It doesn't raise any error even if the user credentials are wrong. So When i checked the faq i found an answer as given in the link Apache libcloud FAQ

But it doesn't seem to be effective since querying each time to check whether the user is authenticated will reduce the performance if the query returns a bulk of data.

When i checked the response i got from the api there is a field called driver.connection.auth_user_info and i found that the field is empty if the user is not authenticated. So can i use this method as a standard? Any help is appreciated


Source: (StackOverflow)

How to list AWS EC2 regions with libcloud

Is there a way to get the list of all regions available on AWS through libcloud ?

With powershell AWS SDK I can use :

$regions = @(Get-AWSRegion)
foreach ($region in $regions)
{
$region.Region
}

How can I do the same with Python and libcloud ?

Many thanks, Johnny


Source: (StackOverflow)

python libcloud vcloud connection

I am trying to connect to Vcloud using lib cloud, the authentication works fine using rest API from firefox, but fails in python. am I missing something?

__author__ = 'kshk'
from libcloud.compute.types import Provider
from libcloud.compute.providers import get_driver

import libcloud.security



def testConnection():
    #libcloud.security.VERIFY_SSL_CERT = False
    vcloud = get_driver(Provider.VCLOUD)
    driver = vcloud("login", "passwd", host = "https://portal.vcloud")

    nodes = driver.list_nodes()
    print nodes

def main():
    testConnection()

if __name__ == "__main__":
    main()

OUTPUT:

/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7 /Users/krishnaa/PycharmProjects/VCloud-API/vcloud_test.py
Traceback (most recent call last):
  File "/Users/krishnaa/PycharmProjects/VCloud-API/vcloud_test.py", line 21, in <module>
    main()
  File "/Users/krishnaa/PycharmProjects/VCloud-API/vcloud_test.py", line 18, in main
    testConnection()
  File "/Users/krishnaa/PycharmProjects/VCloud-API/vcloud_test.py", line 14, in testConnection
    nodes = driver.list_nodes()
  File "/Library/Python/2.7/site-packages/apache_libcloud-0.15.1-py2.7.egg/libcloud/compute/drivers/vcloud.py", line 559, in list_nodes
    return self.ex_list_nodes()
  File "/Library/Python/2.7/site-packages/apache_libcloud-0.15.1-py2.7.egg/libcloud/compute/drivers/vcloud.py", line 573, in ex_list_nodes
    vdcs = self.vdcs
  File "/Library/Python/2.7/site-packages/apache_libcloud-0.15.1-py2.7.egg/libcloud/compute/drivers/vcloud.py", line 407, in vdcs
    self.connection.check_org()  # make sure the org is set.
  File "/Library/Python/2.7/site-packages/apache_libcloud-0.15.1-py2.7.egg/libcloud/compute/drivers/vcloud.py", line 325, in check_org
    self._get_auth_token()
  File "/Library/Python/2.7/site-packages/apache_libcloud-0.15.1-py2.7.egg/libcloud/compute/drivers/vcloud.py", line 835, in _get_auth_token
    headers=self._get_auth_headers())
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 973, in request
    self._send_request(method, url, body, headers)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 1007, in _send_request
    self.endheaders(body)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 969, in endheaders
    self._send_output(message_body)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 829, in _send_output
    self.send(msg)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 791, in send
    self.connect()
  File "/Library/Python/2.7/site-packages/apache_libcloud-0.15.1-py2.7.egg/libcloud/httplib_ssl.py", line 96, in connect
    self.timeout)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py", line 553, in create_connection
    for res in getaddrinfo(host, port, 0, SOCK_STREAM):
socket.gaierror: [Errno 8] nodename nor servname provided, or not known

Source: (StackOverflow)

How to enable gzip in apache libcloud along with google cloud storage

Hi I am using apache libcloud to upload static data to my google cloud storage.

I am using this along with django-compressor to minify my data.

End Result Expected : I want the data being uploaded on my google cloud to be gzipped or the data being served from the google cloud to be gzipped.

What is happening currently : Django compressor minifies the data. Then directly uses the apache backend to upload the data

STATICFILES_STORAGE = 'storages.backends.apache_libcloud.LibCloudStorage'
COMPRESS_STORAGE = STATICFILES_STORAGE

I am unable to understand where exactly can I enable the gzip option. Is it a setting on the google cloud or apache liblcoud or django compressor.

Google storage apache libcloud

Django compressor

The django compressor does have an option for gzip, but has it for a custom storage of its own. compressor gzip enabled


Source: (StackOverflow)

How to use libcloud library in python

i am using libcloud api interface in python,here is my code in python , i need to list images in cloustack:

from libcloud.compute.types import Provider 
from libcloud.compute.providers import get_driver 
from libcloud.common.base import Response 
#import libcloud.security as sec 
#sec.VERIFY_SSL_CERT = False 
#USER = 'ACCESSKEY' 
#API_KEY = 'SECRETKEY' 
Driver = get_driver(Provider.CLOUDSTACK) 
url = 'MY URL' 
conn = Driver(key=USER, secret=API_KEY, url=url) 
print "Connection established" 
images = conn.list_images() 
print images

   When runing this code,showing error like this :

 body = self.parse_body() File "/usr/local/lib/python2.7/dist-packages/libcloud/common/base.py", line 195, in parse_body driver=self.connection.driver) libcloud.common.types.MalformedResponseError: <MalformedResponseException in <libcloud.compute.drivers.cloudstack.CloudStackNodeDriver object at 0x7fc356f55b50> 'Failed to parse JSON'>: 'Unknown_ApiKey' Where iam missing? 

Thanks, Indu


Source: (StackOverflow)

Deploy the existing node in Libcloud

I'm working with libcloud but meet the difficulty:

I can use the method deploy_node() to deploy file/shell command to the cloud node. It work perfectly except that I have to pass the create node data inside the function. That means I cannot deploy to the existing node.

For example, now I can :

node = driver.deploy_node(name='myname', size='s1', image='i1', deployment='deployment1'...)

But what I want:

node = driver.create_node(name='myname', size='s1', image='i1')
node.deploy(deployment = 'deployment1)
OR:
driver.deploy(node, deployment = 'deployment1')

This is quite important because we can get the existing node with libcloud via list_nodes() but we cannot deploy via libcloud independently.

If anyone of you have idea with this matter, please help me.

Thank you very much!!!


Source: (StackOverflow)

Is it possible to return a specific nodes flavor?

Is it possible to return a specific nodes flavor? i am trying to capture this for a group of nodes on rackspace so it can be stored for back up and audit purposes


Source: (StackOverflow)

Instance failing to boot from disk on Google Compute Engine

I'm trying to boot an instance on GCE through libcloud.

When I boot through the libcloud function, ex_create_multiple_nodes (with 1 machine specified), the instance and the disk are created successfully, and the disk is attached. I verify this through the developer console. No exceptions are thrown by the function call.

Unfortunately, the instance never boots successfully: ... Booting from Hard Disk... Boot failed: not a bootable disk ... Full log: https://gist.github.com/danwinkler/dcf1351675eb8c744220 (This repeats again and again)

I've tested booting with the same parameters (snapshot, zone, size, etc.) through the developers console and it works fine.

A colleague pointed out that the error looks similar to those caused by virt-manager, but I don't see anything related to that in the docs or the console Link.

Thanks!


Source: (StackOverflow)