コード例 #1
0
    def validate_options(self, options):
        # TODO: Rewrite the error messages to be more dbus specific
        error_msg = None
        if self.is_registered() and not options.get('force', False):
            error_msg = _("This system is already registered. Add force to options to override.")
        elif options.get('name') == '':
            error_msg = _("Error: system name can not be empty.")
        elif 'consumerid' in options and 'force' in options:
            error_msg = _("Error: Can not force registration while attempting to recover registration with consumerid. Please use --force without --consumerid to re-register or use the clean command and try again without --force.")

        # If 'activation_keys' already exists in the dictionary, leave it.  Otherwise, set to None.
        if options.get('activation_keys', None):
            # 746259: Don't allow the user to pass in an empty string as an activation key
            if '' == options['activation_keys']:
                error_msg = _("Error: Must specify an activation key")
            elif 'username' in options:
                error_msg = _("Error: Activation keys do not require user credentials.")
            elif 'consumerid' in options:
                error_msg = _("Error: Activation keys can not be used with previously registered IDs.")
            elif 'environment' in options:
                error_msg = _("Error: Activation keys do not allow environments to be specified.")
        else:
            if 'username' not in options or 'password' not in options:
                error_msg = _("Error: Missing username or password.")

        if error_msg:
            raise exceptions.Failed(msg=error_msg)

        if 'name' not in options:
            options['name'] = socket.gethostname()

        return options
コード例 #2
0
 def Stop(self, sender=None):
     with self.lock:
         if self.server:
             self.server.shutdown()
             self.server = None
             log.debug("Stopped DomainSocketServer")
             return True
         else:
             raise exceptions.Failed("No domain socket server is running")
コード例 #3
0
    def validate_only_proxy_options(self, proxy_options):
        error_msg = None
        for k in six.iterkeys(proxy_options):
            if k not in ['proxy_hostname', 'proxy_port', 'proxy_user', 'proxy_password', 'no_proxy']:
                error_msg = "Error: %s is not a valid proxy option" % k
                break

        if error_msg:
            raise exceptions.Failed(msg=error_msg)

        return proxy_options
コード例 #4
0
 def Stop(self, locale, sender=None):
     locale = dbus_utils.dbus_to_python(locale, expected_type=str)
     Locale.set(locale)
     with self.lock:
         if self.server:
             self.server.shutdown()
             self.server = None
             log.debug("Stopped DomainSocketServer")
             return True
         else:
             raise exceptions.Failed("No domain socket server is running")
コード例 #5
0
    def validate_only_proxy_options(self, proxy_options):
        error_msg = None
        for k in proxy_options.keys():
            if k not in [
                    "proxy_hostname", "proxy_port", "proxy_user",
                    "proxy_password", "no_proxy"
            ]:
                error_msg = "Error: %s is not a valid proxy option" % k
                break

        if error_msg:
            raise exceptions.Failed(msg=error_msg)

        return proxy_options