def post(self): conn = connect() image = find_image(conn, ns.payload.get('image')) if image is None: ns.abort(400, f'Invalid image provided: {ns.payload.get("image")}') flavor = find_flavor(conn, ns.payload.get('flavor')) if flavor is None: ns.abort(400, f'Invalid flavor provided: {ns.payload.get("flavor")}') network = find_network(conn, ns.payload.get('network')) if network is None: ns.abort(400, f'Invalid network provided: {ns.payload.get("network")}') try: server = conn.compute.create_server( name=ns.payload.get('name'), image_id=image.id, flavor_id=flavor.id, networks=[{ "uuid": network.id }], ) server = conn.compute.wait_for_server(server) except ResourceFailure: raise ns.abort( 400, "Invalid resources provided. Check if you have enough resources left on devstack machine" ) return { 'server': server, }, 201
def get(self): conn = connect() server_info = [] for server in list_servers(conn): server_info.append(get_server_info(server)) return {'servers': server_info}, 200
def get(self, name): conn = connect() flavor = find_flavor(conn, name) if flavor is None: ns.abort(404) return {'flavor': flavor}, 200
def get(self, name): conn = connect() network = find_network(conn, name) if network is None: ns.abort(404) return {'network': network}, 200
def get(self, name): conn = connect() image = find_image(conn, name) if image is None: ns.abort(404) return {'image': image}, 200
def get(self, server_id): conn = connect() server = find_server(conn, server_id) if server is None: ns.abort(404) return {'server': get_server_info(server)}, 200
def delete(self, server_id): conn = connect() server = find_server(conn, server_id) if server is None: ns.abort(404) success = delete_server(conn, server_id) return { 'server': server, 'success': success, }, 200
def get(self): conn = connect() flavors = list_flavors(conn) return {'flavors': flavors}, 200
def get(self): conn = connect() networks = list_networks(conn) return {'networks': networks}, 200
def get(self): conn = connect() images = list_images(conn) return {'images': images}, 200