예제 #1
0
 def ensure_resource_provider(self, context, uuid, name=None,
                              parent_provider_uuid=None):
     resp = self.get("/resource_providers/%s" % uuid, version='1.6')
     if resp.status_code == 200:
         LOG.info("Resource Provider %(uuid)s already exists",
                  {"uuid": uuid})
     else:
         LOG.info("Creating resource provider %(provider)s",
                  {"provider": name or uuid})
         try:
             resp = self._create_resource_provider(context, uuid, name,
                                                   parent_provider_uuid)
         except Exception:
             raise exception.ResourceProviderCreationFailed(
                 name=name or uuid)
     return uuid
예제 #2
0
    def test_drv_deployable_make_diff(self, mock_create_driver_deployable,
                                      mock_destroy_driver_deployable,
                                      mock_placement_report,
                                      mock_placement_delete):
        old_driver_dep_list = []
        new_driver_dep_list = self.fake_driver_depolyables[:1]
        self.placement_mock.get.return_value.json.return_value = {
            'resource_providers': [{
                'uuid': mock.sentinel.uuid
            }],
        }

        mock_placement_report.side_effect = (
            exception.ResourceProviderCreationFailed(name=uuids.compute_node))

        self.cm.drv_deployable_make_diff(mock.sentinel.context, '1', '2',
                                         old_driver_dep_list,
                                         new_driver_dep_list, 'foo')

        mock_destroy_driver_deployable.assert_called_once()
        mock_placement_delete.assert_called_once()