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_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_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}
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})
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}
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})
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}
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}
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})
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}
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}
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}
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})
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}
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
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
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)
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_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
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
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
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']}
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
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})
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)
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
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
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}
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