예제 #1
0
 def test_create_subcloud_duplicate_name(self, value):
     fake_subcloud = utils.create_subcloud_dict(value)
     # name = fake_subcloud['name']
     subcloud = self.create_subcloud(self.ctx, fake_subcloud)
     self.assertIsNotNone(subcloud)
     fake_subcloud2 = utils.create_subcloud_dict(value)
     fake_subcloud2['management-start-ip'] = "2.3.4.6"
     fake_subcloud2['management-end-ip'] = "2.3.4.7"
     self.assertRaises(db_exception.DBDuplicateEntry, self.create_subcloud,
                       self.ctx, fake_subcloud2)
예제 #2
0
    def test_subcloud_status_get_all_by_name(self, value):
        fake_subcloud = utils.create_subcloud_dict(value)
        name = fake_subcloud['name']
        subcloud = self.create_subcloud(self.ctx, fake_subcloud)
        self.assertIsNotNone(subcloud)

        endpoint_type1 = 'testendpoint1'
        subcloud_status1 = self.create_subcloud_status(
            self.ctx, endpoint_type=endpoint_type1)
        self.assertIsNotNone(subcloud_status1)

        endpoint_type2 = 'testendpoint2'
        subcloud_status2 = self.create_subcloud_status(
            self.ctx, endpoint_type=endpoint_type2)
        self.assertIsNotNone(subcloud_status2)

        endpoint_type3 = 'testendpoint3'
        subcloud_status3 = self.create_subcloud_status(
            self.ctx, endpoint_type=endpoint_type3)
        self.assertIsNotNone(subcloud_status3)

        new_subcloud_statuses = db_api.subcloud_status_get_all_by_name(
            self.ctx, name)
        self.assertIsNotNone(new_subcloud_statuses)
        self.assertEqual(3, len(new_subcloud_statuses))
        self.assertEqual(endpoint_type1,
                         new_subcloud_statuses[0].endpoint_type)
        self.assertEqual(1, new_subcloud_statuses[0].id)
        self.assertEqual(endpoint_type2,
                         new_subcloud_statuses[1].endpoint_type)
        self.assertEqual(2, new_subcloud_statuses[1].id)
        self.assertEqual(endpoint_type3,
                         new_subcloud_statuses[2].endpoint_type)
        self.assertEqual(3, new_subcloud_statuses[2].id)
예제 #3
0
    def test_update_subcloud(self, value):
        fake_subcloud = utils.create_subcloud_dict(value)
        # name = fake_subcloud['name']
        subcloud = self.create_subcloud(self.ctx, fake_subcloud)
        self.assertIsNotNone(subcloud)

        management_state = 'testmanagementstate'
        availability_status = 'testavailabilitystatus'
        software_version = 'testversion'
        updated = db_api.subcloud_update(
            self.ctx,
            subcloud.id,
            management_state=management_state,
            availability_status=availability_status,
            software_version=software_version)
        self.assertIsNotNone(updated)
        self.assertEqual(management_state, updated.management_state)
        self.assertEqual(availability_status, updated.availability_status)
        self.assertEqual(software_version, updated.software_version)

        updated_subcloud = db_api.subcloud_get(self.ctx, subcloud.id)
        self.assertEqual(management_state, updated_subcloud.management_state)
        self.assertEqual(availability_status,
                         updated_subcloud.availability_status)
        self.assertEqual(software_version, updated_subcloud.software_version)
예제 #4
0
    def test_subcloud_get_by_name(self, value):
        fake_subcloud = utils.create_subcloud_dict(value)
        name = fake_subcloud['name']
        subcloud = self.create_subcloud(self.ctx, fake_subcloud)
        self.assertIsNotNone(subcloud)

        by_name = db_api.subcloud_get_by_name(self.ctx, name)
        self.assertIsNotNone(by_name)
        self.assertEqual(name, by_name.name)
예제 #5
0
    def test_create_subcloud(self, value):
        fake_subcloud = utils.create_subcloud_dict(value)
        name = fake_subcloud['name']
        subcloud = self.create_subcloud(self.ctx, fake_subcloud)
        self.assertIsNotNone(subcloud)

        new_subcloud = db_api.subcloud_get(self.ctx, subcloud.id)
        self.assertIsNotNone(new_subcloud)
        self.assertEqual(name, new_subcloud.name)
예제 #6
0
    def test_delete_subcloud(self, value):
        fake_subcloud = utils.create_subcloud_dict(value)
        # name = fake_subcloud['name']
        subcloud = self.create_subcloud(self.ctx, fake_subcloud)
        self.assertIsNotNone(subcloud)

        db_api.subcloud_destroy(self.ctx, subcloud.id)

        self.assertRaises(exceptions.SubcloudNotFound, db_api.subcloud_get,
                          self.ctx, subcloud.id)
예제 #7
0
    def test_subcloud_status_get_all_by_non_existing_name(self, value):
        fake_subcloud = utils.create_subcloud_dict(value)
        # name = fake_subcloud['name']
        subcloud = self.create_subcloud(self.ctx, fake_subcloud)
        self.assertIsNotNone(subcloud)

        endpoint_type1 = 'testendpoint1'
        subcloud_status1 = self.create_subcloud_status(
            self.ctx, endpoint_type=endpoint_type1)
        self.assertIsNotNone(subcloud_status1)

        new_subcloud_statuses = db_api.subcloud_status_get_all_by_name(
            self.ctx, 'thisnameisnotknown')
        self.assertEqual([], new_subcloud_statuses)
예제 #8
0
    def test_delete_subcloud_status(self, value):
        fake_subcloud = utils.create_subcloud_dict(value)
        # name = fake_subcloud['name']
        subcloud = self.create_subcloud(self.ctx, fake_subcloud)
        self.assertIsNotNone(subcloud)

        endpoint_type = 'testendpoint'
        subcloud_status = self.create_subcloud_status(
            self.ctx, endpoint_type=endpoint_type)
        self.assertIsNotNone(subcloud_status)

        db_api.subcloud_status_destroy_all(self.ctx, subcloud.id)
        self.assertRaises(exceptions.SubcloudStatusNotFound,
                          db_api.subcloud_status_get, self.ctx, subcloud.id,
                          endpoint_type)
 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()
예제 #10
0
    def test_create_subcloud_status(self, value):
        fake_subcloud = utils.create_subcloud_dict(value)
        # name = fake_subcloud['name']
        subcloud = self.create_subcloud(self.ctx, fake_subcloud)
        self.assertIsNotNone(subcloud)

        endpoint_type = 'testendpoint'
        subcloud_status = self.create_subcloud_status(
            self.ctx, endpoint_type=endpoint_type)
        self.assertIsNotNone(subcloud_status)

        new_subcloud_status = db_api.subcloud_status_get(
            self.ctx, subcloud.id, endpoint_type)
        self.assertIsNotNone(new_subcloud_status)
        self.assertEqual(endpoint_type, new_subcloud_status.endpoint_type)
        self.assertEqual(consts.SYNC_STATUS_UNKNOWN,
                         new_subcloud_status.sync_status)
 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()
예제 #13
0
    def test_update_subcloud_status(self, value):
        fake_subcloud = utils.create_subcloud_dict(value)
        # name = fake_subcloud['name']
        subcloud = self.create_subcloud(self.ctx, fake_subcloud)
        self.assertIsNotNone(subcloud)

        endpoint_type = 'testendpoint'
        subcloud_status = self.create_subcloud_status(
            self.ctx, endpoint_type=endpoint_type)
        self.assertIsNotNone(subcloud_status)

        sync_status = consts.SYNC_STATUS_IN_SYNC
        updated = db_api.subcloud_status_update(self.ctx,
                                                subcloud.id,
                                                endpoint_type=endpoint_type,
                                                sync_status=sync_status)
        self.assertIsNotNone(updated)
        self.assertEqual(sync_status, updated.sync_status)

        updated_subcloud_status = db_api.subcloud_status_get(
            self.ctx, subcloud.id, endpoint_type)
        self.assertIsNotNone(updated_subcloud_status)
        self.assertEqual(endpoint_type, updated_subcloud_status.endpoint_type)
        self.assertEqual(sync_status, updated_subcloud_status.sync_status)