Example #1
0
 def test_init(self, mock_context, mock_endpoint, mock_dcorch_rpc_client):
     mock_context.get_admin_context.return_value = self.ctxt
     am = subcloud_manager.SubcloudManager()
     self.assertIsNotNone(am)
     self.assertEqual('subcloud_manager', am.service_name)
     self.assertEqual('localhost', am.host)
     self.assertEqual(self.ctxt, am.context)
Example #2
0
    def test_init(self, mock_context, mock_keystone_client,
                  mock_sysinv_client):
        mock_context.get_admin_context.return_value = self.ctxt

        sm = subcloud_manager.SubcloudManager()
        am = subcloud_audit_manager.SubcloudAuditManager(subcloud_manager=sm)
        self.assertIsNotNone(am)
        self.assertEqual('subcloud_audit_manager', am.service_name)
        self.assertEqual('localhost', am.host)
        self.assertEqual(self.ctxt, am.context)
Example #3
0
 def test_add_subcloud(self, mock_create_addn_hosts, mock_sysinv_client,
                       mock_db_api, mock_endpoint, mock_context,
                       mock_dcorch_rpc_client):
     controllers = [Controller('controller-0'), Controller('controller-1')]
     mock_context.get_admin_context.return_value = self.ctxt
     mock_db_api.subcloud_get_by_name.side_effect = \
         exceptions.SubcloudNameNotFound()
     mock_sysinv_client().get_controller_hosts.return_value = controllers
     sm = subcloud_manager.SubcloudManager()
     sm.add_subcloud(self.ctxt, payload=FAKE_SUBCLOUD_DATA)
     mock_db_api.subcloud_create.assert_called_once()
     mock_db_api.subcloud_status_create.assert_called()
     mock_sysinv_client().create_route.assert_called()
     mock_dcorch_rpc_client().add_subcloud.assert_called_once()
     mock_create_addn_hosts.assert_called_once()
 def test_delete_subcloud(self, value, mock_create_addn_hosts,
                          mock_keystone_client, mock_sysinv_client,
                          mock_db_api, mock_context,
                          mock_dcorch_rpc_client):
     controllers = [Controller('controller-0'), Controller('controller-1')]
     mock_context.get_admin_context.return_value = self.ctxt
     data = utils.create_subcloud_dict(value)
     fake_subcloud = Subcloud(data, False)
     mock_db_api.subcloud_get.return_value = fake_subcloud
     mock_sysinv_client().get_controller_hosts.return_value = controllers
     sm = subcloud_manager.SubcloudManager()
     sm.delete_subcloud(self.ctxt, subcloud_id=data['id'])
     mock_sysinv_client().delete_route.assert_called()
     mock_keystone_client().delete_region.assert_called_once()
     mock_db_api.subcloud_destroy.assert_called_once()
     mock_create_addn_hosts.assert_called_once()
Example #5
0
 def test_update_subcloud(self, mock_db_api, mock_endpoint, mock_context,
                          mock_dcorch_rpc_client):
     mock_context.get_admin_context.return_value = self.ctxt
     data = FAKE_SUBCLOUD_DATA
     subcloud_result = Subcloud(FAKE_ID, data, True)
     mock_db_api.subcloud_get.return_value = subcloud_result
     mock_db_api.subcloud_update.return_value = subcloud_result
     sm = subcloud_manager.SubcloudManager()
     sm.update_subcloud(self.ctxt, FAKE_ID,
                        management_state=consts.MANAGEMENT_MANAGED,
                        description="subcloud1 description",
                        location="subcloud1 location")
     mock_db_api.subcloud_update.assert_called_once_with(
         mock.ANY,
         FAKE_ID,
         management_state=consts.MANAGEMENT_MANAGED,
         description="subcloud1 description",
         location="subcloud1 location")
Example #6
0
 def test_delete_subcloud(self, mock_create_addn_hosts,
                          mock_keystone_client,
                          mock_sysinv_client,
                          mock_db_api,
                          mock_endpoint, mock_context,
                          mock_dcorch_rpc_client):
     controllers = [Controller('controller-0'), Controller('controller-1')]
     mock_context.get_admin_context.return_value = self.ctxt
     fake_subcloud = Subcloud(FAKE_ID, FAKE_SUBCLOUD_DATA, False)
     mock_db_api.subcloud_get.return_value = fake_subcloud
     mock_sysinv_client().get_controller_hosts.return_value = controllers
     sm = subcloud_manager.SubcloudManager()
     sm.delete_subcloud(self.ctxt, subcloud_id=FAKE_ID)
     mock_sysinv_client().delete_route.assert_called()
     mock_keystone_client().delete_region.assert_called_once()
     mock_keystone_client().delete_endpoints.assert_called_once()
     mock_db_api.subcloud_destroy.assert_called_once()
     mock_create_addn_hosts.assert_called_once()
 def test_update_subcloud(self, value, mock_db_api, mock_endpoint,
                          mock_context, mock_dcorch_rpc_client):
     mock_context.get_admin_context.return_value = self.ctxt
     data = utils.create_subcloud_dict(value)
     subcloud_result = Subcloud(data, True)
     mock_db_api.subcloud_get.return_value = subcloud_result
     mock_db_api.subcloud_update.return_value = subcloud_result
     sm = subcloud_manager.SubcloudManager()
     sm.update_subcloud(self.ctxt,
                        data['id'],
                        management_state=consts.MANAGEMENT_MANAGED,
                        description="subcloud new description",
                        location="subcloud new location")
     mock_db_api.subcloud_update.assert_called_once_with(
         mock.ANY,
         data['id'],
         management_state=consts.MANAGEMENT_MANAGED,
         description="subcloud new description",
         location="subcloud new location")
    def test_add_subcloud(self, value, mock_create_addn_hosts,
                          mock_sysinv_client, mock_db_api,
                          mock_keystone_client, mock_context,
                          mock_dcorch_rpc_client):
        value = utils.create_subcloud_dict(value)
        controllers = [Controller('controller-0'), Controller('controller-1')]
        services = [Service('identity', '1234')]
        mock_context.get_admin_context.return_value = self.ctxt
        mock_db_api.subcloud_get_by_name.side_effect = \
            exceptions.SubcloudNameNotFound()

        mock_sysinv_client().get_controller_hosts.return_value = controllers
        mock_keystone_client().services_list = services

        sm = subcloud_manager.SubcloudManager()
        sm.add_subcloud(self.ctxt, payload=value)
        mock_db_api.subcloud_create.assert_called_once()
        mock_db_api.subcloud_status_create.assert_called()
        mock_sysinv_client().create_route.assert_called()
        mock_dcorch_rpc_client().add_subcloud.assert_called_once()
        mock_create_addn_hosts.assert_called_once()