Exemplo n.º 1
0
    def __init__(self, ip, username, password):
        """
        Initializes the object with credentials and connection information
        Requires novaclient library to be installed on the node this code is executed
        Uses v2 api in Kilo/Liberty (v1 is deprecated in Kilo/Liberty)
        Uses v1_1 api in Juno
        """
        try:
            from novaclient.v2 import client as nova_client
        except ImportError:
            from novaclient.v1_1 import client as nova_client

        try:
            from cinderclient.v2 import client as cinder_client
        except ImportError:
            from cinderclient.v1 import client as cinder_client
        from novaclient import exceptions
        self._novaclientexceptions = exceptions
        self.nova_client = nova_client.Client(username = username,
                                              api_key = password,
                                              project_id = 'admin',
                                              auth_url = 'http://{}:35357/v2.0'.format(ip),
                                              service_type="compute")
        self.cinder_client = cinder_client.Client(username = username,
                                                  api_key = password,
                                                  project_id = 'admin',
                                                  auth_url = 'http://{}:35357/v2.0'.format(ip),
                                                  service_type="volumev2")
        self.management = OpenStackManagement(cinder_client = self.cinder_client)
        self.metadata = {}
        self.config_cinder = False
        self.STATE_MAPPING = {'up': 'RUNNING'}

        logger.debug('Init complete')