Пример #1
0
 def allowed_addresses(self):
     if self._values['allowed_addresses'] is None:
         return None
     result = []
     addresses = self._values['allowed_addresses']
     if isinstance(addresses, string_types):
         if addresses in ['', 'none']:
             return []
         else:
             addresses = [addresses]
     if len(addresses) == 1 and addresses[0] in ['default', '']:
         result = ['127.0.0.0/8']
         return result
     for address in addresses:
         try:
             # Check for valid IPv4 or IPv6 entries
             ip_network(u'%s' % str(address))
             result.append(address)
         except ValueError:
             # else fallback to checking reasonably well formatted hostnames
             if is_valid_hostname(address):
                 result.append(str(address))
                 continue
             raise F5ModuleError(
                 "The provided 'allowed_address' value {0} is not a valid IP or hostname".format(address)
             )
     result = list(set(result))
     result.sort()
     return result
Пример #2
0
 def allowed_addresses(self):
     if self._values['allowed_addresses'] is None:
         return None
     result = []
     addresses = self._values['allowed_addresses']
     if isinstance(addresses, string_types):
         if addresses in ['', 'none']:
             return []
         else:
             addresses = [addresses]
     if len(addresses) == 1 and addresses[0] in ['default', '']:
         result = ['127.0.0.0/8']
         return result
     for address in addresses:
         try:
             # Check for valid IPv4 or IPv6 entries
             netaddr.IPNetwork(address)
             result.append(address)
         except netaddr.core.AddrFormatError:
             # else fallback to checking reasonably well formatted hostnames
             if is_valid_hostname(address):
                 result.append(str(address))
                 continue
             raise F5ModuleError(
                 "The provided 'allowed_address' value {0} is not a valid IP or hostname".format(address)
             )
     result = list(set(result))
     result.sort()
     return result
Пример #3
0
 def remote_host(self):
     if is_valid_ip(self._values['remote_host']):
         return self._values['remote_host']
     elif is_valid_hostname(self._values['remote_host']):
         return str(self._values['remote_host'])
     raise F5ModuleError(
         "The provided 'remote_host' is not a valid IP or hostname")
Пример #4
0
 def _set_host_by_name(self):
     if is_valid_ip(self.want.name):
         self.want.update({'fqdn': None, 'address': self.want.name})
     else:
         if not is_valid_hostname(self.want.name):
             raise F5ModuleError(
                 "'name' is neither a valid IP address or FQDN name.")
         self.want.update({'fqdn': self.want.name, 'address': None})
Пример #5
0
 def _set_host_by_name(self):
     try:
         netaddr.IPAddress(self.want.name)
         self.want.update({'fqdn': None, 'address': self.want.name})
     except netaddr.AddrFormatError:
         if not is_valid_hostname(self.want.name):
             raise F5ModuleError(
                 "'name' is neither a valid IP address or FQDN name.")
         self.want.update({'fqdn': self.want.name, 'address': None})
Пример #6
0
 def local_host_name(self):
     if self._values['local_host_name'] is None:
         return None
     if is_valid_ip(self._values['local_host_name']):
         return self._values['local_host_name']
     elif is_valid_hostname(self._values['local_host_name']):
         # else fallback to checking reasonably well formatted hostnames
         return str(self._values['local_host_name'])
     raise F5ModuleError(
         "The provided 'local_host_name' value {0} is not a valid IP or hostname"
         .format(str(self._values['local_host_name'])))
Пример #7
0
 def fqdn(self):
     result = {}
     if self.fqdn_auto_populate:
         result['autopopulate'] = 'enabled'
     else:
         result['autopopulate'] = 'disabled'
     if self._values['fqdn'] is None:
         return result
     if not is_valid_hostname(self._values['fqdn']):
         raise F5ModuleError(
             "The specified 'fqdn' is not a valid hostname.")
     result['tmName'] = self._values['fqdn']
     return result
Пример #8
0
 def local_host_name(self):
     if self._values['local_host_name'] is None:
         return None
     try:
         # Check for valid IPv4 or IPv6 entries
         netaddr.IPNetwork(self._values['local_host_name'])
         return self._values['local_host_name']
     except netaddr.core.AddrFormatError:
         # else fallback to checking reasonably well formatted hostnames
         if is_valid_hostname(self._values['local_host_name']):
             return str(self._values['local_host_name'])
         raise F5ModuleError(
             "The provided 'local_host_name' value {0} is not a valid IP or hostname"
             .format(address))
Пример #9
0
 def local_host_name(self):
     if self._values['local_host_name'] is None:
         return None
     try:
         # Check for valid IPv4 or IPv6 entries
         netaddr.IPNetwork(self._values['local_host_name'])
         return self._values['local_host_name']
     except netaddr.core.AddrFormatError:
         # else fallback to checking reasonably well formatted hostnames
         if is_valid_hostname(self._values['local_host_name']):
             return str(self._values['local_host_name'])
         raise F5ModuleError(
             "The provided 'local_host_name' value {0} is not a valid IP or hostname".format(
                 str(self._values['local_host_name'])
             )
         )