def _route_servers_id_action(dummy_tenant_id, server_id): """ Route: /v1.1/<dummy_tenant_id>/servers/<server_id>/action Method: POST """ utils.show_request(bottle.request) body = json.load(bottle.request.body) # nova console-log if 'os-getConsoleOutput' in body: return api_response.servers_console_log(SERVERS.console_log(server_id)) # nova start elif 'os-start' in body: SERVERS.start(server_id) return # nova stop elif 'os-stop' in body: SERVERS.stop(server_id) return # nova reboot elif 'reboot' in body: hard = body['reboot']['type'].lower() == 'hard' SERVERS.reboot(server_id, hard) return raise exception.BadRequest(reason='Unsupported request')
def _route_images_id(image_id): """ Route: /v1/images/<image_id> Method: GET, HEAD, DELETE, PUT """ utils.show_request(bottle.request) # glance image-list if image_id == 'detail' and bottle.request.method == 'GET': return {'images': IMAGES.list()} # glance image-show <image_id> if image_id != 'detail' and bottle.request.method == 'HEAD': image = IMAGES.show(image_id) _add_header(image) return # glance image-delete <image_id> if image_id != 'detail' and bottle.request.method == 'DELETE': IMAGES.delete(image_id) return # glance image-update <image_id> if image_id != 'detail' and bottle.request.method == 'PUT': image_md = _from_headers(bottle.request.headers) return {'image': IMAGES.update(image_id, image_md)} bottle.abort(400, 'Unable to handle request')
def _route_images_id(image_id): """ Route: /v1/images/<image_id> Method: GET, HEAD, DELETE, PUT """ utils.show_request(bottle.request) # glance image-list if image_id == 'detail' and bottle.request.method == 'GET': return api_response.images_list(IMAGES.list()) # glance image-show <image_id> if image_id != 'detail' and bottle.request.method == 'HEAD': image = IMAGES.show(image_id) _add_header(image) return # glance image-delete <image_id> if image_id != 'detail' and bottle.request.method == 'DELETE': IMAGES.delete(image_id) return # glance image-update <image_id> if image_id != 'detail' and bottle.request.method == 'PUT': image_md = _from_headers(bottle.request.headers) return api_response.images_update(IMAGES.update(image_id, image_md)) raise exception.BadRequest(reason='Unsupported request')
def _route_servers_id_action(server_id): """ Route: /compute/v2.0/servers/<server_id>/action Method: POST """ utils.show_request(bottle.request) body = json.load(bottle.request.body) # nova console-log if 'os-getConsoleOutput' in body: return api_response.show_console_log(SERVERS.console_log(server_id)) # nova start elif 'os-start' in body: SERVERS.start(server_id) return # nova stop elif 'os-stop' in body: SERVERS.stop(server_id) return # nova reboot elif 'reboot' in body: hard = body['reboot']['type'].lower() == 'hard' SERVERS.reboot(server_id, hard) return raise exception.BadRequest(reason='Unsupported request')
def _route_version(): """ Route: /identity/v2.0 Method: GET """ utils.show_request(bottle.request) return api_response.show_version_v2d0()
def _route_schemas_image(): """ Route: /image/v2/schemas/image Method: GET """ utils.show_request(bottle.request) return api_response.show_image_schema()
def _route_schemas_metadefs(_metadef): """ Route: /image/v2/schemas/metadefs/<_metadef> Method: GET """ utils.show_request(bottle.request) return api_response.list_metadefs()
def _route_version(): """ Routes: /v1.1 Method: GET """ utils.show_request(bottle.request) return {"version": API_VERSIONS[0]}
def _route_version(): """ Route: /v2.0 Method: GET """ utils.show_request(bottle.request) return VERSION_RESPONSE
def _route_os_keypairs_name(dummy_tenant_id, keypair_name): """ Route: /v1.1/<dummy_tenant_id>/os-keypairs/<keypair_name> Method: DELETE """ utils.show_request(bottle.request) KEYPAIRS.delete(keypair_name)
def _route_version(): """ Route: /v2.0 Method: GET """ utils.show_request(bottle.request) return {"version": VERSION_V2_0}
def _route_images(dummy_tenant_id): """ Route: /v1.1/<dummy_tenant_id>/images Method: GET """ utils.show_request(bottle.request) return {'images': IMAGES.list(detail=False)}
def _route_images(dummy_tenant_id): """ Route: /v1.1/<dummy_tenant_id>/images Method: GET """ utils.show_request(bottle.request) return api_response.images_list(IMAGES.list(), details=False)
def _route_version(): """ Routes: /compute/v2.0 Method: GET """ utils.show_request(bottle.request) return api_response.show_version_v2d0()
def _route_versions(): """ Routes: /compute Method: GET """ utils.show_request(bottle.request) bottle.response.status = 300 return api_response.list_versions()
def _route_versions(): """ Route: /image, /image/versions Method: GET """ utils.show_request(bottle.request) bottle.response.status = 300 return api_response.list_versions()
def _route_versions(): """ Route: / Method: GET """ utils.show_request(bottle.request) bottle.response.status = 300 return {"versions": VERSIONS}
def _route_tokens(): """ Route: /identity/v2.0/tokens Method: POST """ utils.show_request(bottle.request) body = json.load(bottle.request.body) if 'auth' in body: return api_response.authenticate()
def _route_tokens(): """ Route: /v2.0/tokens Method: POST """ utils.show_request(bottle.request) body = json.load(bottle.request.body) if 'auth' in body: return TOKENS_RESPONSE
def _route_tokens(): """ Route: /v2.0/tokens Method: POST """ utils.show_request(bottle.request) body = json.load(bottle.request.body) if 'auth' in body: return {"access": ACCESS}
def _route_images_id_file(image_id): """ Route: /image/v2/images/<image_id>/file Method: PUT """ utils.show_request(bottle.request) # glance image-upload bottle.response.status = 204 image_fh = bottle.request.body IMAGES.upload(image_id, image_fh) return
def _route_images_id(dummy_tenant_id, image_id): """ Route: /v1.1/<dummy_tenant_id>/images/<image_id> Method: GET """ utils.show_request(bottle.request) # nova image-list if image_id == 'detail': return {'images': IMAGES.list()} # nova image-show <image_id> return {'image': IMAGES.show(image_id)}
def _route_images_id(dummy_tenant_id, image_id): """ Route: /v1.1/<dummy_tenant_id>/images/<image_id> Method: GET """ utils.show_request(bottle.request) # nova image-list if image_id == 'detail': return api_response.images_list(IMAGES.list()) # nova image-show <image_id> return api_response.images_show(IMAGES.show(image_id))
def _route_images(): """ Route: /v1/images Method: POST """ utils.show_request(bottle.request) # Parse the HTTP header image_md = _from_headers(bottle.request.headers) # glance image-create image_fh = _request_body(bottle.request) return api_response.images_create(IMAGES.create(image_fh, image_md))
def _route_images(): """ Route: /v1/images Method: GET """ utils.show_request(bottle.request) # Parse the HTTP header image_md = _from_headers(bottle.request.headers) # glance image-create image_fh = _request_body(bottle.request) return {'image': IMAGES.create(image_fh, image_md)}
def _route_servers(dummy_tenant_id): """ Route: /v1.1/<dummy_tenant_id>/servers Method: GET, POST """ utils.show_request(bottle.request) # nova boot if bottle.request.method == 'POST': body = json.load(bottle.request.body) return api_response.servers_boot(SERVERS.boot(body['server'])) # nova list (no details) return api_response.servers_list(SERVERS.list(), details=False)
def _route_os_keypairs_name(dummy_tenant_id, keypair_name): """ Route: /v1.1/<dummy_tenant_id>/os-keypairs/<keypair_name> Method: DELETE, GET """ utils.show_request(bottle.request) # nova keypair-delete if bottle.request.method == 'DELETE': KEYPAIRS.delete(keypair_name) return # nova keypair-show return api_response.keypairs_show(KEYPAIRS.show(keypair_name))
def _route_os_keypairs(dummy_tenant_id): """ Route: /v1.1/<dummy_tenant_id>/os-keypairs Method: GET, POST """ utils.show_request(bottle.request) # nova keypair-add if bottle.request.method == 'POST': body = json.load(bottle.request.body) return api_response.keypairs_add(KEYPAIRS.add(body['keypair'])) # nova keypair-list return api_response.keypairs_list(KEYPAIRS.list())
def _route_os_keypairs(dummy_tenant_id): """ Route: /v1.1/<dummy_tenant_id>/os-keypairs Method: GET, POST """ utils.show_request(bottle.request) # nova keypair-add if bottle.request.method == 'POST': body = json.load(bottle.request.body) return {'keypair': KEYPAIRS.add(body['keypair'])} # nova keypair-list return {'keypairs': KEYPAIRS.list()}
def _route_os_keypairs(): """ Route: /compute/v2.0/os-keypairs Method: GET, POST """ utils.show_request(bottle.request) # nova keypair-add if bottle.request.method == 'POST': body = json.load(bottle.request.body) return api_response.create_keypair(KEYPAIRS.create(body['keypair'])) # nova keypair-list return api_response.list_keypairs(KEYPAIRS.list())
def _route_os_keypairs_name(keypair_name): """ Route: /compute/v2.0/os-keypairs/<keypair_name> Method: DELETE, GET """ utils.show_request(bottle.request) # nova keypair-delete if bottle.request.method == 'DELETE': KEYPAIRS.delete(keypair_name) return # nova keypair-show return api_response.show_keypair(KEYPAIRS.show(keypair_name))
def _route_servers(): """ Route: /compute/v2.0/servers Method: GET, POST """ utils.show_request(bottle.request) # nova boot if bottle.request.method == 'POST': body = json.load(bottle.request.body) return api_response.create_server(SERVERS.create(body['server'])) # nova list (no details) return api_response.list_servers(SERVERS.list(), details=False)
def _route_flavors(): """ Route: /compute/v2.0/flavors Method: GET, POST """ utils.show_request(bottle.request) # nova flavor-create if bottle.request.method == 'POST': body = json.load(bottle.request.body) return api_response.create_flavor(FLAVORS.create(body['flavor'])) # nova flavor-list (no details) return api_response.list_flavors(FLAVORS.list(), details=False)
def _route_flavors(dummy_tenant_id): """ Route: /v1.1/<dummy_tenant_id>/flavors Method: GET, POST """ utils.show_request(bottle.request) # nova flavor-create if bottle.request.method == 'POST': body = json.load(bottle.request.body) return {'flavor': FLAVORS.create(body['flavor'])} # nova flavor-list (no details) return {'flavors': FLAVORS.list(detail=False)}
def _route_servers(dummy_tenant_id): """ Route: /v1.1/<dummy_tenant_id>/servers Method: GET, POST """ utils.show_request(bottle.request) # nova boot if bottle.request.method == 'POST': body = json.load(bottle.request.body) return {'server': SERVERS.boot(body['server'])} # nova list (no details) return {'servers': SERVERS.list(detail=False)}
def _route_flavors(dummy_tenant_id): """ Route: /v1.1/<dummy_tenant_id>/flavors Method: GET, POST """ utils.show_request(bottle.request) # nova flavor-create if bottle.request.method == 'POST': body = json.load(bottle.request.body) return api_response.flavors_create(FLAVORS.create(body['flavor'])) # nova flavor-list (no details) return api_response.flavors_list(FLAVORS.list(), details=False)
def _route_flavors_id(flavor_id): """ Route: /compute/v2.0/flavors/<flavor_id> Method: GET, DELETE """ utils.show_request(bottle.request) # nova flavor-delete <flavor_id> if bottle.request.method == 'DELETE': FLAVORS.delete(flavor_id) return # nova flavor-list if flavor_id == 'detail': return api_response.list_flavors(FLAVORS.list(), details=True) # nova flavor-show <flavor_id> return api_response.show_flavor(FLAVORS.show(flavor_id))
def _route_servers_id(server_id): """ Route: /compute/v2.0/servers/<server_id> Method: GET, DELETE """ utils.show_request(bottle.request) # nova delete <server_id> if bottle.request.method == 'DELETE': SERVERS.delete(server_id) return # nova list if server_id == 'detail': return api_response.list_servers(SERVERS.list(), details=True) # nova show <server_id> return api_response.show_server(SERVERS.show(server_id))
def _route_flavors_id(dummy_tenant_id, flavor_id): """ Route: /v1.1/<dummy_tenant_id>/flavors/<flavor_id> Method: GET, DELETE """ utils.show_request(bottle.request) # nova flavor-delete <flavor_id> if bottle.request.method == 'DELETE': FLAVORS.delete(flavor_id) return # nova flavor-list if flavor_id == 'detail': return {'flavors': FLAVORS.list()} # nova flavor-show <flavor_id> return {'flavor': FLAVORS.show(flavor_id)}
def _route_servers_id(dummy_tenant_id, server_id): """ Route: /v1.1/<dummy_tenant_id>/servers/<server_id> Method: GET, DELETE """ utils.show_request(bottle.request) # nova delete <server_id> if bottle.request.method == 'DELETE': SERVERS.delete(server_id) return # nova list if server_id == 'detail': return {'servers': SERVERS.list()} # nova show <server_id> return {'server': SERVERS.show(server_id)}
def _route_flavors_id(dummy_tenant_id, flavor_id): """ Route: /v1.1/<dummy_tenant_id>/flavors/<flavor_id> Method: GET, DELETE """ utils.show_request(bottle.request) # nova flavor-delete <flavor_id> if bottle.request.method == 'DELETE': FLAVORS.delete(flavor_id) return # nova flavor-list if flavor_id == 'detail': return api_response.flavors_list(FLAVORS.list()) # nova flavor-show <flavor_id> return api_response.flavors_show(FLAVORS.show(flavor_id))
def _route_images_id(image_id): """ Route: /image/v2/images/<image_id> Method: GET, DELETE, PATCH """ utils.show_request(bottle.request) # glance image-delete if bottle.request.method == 'DELETE': bottle.response.status = 204 IMAGES.delete(image_id) return # glance image-update if bottle.request.method == 'PATCH': image_ops = json.load(bottle.request.body) return api_response.update_image(IMAGES.update(image_id, image_ops)) # glance image-show return api_response.show_image(IMAGES.show(image_id))
def _route_images(): """ Route: /image/v2/images Method: GET, POST """ utils.show_request(bottle.request) # glance image-create if bottle.request.method == 'POST': bottle.response.status = 201 image_md = json.load(bottle.request.body) return api_response.create_image(IMAGES.create(image_md)) # glance image-list if (bottle.request.query.get('marker', None) is not None): # When the client wants more, tell it we're done return api_response.list_images([]) else: # We don't 'do' marker, so return it all on the first call return api_response.list_images(IMAGES.list())
def _route_servers_id_action(dummy_tenant_id, server_id): """ Route: /v1.1/<dummy_tenant_id>/servers/<server_id>/action Method: POST """ utils.show_request(bottle.request) body = json.load(bottle.request.body) # nova console-log if 'os-getConsoleOutput' in body: return {'output': SERVERS.console_log(server_id)} # nova reboot elif 'reboot' in body: hard = body['reboot']['type'].lower() == 'hard' SERVERS.reboot(server_id, hard) return bottle.abort(400)