Darryl L. Pierce wrote: > Checks for the standard fields for a URL, and enforces some simple > requirements. > > An exception is raised if the filename: > > * has a hostname but not a protocol and port, > * has a protocol but not hostname > > Signed-off-by: Darryl L. Pierce <[email protected]> > --- > cobbler/item_image.py | 19 +++++++++++++++++-- > 1 files changed, 17 insertions(+), 2 deletions(-) > > diff --git a/cobbler/item_image.py b/cobbler/item_image.py > index 98e0255..2ce6738 100644 > --- a/cobbler/item_image.py > +++ b/cobbler/item_image.py > @@ -113,11 +113,26 @@ class Image(item.Item): > def set_file(self,filename): > """ > Stores the image location. This should be accessible on all nodes > - that need to access it. Format: either /mnt/commonpath/foo.iso or > + that need to access it. Format: either /mnt/commonpath/foo.iso or > nfs://host/path/foo.iso > """ > # FIXME: this should accept NFS paths or filesystem paths > - self.file = filename > + uri = filename > + > + protocol = auth = hostname = port = path = file = "" > + if filename.find("://") != -1: protocol, filename = > filename.split("://") > + if filename.find("@") != -1: auth, filename = filename.split("@") > + if filename.find("/") > 0: hostname, filename = > filename.split("/", 1) > + if hostname.find(":") != -1: hostname, port = hostname.split(":") > + if filename.find("/") != -1: path, filename = filename.rsplit("/", 1) > + > + if len(filename) == 0: raise CX(_("missing filename")) > + if len(hostname) > 0 and len(protocol) == 0 and len(port) == 0: > + raise CX(_("if protocol is not supplied then a port must be > provided")) > + if len(hostname) == 0 and len(protocol) > 0: > + raise CX(_("no hostname supplied but is required for protocol")) > + > + self.file = uri > return True > > def set_os_version(self,os_version): >
I think we can be more explicit WRT the "if protocol is not supplied" based on only supporting what koan can support today: The valid forms are: nfs://hostspec:/path_not_ending_in_slash hostspec can be either "u...@host" or "host". the literal "nfs://" is required for this format. /absolute_path_not_ending_in_slash I'm not sure what the port details were? Where would a port be supplied? Thanks, --Michael _______________________________________________ cobbler mailing list [email protected] https://fedorahosted.org/mailman/listinfo/cobbler
