Exemple #1
0
 def test_delete_multiple_baymodel_by_name(self):
     obj_utils.create_test_baymodel(self.context, name="test_baymodel", uuid=utils.generate_uuid())
     obj_utils.create_test_baymodel(self.context, name="test_baymodel", uuid=utils.generate_uuid())
     response = self.delete("/baymodels/test_baymodel", expect_errors=True)
     self.assertEqual(409, response.status_int)
     self.assertEqual("application/json", response.content_type)
     self.assertTrue(response.json["error_message"])
Exemple #2
0
    def test_collection_links(self):
        for id_ in range(5):
            obj_utils.create_test_baymodel(self.context, id=id_, uuid=utils.generate_uuid())
        response = self.get_json("/baymodels/?limit=3")
        self.assertEqual(3, len(response["baymodels"]))

        next_marker = response["baymodels"][-1]["uuid"]
        self.assertIn(next_marker, response["next"])
Exemple #3
0
    def test_collection_links_default_limit(self):
        cfg.CONF.set_override("max_limit", 3, "api")
        for id_ in range(5):
            obj_utils.create_test_baymodel(self.context, id=id_, uuid=utils.generate_uuid())
        response = self.get_json("/baymodels")
        self.assertEqual(3, len(response["baymodels"]))

        next_marker = response["baymodels"][-1]["uuid"]
        self.assertIn(next_marker, response["next"])
Exemple #4
0
    def test_collection_links(self):
        for id_ in range(5):
            obj_utils.create_test_baymodel(self.context, id=id_,
                                           uuid=uuidutils.generate_uuid())
        response = self.get_json('/baymodels/?limit=3')
        self.assertEqual(3, len(response['baymodels']))

        next_marker = response['baymodels'][-1]['uuid']
        self.assertIn(next_marker, response['next'])
Exemple #5
0
 def test_delete_multiple_baymodel_by_name(self):
     obj_utils.create_test_baymodel(self.context, name='test_baymodel',
                                    uuid=utils.generate_uuid())
     obj_utils.create_test_baymodel(self.context, name='test_baymodel',
                                    uuid=utils.generate_uuid())
     response = self.delete('/baymodels/test_baymodel', expect_errors=True)
     self.assertEqual(409, response.status_int)
     self.assertEqual('application/json', response.content_type)
     self.assertTrue(response.json['errors'])
Exemple #6
0
    def test_collection_links_default_limit(self):
        cfg.CONF.set_override('max_limit', 3, 'api')
        for id_ in range(5):
            obj_utils.create_test_baymodel(self.context, id=id_,
                                           uuid=utils.generate_uuid())
        response = self.get_json('/baymodels')
        self.assertEqual(3, len(response['baymodels']))

        next_marker = response['baymodels'][-1]['uuid']
        self.assertIn(next_marker, response['next'])
Exemple #7
0
 def test_links(self):
     uuid = utils.generate_uuid()
     obj_utils.create_test_baymodel(self.context, id=1, uuid=uuid)
     response = self.get_json('/baymodels/%s' % uuid)
     self.assertIn('links', response.keys())
     self.assertEqual(2, len(response['links']))
     self.assertIn(uuid, response['links'][0]['href'])
     for l in response['links']:
         bookmark = l['rel'] == 'bookmark'
         self.assertTrue(self.validate_link(l['href'], bookmark=bookmark))
Exemple #8
0
 def test_links(self):
     uuid = utils.generate_uuid()
     obj_utils.create_test_baymodel(self.context, id=1, uuid=uuid)
     response = self.get_json("/baymodels/%s" % uuid)
     self.assertIn("links", response.keys())
     self.assertEqual(2, len(response["links"]))
     self.assertIn(uuid, response["links"][0]["href"])
     for l in response["links"]:
         bookmark = l["rel"] == "bookmark"
         self.assertTrue(self.validate_link(l["href"], bookmark=bookmark))
Exemple #9
0
    def test_detail_with_pagination_marker(self):
        bm_list = []
        for id_ in range(4):
            baymodel = obj_utils.create_test_baymodel(self.context, id=id_, uuid=utils.generate_uuid())
            bm_list.append(baymodel)

        response = self.get_json("/baymodels/detail?limit=3&marker=%s" % bm_list[2].uuid)
        self.assertEqual(1, len(response["baymodels"]))
        self.assertEqual(bm_list[-1].uuid, response["baymodels"][0]["uuid"])
        for key in (
            "flavor_id",
            "master_flavor_id",
            "dns_nameserver",
            "keypair_id",
            "external_network_id",
            "fixed_network",
            "docker_volume_size",
            "ssh_authorized_key",
            "coe",
        ):
            self.assertIn(key, response["baymodels"][0])
            self.assertIn("flavor_id", response["baymodels"][0])
            self.assertIn("master_flavor_id", response["baymodels"][0])
            self.assertIn("dns_nameserver", response["baymodels"][0])
            self.assertIn("keypair_id", response["baymodels"][0])
            self.assertIn("external_network_id", response["baymodels"][0])
            self.assertIn("fixed_network", response["baymodels"][0])
            self.assertIn("docker_volume_size", response["baymodels"][0])
            self.assertIn("ssh_authorized_key", response["baymodels"][0])
            self.assertIn("coe", response["baymodels"][0])
            self.assertIn("http_proxy", response["baymodels"][0])
            self.assertIn("https_proxy", response["baymodels"][0])
            self.assertIn("no_proxy", response["baymodels"][0])
Exemple #10
0
 def setUp(self):
     super(TestPost, self).setUp()
     self.baymodel = obj_utils.create_test_baymodel(self.context)
     p = mock.patch.object(rpcapi.API, 'bay_create')
     self.mock_bay_create = p.start()
     self.mock_bay_create.side_effect = self._simulate_rpc_bay_create
     self.addCleanup(p.stop)
Exemple #11
0
    def test_remove_singular(self):
        baymodel = obj_utils.create_test_baymodel(self.context,
                                                  uuid=utils.generate_uuid())
        response = self.get_json('/baymodels/%s' % baymodel.uuid)
        self.assertIsNotNone(response['image_id'])

        response = self.patch_json('/baymodels/%s' % baymodel.uuid,
                                   [{'path': '/image_id', 'op': 'remove'}])
        self.assertEqual('application/json', response.content_type)
        self.assertEqual(200, response.status_code)

        response = self.get_json('/baymodels/%s' % baymodel.uuid)
        self.assertIsNone(response['image_id'])
        # Assert nothing else was changed
        self.assertEqual(baymodel.uuid, response['uuid'])
        self.assertEqual(baymodel.name, response['name'])
        self.assertEqual(baymodel.apiserver_port, response['apiserver_port'])
        self.assertEqual(self.baymodel.fixed_network,
                         response['fixed_network'])
        self.assertEqual(self.baymodel.docker_volume_size,
                         response['docker_volume_size'])
        self.assertEqual(self.baymodel.ssh_authorized_key,
                         response['ssh_authorized_key'])
        self.assertEqual(self.baymodel.coe,
                         response['coe'])
Exemple #12
0
 def test_delete_baymodel(self):
     baymodel = obj_utils.create_test_baymodel(self.context)
     self.delete("/baymodels/%s" % baymodel.uuid)
     response = self.get_json("/baymodels/%s" % baymodel.uuid, expect_errors=True)
     self.assertEqual(404, response.status_int)
     self.assertEqual("application/json", response.content_type)
     self.assertTrue(response.json["error_message"])
Exemple #13
0
    def test_remove_singular(self):
        baymodel = obj_utils.create_test_baymodel(self.context,
                                                  uuid=utils.generate_uuid())
        response = self.get_json('/baymodels/%s' % baymodel.uuid)
        self.assertIsNotNone(response['dns_nameserver'])

        response = self.patch_json('/baymodels/%s' % baymodel.uuid,
                                   [{'path': '/dns_nameserver',
                                     'op': 'remove'}])
        self.assertEqual('application/json', response.content_type)
        self.assertEqual(200, response.status_code)

        response = self.get_json('/baymodels/%s' % baymodel.uuid)
        self.assertIsNone(response['dns_nameserver'])
        # Assert nothing else was changed
        self.assertEqual(baymodel.uuid, response['uuid'])
        self.assertEqual(baymodel.name, response['name'])
        self.assertEqual(baymodel.apiserver_port, response['apiserver_port'])
        self.assertEqual(baymodel.image_id,
                         response['image_id'])
        self.assertEqual(baymodel.fixed_network,
                         response['fixed_network'])
        self.assertEqual(baymodel.network_driver,
                         response['network_driver'])
        self.assertEqual(baymodel.volume_driver,
                         response['volume_driver'])
        self.assertEqual(baymodel.docker_volume_size,
                         response['docker_volume_size'])
        self.assertEqual(baymodel.coe, response['coe'])
        self.assertEqual(baymodel.http_proxy, response['http_proxy'])
        self.assertEqual(baymodel.https_proxy, response['https_proxy'])
        self.assertEqual(baymodel.no_proxy, response['no_proxy'])
        self.assertEqual(baymodel.labels, response['labels'])
Exemple #14
0
    def test_detail_with_pagination_marker(self):
        bm_list = []
        for id_ in range(4):
            baymodel = obj_utils.create_test_baymodel(
                self.context, id=id_,
                uuid=utils.generate_uuid())
            bm_list.append(baymodel)

        response = self.get_json('/baymodels/detail?limit=3&marker=%s'
                                 % bm_list[2].uuid)
        self.assertEqual(1, len(response['baymodels']))
        self.assertEqual(bm_list[-1].uuid, response['baymodels'][0]['uuid'])
        for key in ("flavor_id", "master_flavor_id", "dns_nameserver",
                    "keypair_id", "external_network_id", "fixed_network",
                    "network_driver", "docker_volume_size", "labels",
                    "ssh_authorized_key", "coe"):
            self.assertIn(key, response['baymodels'][0])
            self.assertIn('flavor_id', response['baymodels'][0])
            self.assertIn('master_flavor_id', response['baymodels'][0])
            self.assertIn('dns_nameserver', response['baymodels'][0])
            self.assertIn('keypair_id', response['baymodels'][0])
            self.assertIn('external_network_id', response['baymodels'][0])
            self.assertIn('fixed_network', response['baymodels'][0])
            self.assertIn('docker_volume_size', response['baymodels'][0])
            self.assertIn('ssh_authorized_key', response['baymodels'][0])
            self.assertIn('coe', response['baymodels'][0])
            self.assertIn('http_proxy', response['baymodels'][0])
            self.assertIn('https_proxy', response['baymodels'][0])
            self.assertIn('no_proxy', response['baymodels'][0])
Exemple #15
0
    def test_remove_singular(self):
        baymodel = obj_utils.create_test_baymodel(self.context, uuid=utils.generate_uuid())
        response = self.get_json("/baymodels/%s" % baymodel.uuid)
        self.assertIsNotNone(response["dns_nameserver"])

        response = self.patch_json("/baymodels/%s" % baymodel.uuid, [{"path": "/dns_nameserver", "op": "remove"}])
        self.assertEqual("application/json", response.content_type)
        self.assertEqual(200, response.status_code)

        response = self.get_json("/baymodels/%s" % baymodel.uuid)
        self.assertIsNone(response["dns_nameserver"])
        # Assert nothing else was changed
        self.assertEqual(baymodel.uuid, response["uuid"])
        self.assertEqual(baymodel.name, response["name"])
        self.assertEqual(baymodel.apiserver_port, response["apiserver_port"])
        self.assertEqual(baymodel.image_id, response["image_id"])
        self.assertEqual(baymodel.fixed_network, response["fixed_network"])
        self.assertEqual(baymodel.network_driver, response["network_driver"])
        self.assertEqual(baymodel.docker_volume_size, response["docker_volume_size"])
        self.assertEqual(baymodel.ssh_authorized_key, response["ssh_authorized_key"])
        self.assertEqual(baymodel.coe, response["coe"])
        self.assertEqual(baymodel.http_proxy, response["http_proxy"])
        self.assertEqual(baymodel.https_proxy, response["https_proxy"])
        self.assertEqual(baymodel.no_proxy, response["no_proxy"])
        self.assertEqual(baymodel.labels, response["labels"])
Exemple #16
0
 def test_policy_only_owner_update(self):
     baymodel = obj_utils.create_test_baymodel(self.context,
                                               user_id='another')
     self._owner_check(
         "baymodel:update", self.patch_json,
         '/baymodels/%s' % baymodel.uuid,
         [{'path': '/name', 'value': "new_name", 'op': 'replace'}],
         expect_errors=True)
Exemple #17
0
 def setUp(self):
     super(TestPatch, self).setUp()
     self.baymodel = obj_utils.create_test_baymodel(self.context)
     self.bay = obj_utils.create_test_bay(self.context, name="bay_example_A", node_count=3)
     p = mock.patch.object(rpcapi.API, "bay_update")
     self.mock_bay_update = p.start()
     self.mock_bay_update.side_effect = self._simulate_rpc_bay_update
     self.addCleanup(p.stop)
Exemple #18
0
 def test_delete_baymodel(self):
     baymodel = obj_utils.create_test_baymodel(self.context)
     self.delete('/baymodels/%s' % baymodel.uuid)
     response = self.get_json('/baymodels/%s' % baymodel.uuid,
                              expect_errors=True)
     self.assertEqual(404, response.status_int)
     self.assertEqual('application/json', response.content_type)
     self.assertTrue(response.json['errors'])
Exemple #19
0
 def test_create_bay_with_no_lb_multi_node(self):
     baymodel = obj_utils.create_test_baymodel(
         self.context, name='foo', uuid='foo', master_lb_enabled=False)
     bdict = apiutils.bay_post_data(baymodel_id=baymodel.name,
                                    master_count=3)
     response = self.post_json('/bays', bdict, expect_errors=True)
     self.assertEqual('application/json', response.content_type)
     self.assertEqual(400, response.status_int)
Exemple #20
0
 def test_policy_disallow_update(self):
     baymodel = obj_utils.create_test_baymodel(self.context,
                                               name='example_A',
                                               uuid="333-444-5555")
     self._common_policy_check(
         "baymodel:update", self.patch_json,
         '/baymodels/%s' % baymodel.name,
         [{'name': '/name', 'value': "new_name", 'op': 'replace'}])
Exemple #21
0
 def test_detail(self):
     baymodel = obj_utils.create_test_baymodel(self.context)
     response = self.get_json('/baymodels/detail')
     self.assertEqual(baymodel.uuid, response['baymodels'][0]["uuid"])
     for key in ("flavor_id", "master_flavor_id", "dns_nameserver",
                 "keypair_id", "external_network_id", "fixed_network",
                 "docker_volume_size", "ssh_authorized_key", "coe"):
         self.assertIn(key, response['baymodels'][0])
Exemple #22
0
 def test_policy_disallow_update(self):
     baymodel = obj_utils.create_test_baymodel(self.context, name="example_A", uuid="333-444-5555")
     self._common_policy_check(
         "baymodel:update",
         self.patch_json,
         "/baymodels/%s" % baymodel.name,
         [{"name": "/name", "value": "new_name", "op": "replace"}],
     )
Exemple #23
0
 def test_delete_baymodel_with_bay(self):
     baymodel = obj_utils.create_test_baymodel(self.context)
     obj_utils.create_test_bay(self.context, baymodel_id=baymodel.uuid)
     response = self.delete('/baymodels/%s' % baymodel.uuid,
                            expect_errors=True)
     self.assertEqual(400, response.status_int)
     self.assertEqual('application/json', response.content_type)
     self.assertTrue(response.json['error_message'])
     self.assertIn(baymodel.uuid, response.json['error_message'])
Exemple #24
0
 def test_policy_disallow_update(self):
     baymodel = obj_utils.create_test_baymodel(self.context, name="example_A", uuid=utils.generate_uuid())
     self._common_policy_check(
         "baymodel:update",
         self.patch_json,
         "/baymodels/%s" % baymodel.name,
         [{"path": "/name", "value": "new_name", "op": "replace"}],
         expect_errors=True,
     )
Exemple #25
0
    def test_get_all_with_pagination_marker(self):
        bm_list = []
        for id_ in range(4):
            baymodel = obj_utils.create_test_baymodel(self.context, id=id_, uuid=utils.generate_uuid())
            bm_list.append(baymodel)

        response = self.get_json("/baymodels?limit=3&marker=%s" % bm_list[2].uuid)
        self.assertEqual(1, len(response["baymodels"]))
        self.assertEqual(bm_list[-1].uuid, response["baymodels"][0]["uuid"])
Exemple #26
0
 def test_many(self):
     bm_list = []
     for id_ in range(5):
         baymodel = obj_utils.create_test_baymodel(self.context, id=id_, uuid=utils.generate_uuid())
         bm_list.append(baymodel.uuid)
     response = self.get_json("/baymodels")
     self.assertEqual(len(bm_list), len(response["baymodels"]))
     uuids = [bm["uuid"] for bm in response["baymodels"]]
     self.assertEqual(sorted(bm_list), sorted(uuids))
Exemple #27
0
 def test_update_baymodel_with_bay_not_allow_update(self):
     baymodel = obj_utils.create_test_baymodel(self.context)
     obj_utils.create_test_bay(self.context, baymodel_id=baymodel.uuid)
     response = self.patch_json('/baymodels/%s' % baymodel.uuid,
                                [{'path': '/name',
                                  'value': 'new_name',
                                  'op': 'replace'}],
                                expect_errors=True)
     self.assertEqual(400, response.status_code)
Exemple #28
0
 def test_policy_disallow_update(self):
     baymodel = obj_utils.create_test_baymodel(self.context,
                                               name='example_A',
                                               uuid=utils.generate_uuid())
     self._common_policy_check(
         "baymodel:update", self.patch_json,
         '/baymodels/%s' % baymodel.name,
         [{'path': '/name', 'value': "new_name", 'op': 'replace'}],
         expect_errors=True)
Exemple #29
0
 def test_replace_baymodel_id(self):
     baymodel = obj_utils.create_test_baymodel(self.context, uuid=utils.generate_uuid())
     response = self.patch_json(
         "/bays/%s" % self.bay.uuid,
         [{"path": "/baymodel_id", "value": baymodel.uuid, "op": "replace"}],
         expect_errors=True,
     )
     self.assertEqual("application/json", response.content_type)
     self.assertEqual(200, response.status_code)
Exemple #30
0
 def setUp(self):
     super(TestPost, self).setUp()
     self.baymodel = obj_utils.create_test_baymodel(self.context)
     p = mock.patch.object(rpcapi.API, 'bay_create')
     self.mock_bay_create = p.start()
     self.mock_bay_create.side_effect = self._simulate_rpc_bay_create
     self.addCleanup(p.stop)
     p = mock.patch.object(attr_validator, 'validate_os_resources')
     self.mock_valid_os_res = p.start()
     self.addCleanup(p.stop)
Exemple #31
0
 def test_replace_baymodel_id(self):
     baymodel = obj_utils.create_test_baymodel(self.context,
                                               uuid=utils.generate_uuid())
     response = self.patch_json('/bays/%s' % self.bay.uuid,
                                [{'path': '/baymodel_id',
                                  'value': baymodel.uuid,
                                  'op': 'replace'}],
                                expect_errors=True)
     self.assertEqual('application/json', response.content_type)
     self.assertEqual(200, response.status_code)
Exemple #32
0
 def test_many(self):
     bm_list = []
     for id_ in range(5):
         baymodel = obj_utils.create_test_baymodel(
             self.context, id=id_, uuid=utils.generate_uuid())
         bm_list.append(baymodel.uuid)
     response = self.get_json('/baymodels')
     self.assertEqual(len(bm_list), len(response['baymodels']))
     uuids = [bm['uuid'] for bm in response['baymodels']]
     self.assertEqual(sorted(bm_list), sorted(uuids))
Exemple #33
0
 def test_replace_baymodel_id(self):
     baymodel = obj_utils.create_test_baymodel(self.context,
                                               uuid=utils.generate_uuid())
     response = self.patch_json('/bays/%s' % self.bay.uuid,
                                [{'path': '/baymodel_id',
                                  'value': baymodel.uuid,
                                  'op': 'replace'}],
                                expect_errors=True)
     self.assertEqual('application/json', response.content_type)
     self.assertEqual(200, response.status_code)
Exemple #34
0
 def setUp(self):
     super(TestPatch, self).setUp()
     self.baymodel = obj_utils.create_test_baymodel(self.context)
     self.bay = obj_utils.create_test_bay(self.context,
                                          name='bay_example_A',
                                          node_count=3)
     p = mock.patch.object(rpcapi.API, 'bay_update')
     self.mock_bay_update = p.start()
     self.mock_bay_update.side_effect = self._simulate_rpc_bay_update
     self.addCleanup(p.stop)
Exemple #35
0
 def test_create_bay_with_no_lb_multi_node(self):
     baymodel = obj_utils.create_test_baymodel(self.context,
                                               name='foo',
                                               uuid='foo',
                                               master_lb_enabled=False)
     bdict = apiutils.bay_post_data(baymodel_id=baymodel.name,
                                    master_count=3)
     response = self.post_json('/bays', bdict, expect_errors=True)
     self.assertEqual('application/json', response.content_type)
     self.assertEqual(400, response.status_int)
Exemple #36
0
 def test_get_one_by_name(self):
     baymodel = obj_utils.create_test_baymodel(self.context)
     response = self.get_json('/baymodels/%s' % baymodel['name'])
     self.assertEqual(baymodel.uuid, response['uuid'])
     self.assertIn('flavor_id', response)
     self.assertIn('master_flavor_id', response)
     self.assertIn('dns_nameserver', response)
     self.assertIn('keypair_id', response)
     self.assertIn('external_network_id', response)
     self.assertIn('fixed_network', response)
     self.assertIn('docker_volume_size', response)
Exemple #37
0
    def test_one(self):
        baymodel = obj_utils.create_test_baymodel(self.context)
        response = self.get_json('/baymodels')
        self.assertEqual(baymodel.uuid, response['baymodels'][0]["uuid"])
        self._verify_attrs(self._baymodel_attrs, response['baymodels'][0])

        # Verify attrs that should not appear from response
        none_attrs = (set(self._expand_baymodel_attrs) -
                      set(self._baymodel_attrs))
        self._verify_attrs(none_attrs, response['baymodels'][0],
                           positive=False)
Exemple #38
0
 def test_policy_disallow_update(self):
     baymodel = obj_utils.create_test_baymodel(self.context,
                                               name='example_A',
                                               uuid="333-444-5555")
     self._common_policy_check("baymodel:update", self.patch_json,
                               '/baymodels/%s' % baymodel.name,
                               [{
                                   'name': '/name',
                                   'value': "new_name",
                                   'op': 'replace'
                               }])
Exemple #39
0
 def test_update_baymodel_with_bay_allow_update(self):
     baymodel = obj_utils.create_test_baymodel(self.context)
     obj_utils.create_test_bay(self.context, baymodel_id=baymodel.uuid)
     response = self.patch_json('/baymodels/%s' % baymodel.uuid,
                                [{'path': '/public',
                                  'value': True,
                                  'op': 'replace'}],
                                expect_errors=True)
     self.assertEqual(200, response.status_int)
     response = self.get_json('/baymodels/%s' % self.baymodel.uuid)
     self.assertEqual(response['public'], True)
Exemple #40
0
    def test_get_all_with_pagination_marker(self):
        bm_list = []
        for id_ in range(4):
            baymodel = obj_utils.create_test_baymodel(
                self.context, id=id_, uuid=utils.generate_uuid())
            bm_list.append(baymodel)

        response = self.get_json('/baymodels?limit=3&marker=%s' %
                                 bm_list[2].uuid)
        self.assertEqual(1, len(response['baymodels']))
        self.assertEqual(bm_list[-1].uuid, response['baymodels'][0]['uuid'])
Exemple #41
0
 def test_one(self):
     baymodel = obj_utils.create_test_baymodel(self.context)
     response = self.get_json('/baymodels')
     self.assertEqual(baymodel.uuid, response['baymodels'][0]["uuid"])
     self.assertNotIn('flavor_id', response['baymodels'][0])
     self.assertNotIn('master_flavor_id', response['baymodels'][0])
     self.assertNotIn('dns_nameserver', response['baymodels'][0])
     self.assertNotIn('keypair_id', response['baymodels'][0])
     self.assertNotIn('external_network_id', response['baymodels'][0])
     self.assertNotIn('fixed_network', response['baymodels'][0])
     self.assertNotIn('docker_volume_size', response['baymodels'][0])
     self.assertNotIn('ssh_authorized_key', response['baymodels'][0])
Exemple #42
0
    def test_policy_disallow_create(self):
        baymodel = obj_utils.create_test_baymodel(self.context)
        bay = obj_utils.create_test_bay(self.context,
                                        baymodel_id=baymodel.uuid)
        params = ('{"name": "My Docker", "image": "ubuntu",'
                  '"command": "env", "memory": "512m",'
                  '"bay_uuid": "%s"}' % bay.uuid)

        self._common_policy_check(
            'container:create', self.app.post, '/v1/containers', params=params,
            content_type='application/json',
            expect_errors=True)
Exemple #43
0
    def test_update_baymodel_with_bay(self):
        baymodel = obj_utils.create_test_baymodel(self.context)
        obj_utils.create_test_bay(self.context, baymodel_id=baymodel.uuid)

        response = self.patch_json('/baymodels/%s' % baymodel.uuid,
                                   [{'path': '/name',
                                     'value': 'bay_model_example_B',
                                     'op': 'replace'}],
                                   expect_errors=True)
        self.assertEqual(400, response.status_int)
        self.assertEqual('application/json', response.content_type)
        self.assertTrue(response.json['errors'])
        self.assertIn(baymodel.uuid, response.json['errors'][0]['detail'])
Exemple #44
0
 def test_policy_disallow_update(self):
     baymodel = obj_utils.create_test_baymodel(self.context,
                                               name='example_A',
                                               uuid=utils.generate_uuid())
     self._common_policy_check("baymodel:update",
                               self.patch_json,
                               '/baymodels/%s' % baymodel.name,
                               [{
                                   'path': '/name',
                                   'value': "new_name",
                                   'op': 'replace'
                               }],
                               expect_errors=True)
Exemple #45
0
    def test_detail_with_pagination_marker(self):
        bm_list = []
        for id_ in range(4):
            baymodel = obj_utils.create_test_baymodel(
                self.context, id=id_, uuid=utils.generate_uuid())
            bm_list.append(baymodel)

        response = self.get_json('/baymodels/detail?limit=3&marker=%s' %
                                 bm_list[2].uuid)
        self.assertEqual(1, len(response['baymodels']))
        self.assertEqual(bm_list[-1].uuid, response['baymodels'][0]['uuid'])
        for key in ("flavor_id", "master_flavor_id", "dns_nameserver",
                    "keypair_id", "external_network_id", "fixed_network",
                    "docker_volume_size", "ssh_authorized_key", "coe"):
            self.assertIn(key, response['baymodels'][0])
Exemple #46
0
 def setUp(self):
     super(TestPatch, self).setUp()
     self.baymodel = obj_utils.create_test_baymodel(
         self.context,
         name='bay_model_example_A',
         image_id='nerdherd',
         apiserver_port=8080,
         fixed_network='private',
         docker_volume_size=20,
         ssh_authorized_key='ssh-rsa AAAAB3NzaC1ycEAAAADA'
         'v0XRqg3tm+jlsOKGO81lPDH+KaSJ'
         'Q7wvmjUqszP/H6NC/m+qiGp/sTis'
         'DYucqbeuM7nmJi+8Hb55y1xWoOZI'
         'KMa71G5/4EOQxuQ/sgW965OOO2Hq'
         'X8vjlQUnTK0HijrbSTLxp/9kazWW'
         'FrfsdB8RtZBN digambar@magnum')
Exemple #47
0
 def test_get_one(self):
     baymodel = obj_utils.create_test_baymodel(self.context)
     response = self.get_json('/baymodels/%s' % baymodel['uuid'])
     self.assertEqual(baymodel.uuid, response['uuid'])
     self.assertIn('flavor_id', response)
     self.assertIn('master_flavor_id', response)
     self.assertIn('dns_nameserver', response)
     self.assertIn('keypair_id', response)
     self.assertIn('external_network_id', response)
     self.assertIn('fixed_network', response)
     self.assertIn('network_driver', response)
     self.assertIn('docker_volume_size', response)
     self.assertIn('ssh_authorized_key', response)
     self.assertIn('coe', response)
     self.assertIn('http_proxy', response)
     self.assertIn('https_proxy', response)
     self.assertIn('no_proxy', response)
     self.assertIn('labels', response)
Exemple #48
0
 def setUp(self):
     super(TestPatch, self).setUp()
     p = mock.patch.object(attr_validator, 'validate_os_resources')
     self.mock_valid_os_res = p.start()
     self.addCleanup(p.stop)
     self.baymodel = obj_utils.create_test_baymodel(
         self.context,
         name='bay_model_example_A',
         image_id='nerdherd',
         apiserver_port=8080,
         fixed_network='private',
         flavor_id='m1.magnum',
         master_flavor_id='m1.magnum',
         external_network_id='public',
         keypair_id='test',
         volume_driver='rexray',
         public=False,
         docker_volume_size=20,
         coe='swarm',
         labels={'key1': 'val1', 'key2': 'val2'}
     )
Exemple #49
0
 def test_delete_baymodel_with_name(self):
     baymodel = obj_utils.create_test_baymodel(self.context)
     response = self.delete('/baymodels/%s' % baymodel['name'],
                            expect_errors=True)
     self.assertEqual(204, response.status_int)
Exemple #50
0
 def test_detail_against_single(self):
     baymodel = obj_utils.create_test_baymodel(self.context)
     response = self.get_json('/baymodels/%s/detail' % baymodel['uuid'],
                              expect_errors=True)
     self.assertEqual(404, response.status_int)
Exemple #51
0
 def setUp(self):
     super(TestListBay, self).setUp()
     obj_utils.create_test_baymodel(self.context)
Exemple #52
0
 def test_policy_disallow_get_one(self):
     baymodel = obj_utils.create_test_baymodel(self.context)
     self._common_policy_check(
         "baymodel:get", self.get_json,
         '/baymodels/%s' % baymodel.uuid,
         expect_errors=True)
Exemple #53
0
 def test_policy_disallow_delete(self):
     baymodel = obj_utils.create_test_baymodel(self.context)
     self._common_policy_check(
         "baymodel:delete", self.delete,
         '/baymodels/%s' % baymodel.uuid, expect_errors=True)
Exemple #54
0
 def test_policy_only_owner_delete(self):
     baymodel = obj_utils.create_test_baymodel(self.context,
                                               user_id='another')
     self._owner_check(
         "baymodel:delete", self.delete, '/baymodels/%s' % baymodel.uuid,
         expect_errors=True)
Exemple #55
0
 def test_policy_disallow_delete(self):
     baymodel = obj_utils.create_test_baymodel(self.context,
                                               uuid='137-246-789')
     self._common_policy_check("baymodel:delete", self.delete,
                               '/baymodels/%s' % baymodel.uuid)
Exemple #56
0
 def test_one(self):
     baymodel = obj_utils.create_test_baymodel(self.context)
     response = self.get_json('/baymodels')
     self.assertEqual(baymodel.uuid, response['baymodels'][0]["uuid"])
     self._verify_attrs(self._baymodel_attrs,
                        response['baymodels'][0])
Exemple #57
0
 def setUp(self):
     super(TestBayPolicyEnforcement, self).setUp()
     obj_utils.create_test_baymodel(self.context)
Exemple #58
0
 def test_get_one_by_name(self):
     baymodel = obj_utils.create_test_baymodel(self.context)
     response = self.get_json('/baymodels/%s' % baymodel['name'])
     self.assertEqual(baymodel.uuid, response['uuid'])
     self._verify_attrs(self._baymodel_attrs, response)