def get_rpc_service(service_ident): """Get the RPC service from the service uuid or logical name. :param service_ident: the UUID or logical name of a service. :returns: The RPC Service. :raises: InvalidUuidOrName if the name or uuid provided is not valid. :raises: ServiceNotFound if the service is not found. """ # Check to see if the service_ident is a valid UUID. If it is, treat it # as a UUID. if uuidutils.is_uuid_like(service_ident): return objects.Service.get_by_uuid(pecan.request.context, service_ident) # We can refer to services by their name, if the client supports it # if allow_service_logical_names(): # if utils.is_hostname_safe(service_ident): else: return objects.Service.get_by_name(pecan.request.context, service_ident) raise exception.InvalidUuidOrName(name=service_ident) raise exception.ServiceNotFound(service=service_ident)
def get_rpc_port(port_ident): """Get the RPC port from the port uuid. :param port_ident: the UUID or logical name of a port. :returns: The RPC Port. :raises: InvalidUuidOrName if the name or uuid provided is not valid. :raises: portNotFound if the port is not found. """ # Check to see if the port_ident is a valid UUID. If it is, treat it # as a UUID. if uuidutils.is_uuid_like(port_ident): return objects.Port.get_by_uuid(pecan.request.context, port_ident) # We can refer to ports by their name, if the client supports it else: return objects.Port.get_by_name(pecan.request.context, port_ident) raise exception.InvalidUuidOrName(uuid=port_ident) raise exception.PortNottFound(uuid=port_ident)
def get_rpc_node(node_ident): """Get the RPC node from the node uuid or logical name. :param node_ident: the UUID or logical name of a node. :returns: The RPC Node. :raises: InvalidUuidOrName if the name or uuid provided is not valid. :raises: NodeNotFound if the node is not found. """ # Check to see if the node_ident is a valid UUID. If it is, treat it # as a UUID. if uuidutils.is_uuid_like(node_ident): return objects.Node.get_by_uuid(pecan.request.context, node_ident) # We can refer to nodes by their name, if the client supports it if allow_node_logical_names(): if utils.is_hostname_safe(node_ident): return objects.Node.get_by_name(pecan.request.context, node_ident) raise exception.InvalidUuidOrName(name=node_ident) # Ensure we raise the same exception as we did for the Juno release raise exception.NodeNotFound(node=node_ident)
def get_rpc_plugin(plugin_ident): """Get the RPC plugin from the plugin uuid or logical name. :param plugin_ident: the UUID or logical name of a plugin. :returns: The RPC Plugin. :raises: InvalidUuidOrName if the name or uuid provided is not valid. :raises: PluginNotFound if the plugin is not found. """ # Check to see if the plugin_ident is a valid UUID. If it is, treat it # as a UUID. if uuidutils.is_uuid_like(plugin_ident): return objects.Plugin.get_by_uuid(pecan.request.context, plugin_ident) # We can refer to plugins by their name, if the client supports it # if allow_plugin_logical_names(): # if utils.is_hostname_safe(plugin_ident): else: return objects.Plugin.get_by_name(pecan.request.context, plugin_ident) raise exception.InvalidUuidOrName(name=plugin_ident) raise exception.PluginNotFound(plugin=plugin_ident)
def get_rpc_board(board_ident): """Get the RPC board from the board uuid or logical name. :param board_ident: the UUID or logical name of a board. :returns: The RPC Board. :raises: InvalidUuidOrName if the name or uuid provided is not valid. :raises: BoardNotFound if the board is not found. """ # Check to see if the board_ident is a valid UUID. If it is, treat it # as a UUID. if uuidutils.is_uuid_like(board_ident): return objects.Board.get_by_uuid(pecan.request.context, board_ident) # We can refer to boards by their name, if the client supports it # if allow_board_logical_names(): # if utils.is_hostname_safe(board_ident): else: return objects.Board.get_by_name(pecan.request.context, board_ident) raise exception.InvalidUuidOrName(name=board_ident) raise exception.BoardNotFound(board=board_ident)
def get_rpc_fleet(fleet_ident): """Get the RPC fleet from the fleet uuid or logical name. :param fleet_ident: the UUID or logical name of a fleet. :returns: The RPC Fleet. :raises: InvalidUuidOrName if the name or uuid provided is not valid. :raises: FleetNotFound if the fleet is not found. """ # Check to see if the fleet_ident is a valid UUID. If it is, treat it # as a UUID. if uuidutils.is_uuid_like(fleet_ident): return objects.Fleet.get_by_uuid(pecan.request.context, fleet_ident) # We can refer to fleets by their name, if the client supports it # if allow_fleet_logical_names(): # if utils.is_hostname_safe(fleet_ident): else: return objects.Fleet.get_by_name(pecan.request.context, fleet_ident) raise exception.InvalidUuidOrName(name=fleet_ident) raise exception.FleetNotFound(fleet=fleet_ident)
def validate(value): if not (uuidutils.is_uuid_like(value) or v1_utils.is_valid_logical_name(value)): raise exception.InvalidUuidOrName(name=value) return value
def validate(value): if not (uuidutils.is_uuid_like(value) or utils.is_hostname_safe(value)): raise exception.InvalidUuidOrName(name=value) return value