コード例 #1
0
    def test_translate_floating_ips_view(self):
        mock_trans = mock.Mock()
        mock_trans.return_value = {'floating_ip': 'foo'}
        self.floating_ips._translate_floating_ip_view = mock_trans
        fip1 = objects.FixedIP(address='192.168.1.2', instance_uuid=FAKE_UUID)
        fip2 = objects.FixedIP(address='192.168.1.3', instance_uuid=FAKE_UUID)

        floaters = [
            self._build_floating_ip('10.0.0.2', fip1),
            self._build_floating_ip('10.0.0.3', fip2)
        ]

        result = self.floating_ips._translate_floating_ips_view(floaters)

        called_floaters = [call[0][0] for call in mock_trans.call_args_list]
        self.assertTrue(
            any(
                obj_base.obj_equal_prims(floaters[0], f)
                for f in called_floaters),
            "_translate_floating_ip_view was not called with all "
            "floating ips")
        self.assertTrue(
            any(
                obj_base.obj_equal_prims(floaters[1], f)
                for f in called_floaters),
            "_translate_floating_ip_view was not called with all "
            "floating ips")
        expected_result = {'floating_ips': ['foo', 'foo']}
        self.assertEqual(expected_result, result)
コード例 #2
0
 def test_create_with_tags_set(self):
     # Test that when we set tags on the build request,
     # create it and reload it from the database that the
     # build_request.instance.tags is the same thing.
     build_request_obj = fake_build_request.fake_req_obj(self.context)
     self.assertEqual(1, len(build_request_obj.tags))
     build_request_obj.create()
     self.assertEqual(1, len(build_request_obj.tags))
     self.assertEqual(len(build_request_obj.tags),
                      len(build_request_obj.instance.tags))
     # Can't compare list objects directly, just compare the single
     # item they contain.
     base.obj_equal_prims(build_request_obj.tags[0],
                          build_request_obj.instance.tags[0])
コード例 #3
0
ファイル: test_build_request.py プロジェクト: Juniper/nova
 def test_create_with_tags_set(self):
     # Test that when we set tags on the build request,
     # create it and reload it from the database that the
     # build_request.instance.tags is the same thing.
     build_request_obj = fake_build_request.fake_req_obj(self.context)
     self.assertEqual(1, len(build_request_obj.tags))
     build_request_obj.create()
     self.assertEqual(1, len(build_request_obj.tags))
     self.assertEqual(len(build_request_obj.tags),
                      len(build_request_obj.instance.tags))
     # Can't compare list objects directly, just compare the single
     # item they contain.
     base.obj_equal_prims(build_request_obj.tags[0],
                          build_request_obj.instance.tags[0])
コード例 #4
0
 def test_update_from_virt_driver(self):
     # copy in case the update has a side effect
     resources = copy.deepcopy(fake_resources)
     compute = compute_node.ComputeNode()
     compute.update_from_virt_driver(resources)
     expected = fake_compute_with_resources
     self.assertTrue(base.obj_equal_prims(expected, compute))
コード例 #5
0
 def test_get_by_project_id(self):
     create_group = self._api_group()
     get_groups = objects.InstanceGroupList.get_by_project_id(
         self.context, self.context.project_id)
     self.assertEqual(1, len(get_groups))
     self.assertTrue(base.obj_equal_prims(create_group, get_groups[0]))
     ovo_fixture.compare_obj(self, get_groups[0], create_group)
コード例 #6
0
ファイル: test_report.py プロジェクト: xx312022850/nova
    def test_get_resource_provider_found(self):
        # Ensure _get_resource_provider() returns a ResourceProvider object if
        # it finds a resource provider record from the placement API
        uuid = uuids.compute_node
        resp_mock = mock.Mock(status_code=200)
        json_data = {
            'uuid': uuid,
            'name': uuid,
            'generation': 42,
        }
        resp_mock.json.return_value = json_data
        self.ks_sess_mock.get.return_value = resp_mock

        result = self.client._get_resource_provider(uuid)

        expected_provider = objects.ResourceProvider(
            uuid=uuid,
            name=uuid,
            generation=42,
        )
        expected_url = '/resource_providers/' + uuid
        self.ks_sess_mock.get.assert_called_once_with(expected_url,
                                                      endpoint_filter=mock.ANY,
                                                      raise_exc=False)
        self.assertTrue(obj_base.obj_equal_prims(expected_provider, result))
コード例 #7
0
ファイル: test_report.py プロジェクト: j-griffith/nova
    def test_create_resource_provider(self):
        # Ensure _create_resource_provider() returns a ResourceProvider object
        # constructed after creating a resource provider record in the
        # placement API
        uuid = uuids.compute_node
        name = 'computehost'
        resp_mock = mock.Mock(status_code=201)
        self.ks_sess_mock.post.return_value = resp_mock

        result = self.client._create_resource_provider(uuid, name)

        expected_payload = {
            'uuid': uuid,
            'name': name,
        }
        expected_provider = objects.ResourceProvider(
            uuid=uuid,
            name=name,
            generation=1,
        )
        expected_url = '/resource_providers'
        self.ks_sess_mock.post.assert_called_once_with(
                expected_url,
                endpoint_filter=mock.ANY,
                json=expected_payload,
                raise_exc=False)
        self.assertTrue(obj_base.obj_equal_prims(expected_provider,
                                                 result))
コード例 #8
0
ファイル: test_report.py プロジェクト: j-griffith/nova
    def test_get_resource_provider_found(self):
        # Ensure _get_resource_provider() returns a ResourceProvider object if
        # it finds a resource provider record from the placement API
        uuid = uuids.compute_node
        resp_mock = mock.Mock(status_code=200)
        json_data = {
            'uuid': uuid,
            'name': uuid,
            'generation': 42,
        }
        resp_mock.json.return_value = json_data
        self.ks_sess_mock.get.return_value = resp_mock

        result = self.client._get_resource_provider(uuid)

        expected_provider = objects.ResourceProvider(
                uuid=uuid,
                name=uuid,
                generation=42,
        )
        expected_url = '/resource_providers/' + uuid
        self.ks_sess_mock.get.assert_called_once_with(expected_url,
                                                      endpoint_filter=mock.ANY,
                                                      raise_exc=False)
        self.assertTrue(obj_base.obj_equal_prims(expected_provider,
                                                 result))
コード例 #9
0
ファイル: test_instance_group.py プロジェクト: klmitch/nova
 def test_get_by_project_id(self):
     create_group = self._api_group()
     get_groups = objects.InstanceGroupList.get_by_project_id(
             self.context, self.context.project_id)
     self.assertEqual(1, len(get_groups))
     self.assertTrue(base.obj_equal_prims(create_group, get_groups[0]))
     ovo_fixture.compare_obj(self, get_groups[0], create_group)
コード例 #10
0
ファイル: test_report.py プロジェクト: xx312022850/nova
    def test_create_resource_provider(self):
        # Ensure _create_resource_provider() returns a ResourceProvider object
        # constructed after creating a resource provider record in the
        # placement API
        uuid = uuids.compute_node
        name = 'computehost'
        resp_mock = mock.Mock(status_code=201)
        self.ks_sess_mock.post.return_value = resp_mock

        result = self.client._create_resource_provider(uuid, name)

        expected_payload = {
            'uuid': uuid,
            'name': name,
        }
        expected_provider = objects.ResourceProvider(
            uuid=uuid,
            name=name,
            generation=1,
        )
        expected_url = '/resource_providers'
        self.ks_sess_mock.post.assert_called_once_with(
            expected_url,
            endpoint_filter=mock.ANY,
            json=expected_payload,
            raise_exc=False)
        self.assertTrue(obj_base.obj_equal_prims(expected_provider, result))
コード例 #11
0
 def test_update_from_virt_driver(self):
     # copy in case the update has a side effect
     resources = copy.deepcopy(fake_resources)
     compute = compute_node.ComputeNode()
     compute.update_from_virt_driver(resources)
     expected = fake_compute_with_resources
     self.assertTrue(base.obj_equal_prims(expected, compute))
コード例 #12
0
 def test_get_all(self):
     create_group = self._api_group()
     db_group = self._main_group()
     get_groups = objects.InstanceGroupList.get_all(self.context)
     self.assertEqual(2, len(get_groups))
     self.assertTrue(base.obj_equal_prims(create_group, get_groups[0]))
     ovo_fixture.compare_obj(self, get_groups[1], db_group)
コード例 #13
0
ファイル: resource_tracker.py プロジェクト: cosmo83/nova
 def _resource_change(self, compute_node):
     """Check to see if any resources have changed."""
     nodename = compute_node.hypervisor_hostname
     old_compute = self.old_resources[nodename]
     if not obj_base.obj_equal_prims(compute_node, old_compute):
         self.old_resources[nodename] = copy.deepcopy(compute_node)
         return True
     return False
コード例 #14
0
ファイル: resource_tracker.py プロジェクト: vmturbo/nova
 def _resource_change(self, compute_node):
     """Check to see if any resources have changed."""
     nodename = compute_node.hypervisor_hostname
     old_compute = self.old_resources[nodename]
     if not obj_base.obj_equal_prims(
             compute_node, old_compute, ['updated_at']):
         self.old_resources[nodename] = copy.deepcopy(compute_node)
         return True
     return False
コード例 #15
0
ファイル: test_request_spec.py プロジェクト: cyx1231st/nova
    def test_save_in_db(self):
        spec = self._create_spec()

        old_az = spec.availability_zone
        spec.availability_zone = "%s-new" % old_az
        spec.save()
        db_spec = self.spec_obj.get_by_instance_uuid(self.context, spec.instance_uuid)
        self.assertTrue(obj_base.obj_equal_prims(spec, db_spec))
        self.assertNotEqual(old_az, db_spec.availability_zone)
コード例 #16
0
ファイル: test_compute_node.py プロジェクト: mahak/nova
 def test_update_from_virt_driver(self):
     # copy in case the update has a side effect
     resources = copy.deepcopy(fake_resources)
     # Emulate the ironic driver which adds a uuid field.
     resources['uuid'] = uuidsentinel.node_uuid
     compute = compute_node.ComputeNode()
     compute.update_from_virt_driver(resources)
     expected = fake_compute_with_resources.obj_clone()
     expected.uuid = uuidsentinel.node_uuid
     self.assertTrue(base.obj_equal_prims(expected, compute))
コード例 #17
0
    def test_save_in_db(self):
        spec = self._create_spec()

        old_az = spec.availability_zone
        spec.availability_zone = '%s-new' % old_az
        spec.save()
        db_spec = self.spec_obj.get_by_instance_uuid(self.context,
                                                     spec.instance_uuid)
        self.assertTrue(obj_base.obj_equal_prims(spec, db_spec))
        self.assertNotEqual(old_az, db_spec.availability_zone)
コード例 #18
0
 def test_update_from_virt_driver(self):
     # copy in case the update has a side effect
     resources = copy.deepcopy(fake_resources)
     # Emulate the ironic driver which adds a uuid field.
     resources['uuid'] = uuidsentinel.node_uuid
     compute = compute_node.ComputeNode()
     compute.update_from_virt_driver(resources)
     expected = fake_compute_with_resources.obj_clone()
     expected.uuid = uuidsentinel.node_uuid
     self.assertTrue(base.obj_equal_prims(expected, compute))
コード例 #19
0
 def test_update_from_virt_driver_missing_field(self):
     # NOTE(pmurray): update_from_virt_driver does not require
     # all fields to be present in resources. Validation of the
     # resources data structure would be done in a different method.
     resources = copy.deepcopy(fake_resources)
     del resources['vcpus']
     compute = compute_node.ComputeNode()
     compute.update_from_virt_driver(resources)
     expected = fake_compute_with_resources.obj_clone()
     del expected.vcpus
     self.assertTrue(base.obj_equal_prims(expected, compute))
コード例 #20
0
 def test_update_from_virt_driver_missing_field(self):
     # NOTE(pmurray): update_from_virt_driver does not require
     # all fields to be present in resources. Validation of the
     # resources data structure would be done in a different method.
     resources = copy.deepcopy(fake_resources)
     del resources['vcpus']
     compute = compute_node.ComputeNode()
     compute.update_from_virt_driver(resources)
     expected = fake_compute_with_resources.obj_clone()
     del expected.vcpus
     self.assertTrue(base.obj_equal_prims(expected, compute))
コード例 #21
0
ファイル: test_compute_node.py プロジェクト: mahak/nova
 def test_update_from_virt_driver_uuid_already_set(self):
     """Tests update_from_virt_driver where the compute node object already
     has a uuid value so the uuid from the virt driver is ignored.
     """
     # copy in case the update has a side effect
     resources = copy.deepcopy(fake_resources)
     # Emulate the ironic driver which adds a uuid field.
     resources['uuid'] = uuidsentinel.node_uuid
     compute = compute_node.ComputeNode(uuid=uuidsentinel.something_else)
     compute.update_from_virt_driver(resources)
     expected = fake_compute_with_resources.obj_clone()
     expected.uuid = uuidsentinel.something_else
     self.assertTrue(base.obj_equal_prims(expected, compute))
コード例 #22
0
 def test_update_from_virt_driver_uuid_already_set(self):
     """Tests update_from_virt_driver where the compute node object already
     has a uuid value so the uuid from the virt driver is ignored.
     """
     # copy in case the update has a side effect
     resources = copy.deepcopy(fake_resources)
     # Emulate the ironic driver which adds a uuid field.
     resources['uuid'] = uuidsentinel.node_uuid
     compute = compute_node.ComputeNode(uuid=uuidsentinel.something_else)
     compute.update_from_virt_driver(resources)
     expected = fake_compute_with_resources.obj_clone()
     expected.uuid = uuidsentinel.something_else
     self.assertTrue(base.obj_equal_prims(expected, compute))
コード例 #23
0
ファイル: test_floating_ips.py プロジェクト: mahak/nova
    def test_translate_floating_ips_view(self):
        mock_trans = mock.Mock()
        mock_trans.return_value = {'floating_ip': 'foo'}
        self.floating_ips._translate_floating_ip_view = mock_trans
        fip1 = objects.FixedIP(address='192.168.1.2', instance_uuid=FAKE_UUID)
        fip2 = objects.FixedIP(address='192.168.1.3', instance_uuid=FAKE_UUID)

        floaters = [self._build_floating_ip('10.0.0.2', fip1),
                    self._build_floating_ip('10.0.0.3', fip2)]

        result = self.floating_ips._translate_floating_ips_view(floaters)

        called_floaters = [call[0][0] for call in mock_trans.call_args_list]
        self.assertTrue(any(obj_base.obj_equal_prims(floaters[0], f)
                            for f in called_floaters),
                        "_translate_floating_ip_view was not called with all "
                        "floating ips")
        self.assertTrue(any(obj_base.obj_equal_prims(floaters[1], f)
                            for f in called_floaters),
                        "_translate_floating_ip_view was not called with all "
                        "floating ips")
        expected_result = {'floating_ips': ['foo', 'foo']}
        self.assertEqual(expected_result, result)
コード例 #24
0
ファイル: test.py プロジェクト: vmturbo/nova
 def __eq__(self, other):
     return objects_base.obj_equal_prims(other, self.want_obj)
コード例 #25
0
 def test_get_by_uuid(self):
     spec = self._create_spec()
     db_spec = self.spec_obj.get_by_instance_uuid(self.context,
                                                  self.instance_uuid)
     self.assertTrue(obj_base.obj_equal_prims(spec, db_spec))
コード例 #26
0
 def _assert_agg_data(self, expected, actual):
     self.assertTrue(obj_base.obj_equal_prims(expected, actual),
                     "The aggregate objects were not equal")
コード例 #27
0
ファイル: test_instance_group.py プロジェクト: klmitch/nova
 def test_get_by_name(self):
     create_group = self._api_group()
     get_group = objects.InstanceGroup.get_by_name(self.context,
                                                   create_group.name)
     self.assertTrue(base.obj_equal_prims(create_group, get_group))
コード例 #28
0
ファイル: test_instance_group.py プロジェクト: klmitch/nova
 def test_get_by_instance_uuid(self):
     create_group = self._api_group(members=[uuids.instance])
     get_group = objects.InstanceGroup.get_by_instance_uuid(self.context,
                                                            uuids.instance)
     self.assertTrue(base.obj_equal_prims(create_group, get_group))
コード例 #29
0
ファイル: resource_tracker.py プロジェクト: kapiliitr/nova
 def _resource_change(self):
     """Check to see if any resources have changed."""
     if not obj_base.obj_equal_prims(self.compute_node, self.old_resources):
         self.old_resources = copy.deepcopy(self.compute_node)
         return True
     return False
コード例 #30
0
ファイル: test_aggregates.py プロジェクト: Juniper/nova
 def _assert_agg_data(self, expected, actual):
     self.assertTrue(obj_base.obj_equal_prims(expected, actual),
                     "The aggregate objects were not equal")
コード例 #31
0
ファイル: test_request_spec.py プロジェクト: klmitch/nova
 def test_get_by_uuid(self):
     spec = self._create_spec()
     db_spec = self.spec_obj.get_by_instance_uuid(self.context,
             self.instance_uuid)
     self.assertTrue(obj_base.obj_equal_prims(spec, db_spec))
コード例 #32
0
 def test_get_by_instance_uuid(self):
     create_group = self._api_group(members=[uuids.instance])
     get_group = objects.InstanceGroup.get_by_instance_uuid(
         self.context, uuids.instance)
     self.assertTrue(base.obj_equal_prims(create_group, get_group))
コード例 #33
0
 def test_get_by_name(self):
     create_group = self._api_group()
     get_group = objects.InstanceGroup.get_by_name(self.context,
                                                   create_group.name)
     self.assertTrue(base.obj_equal_prims(create_group, get_group))
コード例 #34
0
 def __eq__(self, other):
     return objects_base.obj_equal_prims(other, self.want_obj)
コード例 #35
0
 def _resource_change(self):
     """Check to see if any resources have changed."""
     if not obj_base.obj_equal_prims(self.compute_node, self.old_resources):
         self.old_resources = copy.deepcopy(self.compute_node)
         return True
     return False