def is_valid_node_name(name): """Determine if the provided name is a valid node name. Check to see that the provided node name is valid, and isn't a UUID. :param: name: the node name to check. :returns: True if the name is valid, False otherwise. """ return utils.is_hostname_safe(name) and (not uuidutils.is_uuid_like(name))
def is_valid_board_name(name): """Determine if the provided name is a valid board name. Check to see that the provided board name is valid, and isn't a UUID. :param: name: the board name to check. :returns: True if the name is valid, False otherwise. """ return utils.is_hostname_safe(name) and (not uuidutils.is_uuid_like(name))
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 validate(value): if not utils.is_hostname_safe(value): raise exception.InvalidName(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