Exemple #1
0
    def __init__(self, virtapi, read_only=False, scheme="https"):
        super(VMwareESXDriver, self).__init__(virtapi)

        self._do_deprecation_warning()

        self._host_ip = CONF.vmware.host_ip
        if not (self._host_ip or CONF.vmware.host_username is None or
                        CONF.vmware.host_password is None):
            raise Exception(_("Must specify host_ip, "
                              "host_username "
                              "and host_password to use "
                              "compute_driver=vmwareapi.VMwareESXDriver or "
                              "vmwareapi.VMwareVCDriver"))

        self._datastore_regex = None
        if CONF.vmware.datastore_regex:
            try:
                self._datastore_regex = re.compile(CONF.vmware.datastore_regex)
            except re.error:
                raise exception.InvalidInput(reason=
                    _("Invalid Regular Expression %s")
                    % CONF.vmware.datastore_regex)

        self._session = VMwareAPISession(scheme=scheme)
        self._volumeops = volumeops.VMwareVolumeOps(self._session)
        self._vmops = vmops.VMwareVMOps(self._session, self.virtapi,
                                        self._volumeops,
                                        datastore_regex=self._datastore_regex)
        self._host = host.Host(self._session)
        self._host_state = None

        #TODO(hartsocks): back-off into a configuration test module.
        if CONF.vmware.use_linked_clone is None:
            raise error_util.UseLinkedCloneConfigurationFault()
Exemple #2
0
 def __init__(self, virtapi, read_only=False, scheme="https"):
     super(VMwareVCDriver, self).__init__(virtapi)
     self._cluster_name = CONF.vmware.cluster_name
     if not self._cluster_name:
         self._cluster = None
     else:
         self._cluster = vm_util.get_cluster_ref_from_name(
                         self._session, self._cluster_name)
         if self._cluster is None:
             raise exception.NotFound(_("VMware Cluster %s is not found")
                                        % self._cluster_name)
     self._datastore_regex = None
     if CONF.vmware.datastore_regex:
         try:
             self._datastore_regex = re.compile(CONF.vmware.datastore_regex)
         except re.error:
             raise exception.InvalidInput(reason=
             _("Invalid Regular Expression %s")
             % CONF.vmware.datastore_regex)
     self._volumeops = volumeops.VMwareVolumeOps(self._session,
                                                 self._cluster)
     self._vmops = vmops.VMwareVMOps(self._session, self.virtapi,
                                     self._volumeops, self._cluster,
                                     self._datastore_regex)
     self._vc_state = None
Exemple #3
0
    def __init__(self, virtapi, read_only=False, scheme="https"):
        super(VMwareESXDriver, self).__init__(virtapi)

        self._host_ip = CONF.vmwareapi_host_ip
        host_username = CONF.vmwareapi_host_username
        host_password = CONF.vmwareapi_host_password
        api_retry_count = CONF.vmwareapi_api_retry_count
        if not self._host_ip or host_username is None or host_password is None:
            raise Exception(
                _("Must specify vmwareapi_host_ip,"
                  "vmwareapi_host_username "
                  "and vmwareapi_host_password to use"
                  "compute_driver=vmwareapi.VMwareESXDriver or "
                  "vmwareapi.VMwareVCDriver"))

        self._session = VMwareAPISession(self._host_ip,
                                         host_username,
                                         host_password,
                                         api_retry_count,
                                         scheme=scheme)
        self._volumeops = volumeops.VMwareVolumeOps(self._session)
        self._vmops = vmops.VMwareVMOps(self._session, self.virtapi,
                                        self._volumeops)
        self._host = host.Host(self._session)
        self._host_state = None
Exemple #4
0
    def __init__(self, virtapi, read_only=False, scheme="https"):
        super(VMwareESXDriver, self).__init__(virtapi)

        self._do_quality_warnings()

        self._host_ip = CONF.vmware.host_ip
        if not (self._host_ip or CONF.vmware.host_username is None
                or CONF.vmware.host_password is None):
            raise Exception(
                _("Must specify host_ip, "
                  "host_username "
                  "and host_password to use "
                  "compute_driver=vmwareapi.VMwareESXDriver or "
                  "vmwareapi.VMwareVCDriver"))

        self._session = VMwareAPISession(scheme=scheme)
        self._volumeops = volumeops.VMwareVolumeOps(self._session)
        self._vmops = vmops.VMwareVMOps(self._session, self.virtapi,
                                        self._volumeops)
        self._host = host.Host(self._session)
        self._host_state = None

        #TODO(hartsocks): back-off into a configuration test module.
        if CONF.vmware.use_linked_clone is None:
            raise error_util.UseLinkedCloneConfigurationFault()
    def setUp(self):
        super(VMwareVolumeOpsTestCase, self).setUp()
        vmwareapi_fake.reset()
        stubs.set_stubs(self.stubs)

        self._session = driver.VMwareAPISession()
        self._volumeops = volumeops.VMwareVolumeOps(self._session)
        self.instance = {'name': 'fake_name', 'uuid': 'fake_uuid'}
Exemple #6
0
    def __init__(self, virtapi, scheme="https"):
        super(VMwareVCDriver, self).__init__(virtapi)

        if (CONF.vmware.host_ip is None or
            CONF.vmware.host_username is None or
            CONF.vmware.host_password is None):
            raise Exception(_("Must specify host_ip, host_username and "
                              "host_password to use vmwareapi.VMwareVCDriver"))

        if CONF.vnc.keymap:
            LOG.warning('The option "[vnc] keymap" has been deprecated in '
                        'favor of the VMWare-specific "[vmware] vnc_keymap" '
                        'option. Please update nova.conf to address this '
                        'change')

        self._datastore_regex = None
        if CONF.vmware.datastore_regex:
            try:
                self._datastore_regex = re.compile(CONF.vmware.datastore_regex)
            except re.error:
                raise exception.InvalidInput(reason=
                    _("Invalid Regular Expression %s")
                    % CONF.vmware.datastore_regex)

        self._session = VMwareAPISession(scheme=scheme)

        self._check_min_version()

        # Update the PBM location if necessary
        if CONF.vmware.pbm_enabled:
            self._update_pbm_location()

        self._validate_configuration()
        self._cluster_name = CONF.vmware.cluster_name
        self._cluster_ref = vm_util.get_cluster_ref_by_name(self._session,
                                                            self._cluster_name)
        if self._cluster_ref is None:
            raise exception.NotFound(_("The specified cluster '%s' was not "
                                       "found in vCenter")
                                     % self._cluster_name)
        self._vcenter_uuid = self._get_vcenter_uuid()
        self._nodename = self._create_nodename(self._cluster_ref.value)
        self._volumeops = volumeops.VMwareVolumeOps(self._session,
                                                    self._cluster_ref)
        self._vmops = vmops.VMwareVMOps(self._session,
                                        virtapi,
                                        self._volumeops,
                                        self._cluster_ref,
                                        datastore_regex=self._datastore_regex)
        self._vc_state = host.VCState(self._session,
                                      self._nodename,
                                      self._cluster_ref,
                                      self._datastore_regex)

        # Register the OpenStack extension
        self._register_openstack_extension()
Exemple #7
0
 def __init__(self, virtapi, read_only=False, scheme="https"):
     super(VMwareVCDriver, self).__init__(virtapi)
     self._cluster_name = CONF.vmwareapi_cluster_name
     if not self._cluster_name:
         self._cluster = None
     else:
         self._cluster = vm_util.get_cluster_ref_from_name(
             self._session, self._cluster_name)
         if self._cluster is None:
             raise exception.NotFound(
                 _("VMware Cluster %s is not found") % self._cluster_name)
     self._volumeops = volumeops.VMwareVolumeOps(self._session,
                                                 self._cluster)
     self._vmops = vmops.VMwareVMOps(self._session, self.virtapi,
                                     self._volumeops, self._cluster)
     self._vc_state = None
Exemple #8
0
    def _update_resources(self):
        """This method creates a dictionary of VMOps, VolumeOps and VCState.

        The VMwareVMOps, VMwareVolumeOps and VCState object is for each
        cluster/rp. The dictionary is of the form
        {
            domain-1000 : {'vmops': vmops_obj,
                          'volumeops': volumeops_obj,
                          'vcstate': vcstate_obj,
                          'name': MyCluster},
            resgroup-1000 : {'vmops': vmops_obj,
                              'volumeops': volumeops_obj,
                              'vcstate': vcstate_obj,
                              'name': MyRP},
        }
        """

        # TODO(kirankv) we can avoid creating multiple vmops and volumeops
        # if we make them utility class so that cluster is passed as a
        # parameter to the method
        added_nodes = set(self.dict_mors.keys()) - set(self._resources.keys())
        for node in added_nodes:
            _volumeops = volumeops.VMwareVolumeOps(
                self._session,
                self.dict_mors[node]['cluster_mor'],
                vc_support=True)
            _vmops = vmops.VMwareVMOps(self._session, self._virtapi,
                                       _volumeops,
                                       self.dict_mors[node]['cluster_mor'])
            name = self.dict_mors.get(node)['name']
            _vc_state = host.VCState(self._session,
                                     self._create_nodename(node, name),
                                     self.dict_mors.get(node)['cluster_mor'])
            self._resources[node] = {
                'vmops': _vmops,
                'volumeops': _volumeops,
                'vcstate': _vc_state,
                'name': name,
            }
        deleted_nodes = (set(self._resources.keys()) -
                         set(self.dict_mors.keys()))
        for node in deleted_nodes:
            LOG.debug(
                _("Removing node %s since its removed from"
                  " nova.conf") % node)
            del self._resources[node]
Exemple #9
0
    def _update_resources(self):
        """This method creates a dictionary of VMOps, VolumeOps and VCState.

        The VMwareVMOps, VMwareVolumeOps and VCState object is for each
        cluster/rp. The dictionary is of the form
        {
            domain-1000 : {'vmops': vmops_obj,
                          'volumeops': volumeops_obj,
                          'vcstate': vcstate_obj,
                          'name': MyCluster},
            resgroup-1000 : {'vmops': vmops_obj,
                              'volumeops': volumeops_obj,
                              'vcstate': vcstate_obj,
                              'name': MyRP},
        }
        """
        added_nodes = set(self.dict_mors.keys()) - set(self._resource_keys)
        for node in added_nodes:
            _volumeops = volumeops.VMwareVolumeOps(
                self._session,
                self.dict_mors[node]['cluster_mor'],
                vc_support=True)
            _vmops = vmops.VMwareVCVMOps(self._session,
                                         self._virtapi,
                                         _volumeops,
                                         self.dict_mors[node]['cluster_mor'],
                                         datastore_regex=self._datastore_regex)
            name = self.dict_mors.get(node)['name']
            nodename = self._create_nodename(node, name)
            _vc_state = host.VCState(self._session, nodename,
                                     self.dict_mors.get(node)['cluster_mor'])
            self._resources[nodename] = {
                'vmops': _vmops,
                'volumeops': _volumeops,
                'vcstate': _vc_state,
                'name': name,
            }
            self._resource_keys.add(node)

        deleted_nodes = (set(self._resource_keys) - set(self.dict_mors.keys()))
        for node in deleted_nodes:
            name = self.dict_mors.get(node)['name']
            nodename = self._create_nodename(node, name)
            del self._resources[nodename]
            self._resource_keys.discard(node)
Exemple #10
0
    def setUp(self):

        super(VMwareVolumeOpsTestCase, self).setUp()
        vmwareapi_fake.reset()
        stubs.set_stubs(self.stubs)
        self._session = driver.VMwareAPISession()
        self._context = context.RequestContext('fake_user', 'fake_project')

        self._volumeops = volumeops.VMwareVolumeOps(self._session)
        self._image_id = image_fake.get_valid_image_id()
        self._instance_values = {
            'name': 'fake_name',
            'uuid': 'fake_uuid',
            'vcpus': 1,
            'memory_mb': 512,
            'image_ref': self._image_id,
            'root_gb': 10,
            'node': 'respool-1001(MyResPoolName)',
            'expected_attrs': ['system_metadata'],
        }
        self._instance = fake_instance.fake_instance_obj(self._context,
            **self._instance_values)
Exemple #11
0
    def __init__(self, virtapi, scheme="https"):
        super(VMwareVCDriver, self).__init__(virtapi)

        if (CONF.vmware.host_ip is None or
            CONF.vmware.host_username is None or
            CONF.vmware.host_password is None):
            raise Exception(_("Must specify host_ip, host_username and "
                              "host_password to use vmwareapi.VMwareVCDriver"))

        # Begin Pf9 change
        # Get the list of datastores, and convert to a regex - Pf9 UI passes this in as a comma-separated list
        self._datastore_regex = None
        ds_list = CONF.vmware.datastore_regex

        if ds_list:
            # Convert 'ds1, ds2,ds3,   ds4' => 'ds1|ds2|ds3|ds4'
            regex_string = "|".join([item.rstrip().lstrip() for item in ds_list.split(',')])
            if regex_string != '':
                try:
                    self._datastore_regex = re.compile(regex_string)
                except re.error:
                    raise exception.InvalidInput(reason=
                    _("Invalid Regular Expression %s")
                    % regex_string)

        self._pf9_hostid = CONF.host
        # End Pf9 change

        self._session = VMwareAPISession(scheme=scheme)

        self._check_min_version()

        # Update the PBM location if necessary
        if CONF.vmware.pbm_enabled:
            self._update_pbm_location()

        self._validate_configuration()
        self._cluster_name = CONF.vmware.cluster_name
        self._cluster_ref = vm_util.get_cluster_ref_by_name(self._session,
                                                            self._cluster_name)
        if self._cluster_ref is None:
            raise exception.NotFound(_("The specified cluster '%s' was not "
                                       "found in vCenter")
                                     % self._cluster_name)
        self._vcenter_uuid = self._get_vcenter_uuid()
        self._nodename = self._create_nodename(self._cluster_ref.value,
                                               self._cluster_name)
        self._volumeops = volumeops.VMwareVolumeOps(self._session,
                                                    self._cluster_ref)
        self._vmops = vmops.VMwareVMOps(self._session,
                                        virtapi,
                                        self._volumeops,
                                        self._cluster_ref,
                                        datastore_regex=self._datastore_regex)
        self._vc_state = host.VCState(self._session,
                                      self._nodename,
                                      self._cluster_ref,
                                      self._datastore_regex)

        # Register the OpenStack extension
        self._register_openstack_extension()