Exemplo n.º 1
0
 def validate_satellite_config(self):
     if self.smType != "sat":
         return
     elif not self.sat_server:
         raise InvalidOption("Please specify URL of Satellite 5.")
     elif not self.sat_username or not self.sat_password:
         raise InvalidOption("Please specify username and password of Satellite 5.")
Exemplo n.º 2
0
 def validate_config_name(self):
     if not self.config_name:
         raise InvalidOption("Please enter a name for your configuration")
     elif self.config_name.lower() == "default":
         raise InvalidOption(
             "'default' is not a valid configuration name. Please enter other name."
         )
Exemplo n.º 3
0
    def validate_satellite_config(self):
        if self.smType != "sat":
            return

        for field in ["sat_server", "sat_username", "sat_password"]:
            if not getattr(self, field):
                raise InvalidOption("%s is required." %
                                    field.replace("sat_", "").title())
Exemplo n.º 4
0
    def validate_virt_config(self):
        self.validate_virt_type()
        if not self.server and self.type not in ['libvirt', 'vdsm', 'fake']:
            raise InvalidOption("Server is required.")

        if ((self.smType == 'rhsm')
                and ((self.type in ('esx', 'rhevm', 'hyperv', 'xen')) or
                     (self.type == 'libvirt' and self.server))):
            if not self.env:
                raise InvalidOption("Environment is required.")
            elif not self.owner:
                raise InvalidOption("Organization is required.")

        if self.type == 'libvirt':
            if self.server:
                if ('ssh://' in self.server
                        or '://' not in self.server) and self.password:
                    raise InvalidOption(
                        "Password authentication doesn't work with ssh transport on libvirt backend, please copy your public ssh key to the remote machine."
                    )
Exemplo n.º 5
0
    def validate_rhsm_config(self):
        if self.smType != "rhsm":
            return

        for field in ["rhsm_hostname", "rhsm_username", "rhsm_password"]:
            if not getattr(self, field):
                raise InvalidOption("%s is required." %
                                    field.replace("rhsm_", "").title())

        for field in ["rhsm_port", "rhsm_proxy_port"]:
            self.validate_integer(field)
Exemplo n.º 6
0
    def validate_virt_config(self):
        self.validate_virt_type()
        if not self.server and self.type not in ['libvirt', 'vdsm', 'fake']:
            raise InvalidOption("Please specify URL of virtualization backend server.")

        if ((self.smType == 'rhsm') and (
                (self.type in ('esx', 'rhevm', 'hyperv', 'xen')) or
                (self.type == 'libvirt' and self.server))):
            if not self.env:
                raise InvalidOption("Please specify environment that '%s' belongs to." % self.type)
            elif not self.owner:
                raise InvalidOption("Please specify an organization.")

        if self.type == 'libvirt':
            if self.server:
                if ('ssh://' in self.server or '://' not in self.server) and self.password:
                    raise InvalidOption("Password authentication doesn't work with ssh transport on libvirt backend, please copy your public ssh key to the remote machine.")
            elif self.env:
                raise InvalidOption("Environment is not used in non-remote libvirt connection.")
            elif self.owner:
                raise InvalidOption("Owner is not used in non-remote libvirt connection.")
Exemplo n.º 7
0
 def validate_sm_type(self):
     if not self.smType:
         raise InvalidOption("Please specify where the host/guest associations should be reported.")
Exemplo n.º 8
0
 def validate_virt_type(self):
     if not self.type:
         raise InvalidOption("Please specify a virtualization backend.")
     elif self.type not in self.SUPPORTED_VIRT:
         raise InvalidOption("'%s' is not a supported virtualization backend." % self.type)
Exemplo n.º 9
0
 def humanize_type(self):
     for k, v in self.VIRT_MAP.iteritems():
         if v == self.type:
             return k
     raise InvalidOption("'%s' is not a supported virtualization backend." % self.type)
Exemplo n.º 10
0
 def validate_integer(self, field):
     val = getattr(self, field)
     if val and not val.isdigit():
         raise InvalidOption(
             "%s must be an integer." %
             field.replace("rhsm_", "").replace("sat_", "").title())