コード例 #1
0
def _init_cloudmanager_attributes(res_id, attributes):
    cloudmanager_type = cm_util.get_config_option(res_id, 'cm_type', CLOUDMANAGERS_CONFIG_FILE)
	# Initialize here specific attributes for OpenStack

    attributes["cm_base_url"] = cm_util.get_config_option(res_id, "url", CLOUDMANAGERS_CONFIG_FILE)
    attributes["cm_keystone_url"] = cm_util.get_config_option(res_id, "keystone_base_url", CLOUDMANAGERS_CONFIG_FILE)
    attributes["cm_nova_url"] = cm_util.get_config_option(res_id, "nova_base_url", CLOUDMANAGERS_CONFIG_FILE)
    attributes["cm_tenant_name"] = cm_util.get_config_option(res_id, "tenant_name", CLOUDMANAGERS_CONFIG_FILE)
    attributes["cm_username"] = cm_util.get_config_option(res_id, "username", CLOUDMANAGERS_CONFIG_FILE)
    attributes["cm_password"] = cm_util.get_config_option(res_id, "password", CLOUDMANAGERS_CONFIG_FILE)
コード例 #2
0
    def listimages(self, res_id=None, attributes=None):
        status={}
        error = None
        if(attributes is None):
            status['cloudmanagers'] = res_id
            status['url'] = cm_util.get_config_option(res_id, "url", self.CLOUDMANAGERS_CONFIG_FILE)

            # Retrieve the good module
            cm_type = self._get_cloudmanager_type(res_id)
            module = self._load_driver_module(cm_type)

            # Initialize mandatory attributes depending on cloud manager's type
            module._init_cloudmanager_attributes(res_id, attributes)

            status['images'] = module._get_images(attributes)

        else:
            raise ResourceException("No arguments are yet allowed for this method")

        return status
コード例 #3
0
    def listimages(self, res_id=None, attributes=None):
        status = {}
        error = None
        if (attributes is None):
            status['cloudmanagers'] = res_id
            status['url'] = cm_util.get_config_option(
                res_id, "url", self.CLOUDMANAGERS_CONFIG_FILE)

            # Retrieve the good module
            cm_type = self._get_cloudmanager_type(res_id)
            module = self._load_driver_module(cm_type)

            # Initialize mandatory attributes depending on cloud manager's type
            module._init_cloudmanager_attributes(res_id, attributes)

            status['images'] = module._get_images(attributes)

        else:
            raise ResourceException(
                "No arguments are yet allowed for this method")

        return status
コード例 #4
0
    def read(self, res_id=None, attributes=None):
        status = {}
        error = None
        # If the cloud manager's id is not specified, the method will return a
        # list of the managed cloud managers ids
        if res_id == "":
            status['cloudmanagers'] = self._get_cloudmanagers()

        # If only the cloud manager's id is given, the method will return a
        # list of the existing virtual machines on the cloud manager
        elif (attributes is None
              or "name" not in attributes and "listimages" not in attributes):
            status['cloudmanagers'] = res_id
            status['url'] = cm_util.get_config_option(
                res_id, "url", self.CLOUDMANAGERS_CONFIG_FILE)

            # Retrieve the good module
            cm_type = self._get_cloudmanager_type(res_id)
            module = self._load_driver_module(cm_type)

            # Initialize mandatory attributes depending on cloud manager's type
            module._init_cloudmanager_attributes(res_id, attributes)

            # Retrieve the list of VMs
            status['VMs'] = module._get_VMs(attributes)

        elif ("listimages" in attributes):
            status['cloudmanagers'] = res_id
            status['url'] = cm_util.get_config_option(
                res_id, "url", self.CLOUDMANAGERS_CONFIG_FILE)

            # Retrieve the good module
            cm_type = self._get_cloudmanager_type(res_id)
            module = self._load_driver_module(cm_type)

            # Initialize mandatory attributes depending on cloud manager's type
            module._init_cloudmanager_attributes(res_id, attributes)

            status['images'] = module._get_images(attributes)
        else:
            # Retrieve the good module
            cm_type = self._get_cloudmanager_type(res_id)
            module = self._load_driver_module(cm_type)
            # Initialize mandatory attributes depending on cloud manager's type
            module._init_cloudmanager_attributes(res_id, attributes)

            # Check if the VM exists and retrieve the various important fields to return
            if module._exists(attributes):
                status['cloudmanager'] = res_id
                status['url'] = cm_util.get_config_option(
                    res_id, "url", self.CLOUDMANAGERS_CONFIG_FILE)
                status['vm_name'] = attributes['name']

                try:
                    status['vm_vcpus'] = module._get_vcpus(attributes)
                except ResourceException, ex:
                    status['vm_vcpus'] = str(ex)

                try:
                    vm = module._get_VM(attributes)
                    vm_id = vm['id']
                    flavor = module._get_flavor(attributes, vm['id'])
                    status['vm_flavor'] = flavor['id']
                except ResourceException, ex:
                    status['vm_flavor'] = str(ex)

                status['vm_vnc_port'] = module._get_vnc_port(attributes)
コード例 #5
0
 def _get_cloudmanager_type(self, res_id):
     return cm_util.get_config_option(res_id, "cm_type",
                                      self.CLOUDMANAGERS_CONFIG_FILE)
コード例 #6
0
    def read(self, res_id=None, attributes=None):
        status = {}
        error = None
        # If the cloud manager's id is not specified, the method will return a
        # list of the managed cloud managers ids
        if res_id == "":
            status['cloudmanagers'] = self._get_cloudmanagers()

        # If only the cloud manager's id is given, the method will return a
        # list of the existing virtual machines on the cloud manager
        elif (attributes is None or "name" not in attributes and "listimages" not in attributes):
            status['cloudmanagers'] = res_id
            status['url'] = cm_util.get_config_option(res_id, "url", self.CLOUDMANAGERS_CONFIG_FILE)

            # Retrieve the good module
            cm_type = self._get_cloudmanager_type(res_id)
            module = self._load_driver_module(cm_type)

            # Initialize mandatory attributes depending on cloud manager's type
            module._init_cloudmanager_attributes(res_id, attributes)

            # Retrieve the list of VMs
            status['VMs'] = module._get_VMs(attributes)

        elif ("listimages" in attributes):
            status['cloudmanagers'] = res_id
            status['url'] = cm_util.get_config_option(res_id, "url", self.CLOUDMANAGERS_CONFIG_FILE)

            # Retrieve the good module
            cm_type = self._get_cloudmanager_type(res_id)
            module = self._load_driver_module(cm_type)

            # Initialize mandatory attributes depending on cloud manager's type
            module._init_cloudmanager_attributes(res_id, attributes)

            status['images'] = module._get_images(attributes)
        else:
            # Retrieve the good module
            cm_type = self._get_cloudmanager_type(res_id)
            module = self._load_driver_module(cm_type)
            # Initialize mandatory attributes depending on cloud manager's type
            module._init_cloudmanager_attributes(res_id, attributes)

            # Check if the VM exists and retrieve the various important fields to return
            if module._exists(attributes):
                status['cloudmanager'] = res_id
                status['url'] = cm_util.get_config_option(res_id, "url", self.CLOUDMANAGERS_CONFIG_FILE)
                status['vm_name'] = attributes['name']

                try:
                    status['vm_vcpus'] = module._get_vcpus(attributes)
                except ResourceException, ex:
                    status['vm_vcpus'] = str(ex)

                try:
                    vm = module._get_VM(attributes)
                    vm_id = vm['id']
                    flavor = module._get_flavor(attributes, vm['id'])
                    status['vm_flavor'] = flavor['id']
                except ResourceException, ex:
                    status['vm_flavor'] = str(ex)

                status['vm_vnc_port'] = module._get_vnc_port(attributes)
コード例 #7
0
    def _get_cloudmanager_type(self, res_id):
		return cm_util.get_config_option(res_id, "cm_type", self.CLOUDMANAGERS_CONFIG_FILE)