Пример #1
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}
Пример #2
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}
Пример #3
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}
Пример #4
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}
Пример #5
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}
Пример #6
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}
Пример #7
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
Пример #8
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
Пример #9
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
Пример #10
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']}
Пример #11
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
Пример #12
0
 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
Пример #13
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
Пример #14
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
Пример #15
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
Пример #16
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}
Пример #17
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}
Пример #18
0
 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