def _create_dns_list(self, dns): """ :param dns: :return: """ if not dns: return None dns_list = [] if isinstance(dns, six.string_types): if is_valid_ip(dns): dns_list.append(dns) else: raise ValueError("dns is required to be a valid ip adress. {0} was passed.".format(dns)) elif isinstance(dns, list): for dns_entry in dns: if is_valid_ip(dns_entry): dns_list.append(dns_entry) else: raise ValueError("dns is required to be a valid ip adress. {0} was passed.".format(dns)) else: raise ValueError("dns and dns search must be a list or string. {0} was passed.".format(dns)) return dns_list
def _create_dns_list(self, dns): """ :param dns: :return: """ if not dns: return None dns_list = [] if isinstance(dns, six.string_types): if is_valid_ip(dns): dns_list.append(dns) else: raise ValueError( "dns is required to be a valid ip adress. {0} was passed.". format(dns)) elif isinstance(dns, list): for dns_entry in dns: if is_valid_ip(dns_entry): dns_list.append(dns_entry) else: raise ValueError( "dns is required to be a valid ip adress. {0} was passed.". format(dns)) else: raise ValueError( "dns and dns search must be a list or string. {0} was passed.". format(dns)) return dns_list
def extra_hosts(self, value): """ :param value: :return None: """ if value is None: self._extra_hosts = value elif isinstance(value, list): # TODO: better validation self._extra_hosts = value elif isinstance(value, dict): converted_extra_hosts = [] for k, v in sorted(six.iteritems(value)): if not is_valid_hostname(k): raise ValueError( "each key in extra hosts is required to be a valid hostname. {0} was passed" .format(k)) if not is_valid_ip(v): raise ValueError( "each value in extra hosts is required to be a valid ip address. {0} was passed" .format(v)) converted_extra_hosts.append('{0}:{1}'.format(k, v)) self._extra_hosts = converted_extra_hosts else: raise TypeError( "extra hosts must be a dict, list, or None. {0} was passed". format(value))
def extra_hosts(self, value): """ :param value: :return None: """ if value is None: self._extra_hosts = value elif isinstance(value, list): # TODO: better validation self._extra_hosts = value elif isinstance(value, dict): converted_extra_hosts = [] for k, v in sorted(six.iteritems(value)): if not is_valid_hostname(k): raise ValueError("each key in extra hosts is required to be a valid hostname. {0} was passed".format(k)) if not is_valid_ip(v): raise ValueError("each value in extra hosts is required to be a valid ip address. {0} was passed".format(v)) converted_extra_hosts.append('{0}:{1}'.format(k, v)) self._extra_hosts = converted_extra_hosts else: raise TypeError("extra hosts must be a dict, list, or None. {0} was passed".format(value))