Пример #1
0
 def post_os_security_groups(request, url, headers):
     body = jsonutils.loads(request.body.decode('utf-8'))
     assert list(body) == ['security_group']
     fakes.assert_has_keys(body['security_group'],
                           required=['name', 'description'])
     r = jsonutils.dumps({'security_group': security_group_1})
     return 202, headers, r
 def post_os_security_groups(request, url, headers):
     body = jsonutils.loads(request.body.decode('utf-8'))
     assert list(body) == ['security_group']
     fakes.assert_has_keys(body['security_group'],
                           required=['name', 'description'])
     r = jsonutils.dumps({'security_group': security_group_1})
     return 202, headers, r
Пример #3
0
 def post_servers(self, body, **kw):
     assert set(body.keys()) <= set(['server'])
     fakes.assert_has_keys(body['server'],
                     required=['name', 'image_ref', 'flavor_ref'],
                     optional=['metadata', 'personality',
                               'os-scheduler-hints:scheduler_hints'])
     return (202, {}, self.get_servers_1234()[2])
Пример #4
0
 def post_servers(self, body, **kw):
     assert set(body.keys()) <= set(['server'])
     fakes.assert_has_keys(body['server'],
                           required=['name', 'image_ref', 'flavor_ref'],
                           optional=[
                               'metadata', 'personality',
                               'os-scheduler-hints:scheduler_hints'
                           ])
     return (202, {}, self.get_servers_1234()[2])
        def post_rules(request, context):
            body = jsonutils.loads(request.body)
            assert list(body) == ['security_group_rule']
            fakes.assert_has_keys(body['security_group_rule'],
                                  required=['parent_group_id'],
                                  optional=['group_id', 'ip_protocol',
                                            'from_port', 'to_port', 'cidr'])

            return {'security_group_rule': rule}
Пример #6
0
        def post_rules(request, url, headers):
            body = jsonutils.loads(request.body.decode('utf-8'))
            assert list(body) == ['security_group_rule']
            fakes.assert_has_keys(body['security_group_rule'],
                                  required=['parent_group_id'],
                                  optional=['group_id', 'ip_protocol',
                                            'from_port', 'to_port', 'cidr'])

            return 202, headers, jsonutils.dumps({'security_group_rule': rule})
Пример #7
0
        def post_rules(request, context):
            body = jsonutils.loads(request.body)
            assert list(body) == ['security_group_rule']
            fakes.assert_has_keys(body['security_group_rule'],
                                  required=['parent_group_id'],
                                  optional=[
                                      'group_id', 'ip_protocol', 'from_port',
                                      'to_port', 'cidr'
                                  ])

            return {'security_group_rule': rule}
Пример #8
0
    def post_servers(self, request, url, headers):
        body = jsonutils.loads(request.body.decode('utf-8'))
        assert set(body.keys()) <= set(['server'])
        fakes.assert_has_keys(body['server'],
                        required=['name', 'image_ref', 'flavor_ref'],
                        optional=['metadata', 'personality',
                                  'os-scheduler-hints:scheduler_hints'])
        if body['server']['name'] == 'some-bad-server':
            body = self.server_1235
        else:
            body = self.server_1234

        return 202, headers, jsonutils.dumps({'server': body})
Пример #9
0
    def post_servers(self, request, context):
        body = jsonutils.loads(request.body)
        assert set(body.keys()) <= set(['server'])
        fakes.assert_has_keys(body['server'],
                        required=['name', 'image_ref', 'flavor_ref'],
                        optional=['metadata', 'personality',
                                  'os-scheduler-hints:scheduler_hints'])
        if body['server']['name'] == 'some-bad-server':
            body = self.server_1235
        else:
            body = self.server_1234

        context.status_code = 202
        return {'server': body}
Пример #10
0
    def post_servers(self, request, context):
        body = jsonutils.loads(request.body)
        assert set(body.keys()) <= set(["server"])
        fakes.assert_has_keys(
            body["server"],
            required=["name", "image_ref", "flavor_ref"],
            optional=["metadata", "personality", "os-scheduler-hints:scheduler_hints"],
        )
        if body["server"]["name"] == "some-bad-server":
            body = self.server_1235
        else:
            body = self.server_1234

        context.status_code = 202
        return {"server": body}
Пример #11
0
    def post_servers(self, request, url, headers):
        body = jsonutils.loads(request.body.decode('utf-8'))
        assert set(body.keys()) <= set(['server'])
        fakes.assert_has_keys(body['server'],
                              required=['name', 'image_ref', 'flavor_ref'],
                              optional=[
                                  'metadata', 'personality',
                                  'os-scheduler-hints:scheduler_hints'
                              ])
        if body['server']['name'] == 'some-bad-server':
            body = self.server_1235
        else:
            body = self.server_1234

        return 202, headers, jsonutils.dumps({'server': body})
Пример #12
0
    def post_servers(self, request, context):
        body = jsonutils.loads(request.body)
        context.status_code = 202
        assert set(body.keys()) <= set(["server", "os:scheduler_hints"])
        fakes.assert_has_keys(
            body["server"], required=["name", "imageRef", "flavorRef"], optional=["metadata", "personality"]
        )
        if "personality" in body["server"]:
            for pfile in body["server"]["personality"]:
                fakes.assert_has_keys(pfile, required=["path", "contents"])
        if body["server"]["name"] == "some-bad-server":
            body = self.server_1235
        else:
            body = self.server_1234

        return {"server": body}
Пример #13
0
    def post_servers(self, request, context):
        body = jsonutils.loads(request.body)
        context.status_code = 202
        assert (set(body.keys()) <= set(['server', 'os:scheduler_hints']))
        fakes.assert_has_keys(body['server'],
                              required=['name', 'imageRef', 'flavorRef'],
                              optional=['metadata', 'personality'])
        if 'personality' in body['server']:
            for pfile in body['server']['personality']:
                fakes.assert_has_keys(pfile, required=['path', 'contents'])
        if body['server']['name'] == 'some-bad-server':
            body = self.server_1235
        else:
            body = self.server_1234

        return {'server': body}
Пример #14
0
    def post_servers(self, request, context):
        body = jsonutils.loads(request.body)
        context.status_code = 202
        assert (set(body.keys()) <=
                set(['server', 'os:scheduler_hints']))
        fakes.assert_has_keys(body['server'],
                              required=['name', 'imageRef', 'flavorRef'],
                              optional=['metadata', 'personality'])
        if 'personality' in body['server']:
            for pfile in body['server']['personality']:
                fakes.assert_has_keys(pfile, required=['path', 'contents'])
        if body['server']['name'] == 'some-bad-server':
            body = self.server_1235
        else:
            body = self.server_1234

        return {'server': body}
Пример #15
0
        def post_os_volumes_boot(request, context):
            body = jsonutils.loads(request.body)
            assert set(body.keys()) <= set(["server", "os:scheduler_hints"])

            fakes.assert_has_keys(body["server"], required=["name", "flavorRef"], optional=["imageRef"])

            data = body["server"]

            # Require one, and only one, of the keys for bdm
            if "block_device_mapping" not in data:
                if "block_device_mapping_v2" not in data:
                    msg = "missing required keys: 'block_device_mapping'"
                    raise AssertionError(msg)
            elif "block_device_mapping_v2" in data:
                msg = "found extra keys: 'block_device_mapping'"
                raise AssertionError(msg)

            return {"server": self.server_9012}
Пример #16
0
        def post_os_volumes_boot(request, url, headers):
            body = jsonutils.loads(request.body.decode('utf-8'))
            assert (set(body.keys()) <= set(['server', 'os:scheduler_hints']))

            fakes.assert_has_keys(body['server'],
                                  required=['name', 'flavorRef'],
                                  optional=['imageRef'])

            data = body['server']

            # Require one, and only one, of the keys for bdm
            if 'block_device_mapping' not in data:
                if 'block_device_mapping_v2' not in data:
                    msg = "missing required keys: 'block_device_mapping'"
                    raise AssertionError(msg)
            elif 'block_device_mapping_v2' in data:
                msg = "found extra keys: 'block_device_mapping'"
                raise AssertionError(msg)

            return 202, headers, jsonutils.dumps({'server': self.server_9012})
Пример #17
0
        def post_os_volumes_boot(request, context):
            body = jsonutils.loads(request.body)
            assert (set(body.keys()) <=
                    set(['server', 'os:scheduler_hints']))

            fakes.assert_has_keys(body['server'],
                                  required=['name', 'flavorRef'],
                                  optional=['imageRef'])

            data = body['server']

            # Require one, and only one, of the keys for bdm
            if 'block_device_mapping' not in data:
                if 'block_device_mapping_v2' not in data:
                    msg = "missing required keys: 'block_device_mapping'"
                    raise AssertionError(msg)
            elif 'block_device_mapping_v2' in data:
                msg = "found extra keys: 'block_device_mapping'"
                raise AssertionError(msg)

            return {'server': self.server_9012}
Пример #18
0
        def put_os_floating_ip_dns_testdomain(request, context):
            body = jsonutils.loads(request.body)
            if body["domain_entry"]["scope"] == "private":
                fakes.assert_has_keys(body["domain_entry"], required=["availability_zone", "scope"])
            elif body["domain_entry"]["scope"] == "public":
                fakes.assert_has_keys(body["domain_entry"], required=["project", "scope"])
            else:
                fakes.assert_has_keys(body["domain_entry"], required=["project", "scope"])

            return request.body
Пример #19
0
        def put_os_floating_ip_dns_testdomain(request, context):
            body = jsonutils.loads(request.body)
            if body['domain_entry']['scope'] == 'private':
                fakes.assert_has_keys(body['domain_entry'],
                                      required=['availability_zone', 'scope'])
            elif body['domain_entry']['scope'] == 'public':
                fakes.assert_has_keys(body['domain_entry'],
                                      required=['project', 'scope'])
            else:
                fakes.assert_has_keys(body['domain_entry'],
                                      required=['project', 'scope'])

            return request.body
Пример #20
0
        def put_os_floating_ip_dns_testdomain(request, context):
            body = jsonutils.loads(request.body)
            if body['domain_entry']['scope'] == 'private':
                fakes.assert_has_keys(body['domain_entry'],
                                      required=['availability_zone', 'scope'])
            elif body['domain_entry']['scope'] == 'public':
                fakes.assert_has_keys(body['domain_entry'],
                                      required=['project', 'scope'])
            else:
                fakes.assert_has_keys(body['domain_entry'],
                                      required=['project', 'scope'])

            return request.body
Пример #21
0
        def put_os_floating_ip_dns_testdomain(request, url, headers):
            body = jsonutils.loads(request.body.decode('utf-8'))
            if body['domain_entry']['scope'] == 'private':
                fakes.assert_has_keys(body['domain_entry'],
                                      required=['availability_zone', 'scope'])
            elif body['domain_entry']['scope'] == 'public':
                fakes.assert_has_keys(body['domain_entry'],
                                      required=['project', 'scope'])
            else:
                fakes.assert_has_keys(body['domain_entry'],
                                      required=['project', 'scope'])

            headers['Content-Type'] = 'application/json'
            return (205, headers, request.body)
Пример #22
0
        def put_os_floating_ip_dns_testdomain(request, url, headers):
            body = jsonutils.loads(request.body.decode('utf-8'))
            if body['domain_entry']['scope'] == 'private':
                fakes.assert_has_keys(body['domain_entry'],
                                      required=['availability_zone', 'scope'])
            elif body['domain_entry']['scope'] == 'public':
                fakes.assert_has_keys(body['domain_entry'],
                                      required=['project', 'scope'])
            else:
                fakes.assert_has_keys(body['domain_entry'],
                                      required=['project', 'scope'])

            headers['Content-Type'] = 'application/json'
            return (205, headers, request.body)
Пример #23
0
 def put_servers_1234(request, url, headers):
     body = jsonutils.loads(request.body.decode('utf-8'))
     assert list(body) == ['server']
     fakes.assert_has_keys(body['server'],
                           optional=['name', 'adminPass'])
     return 204, headers, request.body
Пример #24
0
 def put_dns_testdomain_entries_testname(request, url, headers):
     body = jsonutils.loads(request.body.decode('utf-8'))
     fakes.assert_has_keys(body['dns_entry'],
                           required=['ip', 'dns_type'])
     return 205, headers, request.body
Пример #25
0
 def put_servers_1234(request, url, headers):
     body = jsonutils.loads(request.body.decode('utf-8'))
     assert list(body) == ['server']
     fakes.assert_has_keys(body['server'],
                           optional=['name', 'adminPass'])
     return 204, headers, request.body
 def put_os_security_groups_1(request, context):
     body = jsonutils.loads(request.body)
     assert list(body) == ['security_group']
     fakes.assert_has_keys(body['security_group'],
                           required=['name', 'description'])
     return body
Пример #27
0
 def put_dns_testdomain_entries_testname(request, context):
     body = jsonutils.loads(request.body)
     fakes.assert_has_keys(body['dns_entry'],
                           required=['ip', 'dns_type'])
     context.status_code = 205
     return request.body
Пример #28
0
 def post_images_1_metadata(request, context):
     body = jsonutils.loads(request.body)
     assert list(body) == ['metadata']
     fakes.assert_has_keys(body['metadata'], required=['test_key'])
     return {'metadata': image_1['metadata']}
Пример #29
0
 def put_servers_1234(request, context):
     body = jsonutils.loads(request.body)
     assert list(body) == ['server']
     fakes.assert_has_keys(body['server'],
                           optional=['name', 'adminPass'])
     return request.body
Пример #30
0
 def post_os_keypairs(request, url, headers):
     body = jsonutils.loads(request.body.decode('utf-8'))
     assert list(body) == ['keypair']
     fakes.assert_has_keys(body['keypair'], required=['name'])
     return 202, headers, jsonutils.dumps({'keypair': keypair})
Пример #31
0
 def post_images(request, url, headers):
     body = jsonutils.loads(request.body.decode('utf-8'))
     assert list(body) == ['image']
     fakes.assert_has_keys(body['image'], required=['serverId', 'name'])
     return 202, headers, jsonutils.dumps(images_1)
Пример #32
0
 def post_os_keypairs(request, url, headers):
     body = jsonutils.loads(request.body.decode('utf-8'))
     assert list(body) == ['keypair']
     fakes.assert_has_keys(body['keypair'], required=['name'])
     return 202, headers, jsonutils.dumps({'keypair': keypair})
Пример #33
0
 def post_images(request, context):
     body = jsonutils.loads(request.body)
     assert list(body) == ['image']
     fakes.assert_has_keys(body['image'], required=['serverId', 'name'])
     return images_1
Пример #34
0
 def post_images_1_metadata(request, context):
     body = jsonutils.loads(request.body)
     assert list(body) == ['metadata']
     fakes.assert_has_keys(body['metadata'], required=['test_key'])
     return {'metadata': image_1['metadata']}
Пример #35
0
 def put_servers_1234(request, context):
     body = jsonutils.loads(request.body)
     assert list(body) == ["server"]
     fakes.assert_has_keys(body["server"], optional=["name", "adminPass"])
     return request.body
Пример #36
0
 def post_images(request, context):
     body = jsonutils.loads(request.body)
     assert list(body) == ['image']
     fakes.assert_has_keys(body['image'], required=['serverId', 'name'])
     return images_1
Пример #37
0
 def post_os_keypairs(request, context):
     body = jsonutils.loads(request.body)
     assert list(body) == ['keypair']
     fakes.assert_has_keys(body['keypair'], required=['name'])
     return {'keypair': keypair}
Пример #38
0
 def post_os_keypairs(request, context):
     body = jsonutils.loads(request.body)
     assert list(body) == ['keypair']
     fakes.assert_has_keys(body['keypair'], required=['name'])
     return {'keypair': keypair}
Пример #39
0
 def put_dns_testdomain_entries_testname(request, url, headers):
     body = jsonutils.loads(request.body.decode('utf-8'))
     fakes.assert_has_keys(body['dns_entry'],
                           required=['ip', 'dns_type'])
     return 205, headers, request.body
Пример #40
0
 def post_images_1_metadata(request, url, headers):
     body = jsonutils.loads(request.body.decode('utf-8'))
     assert list(body) == ['metadata']
     fakes.assert_has_keys(body['metadata'], required=['test_key'])
     data = jsonutils.dumps({'metadata': image_1['metadata']})
     return 200, headers, data
Пример #41
0
 def post_images_1_metadata(request, url, headers):
     body = jsonutils.loads(request.body.decode('utf-8'))
     assert list(body) == ['metadata']
     fakes.assert_has_keys(body['metadata'], required=['test_key'])
     data = jsonutils.dumps({'metadata': image_1['metadata']})
     return 200, headers, data
Пример #42
0
 def put_dns_testdomain_entries_testname(request, context):
     body = jsonutils.loads(request.body)
     fakes.assert_has_keys(body['dns_entry'],
                           required=['ip', 'dns_type'])
     context.status_code = 205
     return request.body
Пример #43
0
 def post_images(request, url, headers):
     body = jsonutils.loads(request.body.decode('utf-8'))
     assert list(body) == ['image']
     fakes.assert_has_keys(body['image'], required=['serverId', 'name'])
     return 202, headers, jsonutils.dumps(images_1)