Exemplo n.º 1
0
 def _build_error_urls(self):
     linked = netius.conf_suffix("_ERROR_URL")
     for name, error_url in netius.legacy.iteritems(linked):
         base = name[:-10].lower()
         base_dash = base.replace("_", "-")
         self.error_urls[base] = error_url
         self.error_urls[base_dash] = error_url
Exemplo n.º 2
0
 def _build_error_urls(self):
     linked = netius.conf_suffix("_ERROR_URL")
     for name, error_url in netius.legacy.iteritems(linked):
         base = name[:-10].lower()
         base_dash = base.replace("_", "-")
         self.error_urls[base] = error_url
         self.error_urls[base_dash] = error_url
Exemplo n.º 3
0
 def _build_redirect(self):
     linked = netius.conf_suffix("_REDIRECT")
     for name, host in netius.legacy.iteritems(linked):
         base = name[:-9].lower()
         base_dash = base.replace("_", "-")
         self.redirect[base] = host
         self.redirect[base_dash] = host
Exemplo n.º 4
0
 def _build_alias(self):
     linked = netius.conf_suffix("_ALIAS")
     for name, host in netius.legacy.iteritems(linked):
         base = name[:-6].lower()
         base_dash = base.replace("_", "-")
         self.alias[base] = host
         self.alias[base_dash] = host
Exemplo n.º 5
0
 def _build_redirect(self):
     linked = netius.conf_suffix("_REDIRECT")
     for name, host in netius.legacy.iteritems(linked):
         base = name[:-9].lower()
         base_dash = base.replace("_", "-")
         self.redirect[base] = host
         self.redirect[base_dash] = host
Exemplo n.º 6
0
 def _build_alias(self):
     linked = netius.conf_suffix("_ALIAS")
     for name, host in netius.legacy.iteritems(linked):
         base = name[:-6].lower()
         base_dash = base.replace("_", "-")
         self.alias[base] = host
         self.alias[base_dash] = host
Exemplo n.º 7
0
 def _build_passwords(self):
     linked = netius.conf_suffix("_PASSWORD")
     for name, password in netius.legacy.iteritems(linked):
         base = name[:-9].lower()
         base_dash = base.replace("_", "-")
         simple_auth = netius.SimpleAuth(password=password)
         self.auth[base] = simple_auth
         self.auth[base_dash] = simple_auth
Exemplo n.º 8
0
 def _build_passwords(self):
     linked = netius.conf_suffix("_PASSWORD")
     for name, password in netius.legacy.iteritems(linked):
         base = name[:-9].lower()
         base_dash = base.replace("_", "-")
         simple_auth = netius.SimpleAuth(password = password)
         self.auth[base] = simple_auth
         self.auth[base_dash] = simple_auth
Exemplo n.º 9
0
 def _build_redirect_ssl(self, alias=True):
     linked = netius.conf_suffix("_REDIRECT_SSL")
     for name, _force in netius.legacy.iteritems(linked):
         base = name[:-13].lower()
         base_dash = base.replace("_", "-")
         self.redirect[base] = (base, "https")
         self.redirect[base_dash] = (base_dash, "https")
         if not alias: continue
         for key, value in netius.legacy.iteritems(self.alias):
             is_match = value in (base, base_dash)
             if not is_match: continue
             self.redirect[key] = (key, "https")
Exemplo n.º 10
0
 def _build_redirect_ssl(self, alias = True):
     linked = netius.conf_suffix("_REDIRECT_SSL")
     for name, _force in netius.legacy.iteritems(linked):
         base = name[:-13].lower()
         base_dash = base.replace("_", "-")
         self.redirect[base] = (base, "https")
         self.redirect[base_dash] = (base_dash, "https")
         if not alias: continue
         for key, value in netius.legacy.iteritems(self.alias):
             is_match = value in (base, base_dash)
             if not is_match: continue
             self.redirect[key] = (key, "https")
Exemplo n.º 11
0
    def _build_hosts(self, alias=True):
        # tries to retrieve the complete set of configuration
        # values associated with the port suffix, this represents
        # the possible linked container addresses
        linked = netius.conf_suffix("_PORT")

        # iterates over the linked values, validating them and adding
        # them to the list of registered hosts
        for name, host in netius.legacy.iteritems(linked):
            # retrieves the name part of the configuration name
            # and converts it into lower cased value, note that
            # an extra dashed version is created, so that a proper
            # alias may be created for such naming
            base = name[:-5].lower()
            base_dash = base.replace("_", "-")

            # "builds" the name reference of the service and tries
            # to retrieve it from the configuration, it should exist
            # in case this port value represent a service
            name_ref = base.upper() + "_NAME"
            name_value = netius.conf(name_ref, None)
            if not name_value: continue

            # runs a series of validation on both the base and name
            # value to make sure that this value represents a valid
            # linked service/container
            # linked service/container (valid name reference found)
            if name.endswith("_ENV_PORT"): continue
            if not name.find("_ENV_") == -1: continue
            if base[-1].isdigit() and name_value[-1].isdigit(): continue

            # validates that the provided host is a valid URL value and
            # if that's not the case continues the loop (ignores)
            if not self._valid_url(host): continue

            # replaces the prefix of the reference (assumes HTTP) and
            # then adds the base value to the registered hosts
            host = host.replace("tcp://", "http://")
            host = str(host)
            self.hosts[base] = host

            # validates that the dashed version of the name is not the
            # same as the base one (at least one underscore) and if that's
            # not the case skips the current iteration
            if base == base_dash: continue

            # checks if the alias based registration is enabled and adds
            # the dashed version as an alias for such case or as an host
            # otherwise (static registration)
            if alias: self.alias[base_dash] = base
            else: self.hosts[base_dash] = host
Exemplo n.º 12
0
    def _build_hosts(self, alias = True):
        # tries to retrieve the complete set of configuration
        # values associated with the port suffix, this represents
        # the possible linked container addresses
        linked = netius.conf_suffix("_PORT")

        # iterates over the linked values, validating them and adding
        # them to the list of registered hosts
        for name, host in netius.legacy.iteritems(linked):
            # retrieves the name part of the configuration name
            # and converts it into lower cased value, note that
            # an extra dashed version is created, so that a proper
            # alias may be created for such naming
            base = name[:-5].lower()
            base_dash = base.replace("_", "-")

            # "builds" the name reference of the service and tries
            # to retrieve it from the configuration, it should exist
            # in case this port value represent a service
            name_ref = base.upper() + "_NAME"
            name_value = netius.conf(name_ref, None)
            if not name_value: continue

            # runs a series of validation on both the base and name
            # value to make sure that this value represents a valid
            # linked service/container
            # linked service/container (valid name reference found)
            if name.endswith("_ENV_PORT"): continue
            if not name.find("_ENV_") == -1: continue
            if base[-1].isdigit() and name_value[-1].isdigit(): continue

            # validates that the provided host is a valid URL value and
            # if that's not the case continues the loop (ignores)
            if not self._valid_url(host): continue

            # replaces the prefix of the reference (assumes HTTP) and
            # then adds the base value to the registered hosts
            host = host.replace("tcp://", "http://")
            host = str(host)
            self.hosts[base] = host

            # validates that the dashed version of the name is not the
            # same as the base one (at least one underscore) and if that's
            # not the case skips the current iteration
            if base == base_dash: continue

            # checks if the alias based registration is enabled and adds
            # the dashed version as an alias for such case or as an host
            # otherwise (static registration)
            if alias: self.alias[base_dash] = base
            else: self.hosts[base_dash] = host
Exemplo n.º 13
0
    def _build_regex(self, token = "$", sort = True):
        # retrieves the complete set of configuration values with the
        # regex suffix so that they are going to be used for the creation
        # of the regex rules (as expected)
        linked = netius.conf_suffix("_REGEX")

        # retrieves the complete set of names from the linked items and then
        # in case the sort flag is set sorts their values (proper order)
        names = netius.legacy.keys(linked)
        if sort: names.sort()

        # iterates over the complete set of linked regex values splitting
        # the values around the proper token and adding them to the regex
        for name in names:
            value = linked[name]
            value_s = value.split(token, 1)
            if not len(value_s) == 2: continue
            regex, target = value_s
            rule = (re.compile(regex), target)
            self.regex.append(rule)