Пример #1
0
    def test_check_data_with_valid_values_and_without_restrictions(self):
        # Disable restrictions
        attributes = objects.Cluster.get_editable_attributes(self.cluster)
        attributes['common']['use_vcenter']['value'] = True
        attributes['storage']['images_vcenter']['value'] = True
        vmware_attributes = self.vm_data.copy()
        # Set valid data for clusters
        for i, azone in enumerate(
                vmware_attributes['editable']['value']['availability_zones']):
            for j, ncompute in enumerate(azone['nova_computes']):
                ncompute['vsphere_cluster'] = 'cluster-{0}-{1}'.format(i, j)
        # Set valid data for glance
        glance = vmware_attributes['editable']['value']['glance']
        glance['datacenter'] = 'test_datacenter'
        glance['datastore'] = 'test_datastore'
        models = {
            'settings': attributes,
            'default': vmware_attributes['editable'],
            'cluster': self.cluster,
            'version': settings.VERSION,
            'networking_parameters': self.cluster.network_config
        }

        errs = VmwareAttributesRestriction.check_data(
            models=models,
            metadata=vmware_attributes['editable']['metadata'],
            data=vmware_attributes['editable']['value'])
        self.assertItemsEqual(errs, [])
Пример #2
0
    def _check_vmware_consistency(cls, task):
        """Checks vmware attributes consistency and proper values
        """
        attributes = task.cluster.attributes.editable
        vmware_attributes = task.cluster.vmware_attributes
        # Old(< 6.1) clusters haven't vmware support
        if vmware_attributes:
            cinder_nodes = filter(
                lambda node: 'cinder' in node.all_roles,
                task.cluster.nodes)

            if not cinder_nodes:
                logger.info('There is no any node with "cinder" role provided')

            models = {
                'settings': attributes,
                'default': vmware_attributes.editable,
                'cluster': task.cluster,
                'version': settings.VERSION,
                'networking_parameters': task.cluster.network_config
            }

            errors_msg = VmwareAttributesRestriction.check_data(
                models=models,
                metadata=vmware_attributes.editable['metadata'],
                data=vmware_attributes.editable['value'])

            if errors_msg:
                raise errors.CheckBeforeDeploymentError('\n'.join(errors_msg))
Пример #3
0
    def _check_vmware_consistency(cls, task):
        """Checks vmware attributes consistency and proper values
        """
        attributes = task.cluster.attributes.editable
        vmware_attributes = task.cluster.vmware_attributes
        # Old(< 6.1) clusters haven't vmware support
        if vmware_attributes:
            cinder_nodes = filter(lambda node: 'cinder' in node.all_roles,
                                  task.cluster.nodes)

            if not cinder_nodes:
                logger.info('There is no any node with "cinder" role provided')

            models = {
                'settings': attributes,
                'default': vmware_attributes.editable,
                'cluster': task.cluster,
                'version': settings.VERSION,
                'networking_parameters': task.cluster.network_config
            }

            errors_msg = VmwareAttributesRestriction.check_data(
                models=models,
                metadata=vmware_attributes.editable['metadata'],
                data=vmware_attributes.editable['value'])

            if errors_msg:
                raise errors.CheckBeforeDeploymentError('\n'.join(errors_msg))
    def test_check_data_with_valid_values_and_without_restrictions(self):
        # Disable restrictions
        attributes = objects.Cluster.get_editable_attributes(self.cluster)
        attributes["common"]["use_vcenter"]["value"] = True
        attributes["storage"]["images_vcenter"]["value"] = True
        vmware_attributes = self.vm_data.copy()
        # Set valid data for clusters
        for i, azone in enumerate(vmware_attributes["editable"]["value"]["availability_zones"]):
            for j, ncompute in enumerate(azone["nova_computes"]):
                ncompute["vsphere_cluster"] = "cluster-{0}-{1}".format(i, j)
        # Set valid data for glance
        glance = vmware_attributes["editable"]["value"]["glance"]
        glance["datacenter"] = "test_datacenter"
        glance["datastore"] = "test_datastore"
        models = {
            "settings": attributes,
            "default": vmware_attributes["editable"],
            "cluster": self.cluster,
            "version": settings.VERSION,
            "networking_parameters": self.cluster.network_config,
        }

        errs = VmwareAttributesRestriction.check_data(
            models=models,
            metadata=vmware_attributes["editable"]["metadata"],
            data=vmware_attributes["editable"]["value"],
        )
        self.assertItemsEqual(errs, [])
Пример #5
0
    def test_check_data_with_empty_values_without_restrictions(self):
        attributes = objects.Cluster.get_attributes(self.cluster).editable
        attributes['common']['use_vcenter']['value'] = True
        attributes['storage']['images_vcenter']['value'] = True
        vmware_attributes = self.vm_data.copy()
        empty_values = {
            "availability_zones": [
                {
                    "az_name": "",
                    "vcenter_host": "",
                    "vcenter_username": "",
                    "vcenter_password": "",
                    "nova_computes": [
                        {
                            "vsphere_cluster": "",
                            "service_name": "",
                            "datastore_regex": ""
                        }
                    ],
                    "cinder": {
                        "enable": True
                    }
                }
            ],
            "network": {
                "esxi_vlan_interface": ""
            },
            "glance": {
                "vcenter_host": "",
                "vcenter_username": "",
                "vcenter_password": "",
                "datacenter": "",
                "datastore": ""
            }
        }
        # Update value with empty value
        vmware_attributes['editable']['value'] = empty_values
        models = {
            'settings': attributes,
            'default': vmware_attributes['editable'],
            'cluster': self.cluster,
            'version': settings.VERSION,
            'networking_parameters': self.cluster.network_config
        }

        errs = VmwareAttributesRestriction.check_data(
            models=models,
            metadata=vmware_attributes['editable']['metadata'],
            data=vmware_attributes['editable']['value'])
        self.assertItemsEqual(
            errs,
            ['Empty cluster', 'Empty host', 'Empty username',
             'Empty password', 'Empty datacenter', 'Empty datastore'])
Пример #6
0
    def test_check_data_with_empty_values_without_restrictions(self):
        attributes = objects.Cluster.get_editable_attributes(self.cluster)
        attributes['common']['use_vcenter']['value'] = True
        attributes['storage']['images_vcenter']['value'] = True
        vmware_attributes = self.vm_data.copy()
        empty_values = {
            "availability_zones": [
                {
                    "az_name": "",
                    "vcenter_host": "",
                    "vcenter_username": "",
                    "vcenter_password": "",
                    "nova_computes": [
                        {
                            "vsphere_cluster": "",
                            "service_name": "",
                            "datastore_regex": ""
                        }
                    ]
                }
            ],
            "network": {
                "esxi_vlan_interface": ""
            },
            "glance": {
                "vcenter_host": "",
                "vcenter_username": "",
                "vcenter_password": "",
                "datacenter": "",
                "datastore": ""
            }
        }
        # Update value with empty value
        vmware_attributes['editable']['value'] = empty_values
        models = {
            'settings': attributes,
            'default': vmware_attributes['editable'],
            'cluster': self.cluster,
            'version': settings.VERSION,
            'networking_parameters': self.cluster.network_config
        }

        errs = VmwareAttributesRestriction.check_data(
            models=models,
            metadata=vmware_attributes['editable']['metadata'],
            data=vmware_attributes['editable']['value'])
        self.assertItemsEqual(
            errs,
            ['Empty cluster', 'Empty host', 'Empty username',
             'Empty password', 'Empty datacenter', 'Empty datastore'])
Пример #7
0
    def test_check_data_with_invalid_values_and_with_restrictions(self):
        attributes = objects.Cluster.get_editable_attributes(self.cluster)
        # fixture have restrictions enabled for glance that's why
        # only 'Empty cluster' should returned
        vmware_attributes = self.vm_data.copy()
        models = {
            'settings': attributes,
            'default': vmware_attributes['editable'],
            'cluster': self.cluster,
            'version': settings.VERSION,
            'networking_parameters': self.cluster.network_config
        }

        errs = VmwareAttributesRestriction.check_data(
            models=models,
            metadata=vmware_attributes['editable']['metadata'],
            data=vmware_attributes['editable']['value'])
        self.assertItemsEqual(errs, ['Empty cluster'])
    def test_check_data_with_invalid_values_and_with_restrictions(self):
        attributes = objects.Cluster.get_editable_attributes(self.cluster)
        # fixture have restrictions enabled for glance that's why
        # only 'Empty cluster' should returned
        vmware_attributes = self.vm_data.copy()
        models = {
            "settings": attributes,
            "default": vmware_attributes["editable"],
            "cluster": self.cluster,
            "version": settings.VERSION,
            "networking_parameters": self.cluster.network_config,
        }

        errs = VmwareAttributesRestriction.check_data(
            models=models,
            metadata=vmware_attributes["editable"]["metadata"],
            data=vmware_attributes["editable"]["value"],
        )
        self.assertItemsEqual(errs, ["Empty cluster"])
    def test_check_data_with_empty_values_without_restrictions(self):
        attributes = objects.Cluster.get_editable_attributes(self.cluster)
        attributes["common"]["use_vcenter"]["value"] = True
        attributes["storage"]["images_vcenter"]["value"] = True
        vmware_attributes = self.vm_data.copy()
        empty_values = {
            "availability_zones": [
                {
                    "az_name": "",
                    "vcenter_host": "",
                    "vcenter_username": "",
                    "vcenter_password": "",
                    "nova_computes": [{"vsphere_cluster": "", "service_name": "", "datastore_regex": ""}],
                }
            ],
            "network": {"esxi_vlan_interface": ""},
            "glance": {
                "vcenter_host": "",
                "vcenter_username": "",
                "vcenter_password": "",
                "datacenter": "",
                "datastore": "",
            },
        }
        # Update value with empty value
        vmware_attributes["editable"]["value"] = empty_values
        models = {
            "settings": attributes,
            "default": vmware_attributes["editable"],
            "cluster": self.cluster,
            "version": settings.VERSION,
            "networking_parameters": self.cluster.network_config,
        }

        errs = VmwareAttributesRestriction.check_data(
            models=models,
            metadata=vmware_attributes["editable"]["metadata"],
            data=vmware_attributes["editable"]["value"],
        )
        self.assertItemsEqual(
            errs,
            ["Empty cluster", "Empty host", "Empty username", "Empty password", "Empty datacenter", "Empty datastore"],
        )
Пример #10
0
    def test_check_data_with_invalid_values_without_restrictions(self):
        # Disable restrictions
        attributes = objects.Cluster.get_editable_attributes(self.cluster)
        attributes['common']['use_vcenter']['value'] = True
        attributes['storage']['images_vcenter']['value'] = True
        # value data taken from fixture one cluster of
        # nova computes left empty
        vmware_attributes = self.vm_data.copy()
        models = {
            'settings': attributes,
            'default': vmware_attributes['editable'],
            'cluster': self.cluster,
            'version': settings.VERSION,
            'networking_parameters': self.cluster.network_config
        }

        errs = VmwareAttributesRestriction.check_data(
            models=models,
            metadata=vmware_attributes['editable']['metadata'],
            data=vmware_attributes['editable']['value'])
        self.assertItemsEqual(errs, ['Empty cluster'])
    def test_check_data_with_invalid_values_without_restrictions(self):
        # Disable restrictions
        attributes = objects.Cluster.get_editable_attributes(self.cluster)
        attributes["common"]["use_vcenter"]["value"] = True
        attributes["storage"]["images_vcenter"]["value"] = True
        # value data taken from fixture one cluster of
        # nova computes left empty
        vmware_attributes = self.vm_data.copy()
        models = {
            "settings": attributes,
            "default": vmware_attributes["editable"],
            "cluster": self.cluster,
            "version": settings.VERSION,
            "networking_parameters": self.cluster.network_config,
        }

        errs = VmwareAttributesRestriction.check_data(
            models=models,
            metadata=vmware_attributes["editable"]["metadata"],
            data=vmware_attributes["editable"]["value"],
        )
        self.assertItemsEqual(errs, ["Empty cluster"])