def __init__(self, args_str=None): self._args = None if not args_str: args_str = ' '.join(sys.argv[1:]) self._parse_args(args_str) if self._args.rec_ttl < 0 or self._args.rec_ttl > 2147483647: print 'Invalid ttl value ', self._args.rec_ttl return if not DnsProvisioner.is_valid_ipv4_address(self._args.api_server_ip): print 'Invalid IPv4 address ', self._args.api_server_ip return rec_name = self._args.rec_name if self._args.rec_type == 'A': vstr = self._args.rec_name if not DnsProvisioner.is_valid_ipv4_address(self._args.rec_data): print 'Invalid Ipv4 address ', self._args.rec_data return elif self._args.rec_type == 'AAAA': vstr = self._args.rec_name if not DnsProvisioner.is_valid_ipv6_address(self._args.rec_data): print 'Invalid Ipv6 address ', self._args.rec_data return elif self._args.rec_type == 'PTR': vstr = self._args.rec_data if (not rec_name.endswith('.in-addr.arpa') and not rec_name.endswith('.ip6.arpa')): if (not DnsProvisioner.is_valid_ipv4_address(rec_name) and not DnsProvisioner.is_valid_ipv6_address(rec_name)): print 'Invalid PTR record name ', self._args.rec_name return elif self._args.rec_type == 'NS' or self._args.rec_type == 'MX' or self._args.rec_type == 'CNAME': vstr = self._args.rec_name if not DnsProvisioner.is_valid_dns_name(vstr): print 'DNS name requirements are not satisfied by ', vstr return try: dp_obj = DnsProvisioner(self._args.admin_user, self._args.admin_password, self._args.admin_tenant_name, self._args.api_server_ip, self._args.api_server_port) except ConnectionError: print 'Connection to API server failed ' return dp_obj.add_virtual_dns_record(self._args.name, self._args.vdns_fqname, rec_name, self._args.rec_type, self._args.rec_class, self._args.rec_data, self._args.rec_ttl)
def __init__(self, args_str = None): self._args = None if not args_str: args_str = ' '.join(sys.argv[1:]) self._parse_args(args_str) if self._args.rec_ttl < 0 or self._args.rec_ttl > 2147483647: print 'Invalid ttl value ' , self._args.rec_ttl return if not DnsProvisioner.is_valid_ipv4_address(self._args.api_server_ip): print 'Invalid IPv4 address ', self._args.api_server_ip return rec_name = self._args.rec_name if self._args.rec_type == 'A': vstr = self._args.rec_name if not DnsProvisioner.is_valid_ipv4_address(self._args.rec_data): print 'Invalid Ipv4 address ', self._args.rec_data return elif self._args.rec_type == 'AAAA': vstr = self._args.rec_name if not DnsProvisioner.is_valid_ipv6_address(self._args.rec_data): print 'Invalid Ipv6 address ', self._args.rec_data return elif self._args.rec_type == 'PTR': vstr = self._args.rec_data if (not rec_name.endswith('.in-addr.arpa') and not rec_name.endswith('.ip6.arpa')): if (not DnsProvisioner.is_valid_ipv4_address(rec_name) and not DnsProvisioner.is_valid_ipv6_address(rec_name)): print 'Invalid PTR record name ', self._args.rec_name return elif self._args.rec_type == 'NS' or self._args.rec_type == 'MX' or self._args.rec_type == 'CNAME': vstr = self._args.rec_name if not DnsProvisioner.is_valid_dns_name(vstr): print 'DNS name requirements are not satisfied by ', vstr return try: dp_obj = DnsProvisioner(self._args.admin_user, self._args.admin_password, self._args.admin_tenant_name, self._args.api_server_ip, self._args.api_server_port) except ConnectionError: print 'Connection to API server failed ' return dp_obj.add_virtual_dns_record(self._args.name, self._args.vdns_fqname, rec_name, self._args.rec_type, self._args.rec_class, self._args.rec_data, self._args.rec_ttl)
def __init__(self, args_str=None): self._args = None if not args_str: args_str = ' '.join(sys.argv[1:]) self._parse_args(args_str) if not self._args.ttl: self._args.ttl = 86400 if self._args.ttl < 0 or self._args.ttl > 2147483647: print('Invalid ttl value ', self._args.ttl) return if not DnsProvisioner.is_valid_ipv4_address(self._args.api_server_ip): print('Invalid IPv4 address ', self._args.api_server_ip) return if not DnsProvisioner.is_valid_dns_name(self._args.dns_domain): print('Domain name does not satisfy DNS name requirements: ', self._args.dns_domain) return try: dp_obj = DnsProvisioner(self._args.admin_user, self._args.admin_password, self._args.admin_tenant_name, self._args.api_server_ip, self._args.api_server_port) except ConnectionError: print('Connection to API server failed ') return if self._args.dyn_updates: dyn_updates = True else: dyn_updates = False if self._args.external_visible: external_visible = True else: external_visible = False if self._args.reverse_resolution: reverse_resolution = True else: reverse_resolution = False dp_obj.add_virtual_dns(self._args.name, self._args.domain_name, self._args.dns_domain, dyn_updates, self._args.record_order, self._args.ttl, self._args.next_vdns, self._args.floating_ip_record, external_visible, reverse_resolution)
def __init__(self, args_str = None): self._args = None if not args_str: args_str = ' '.join(sys.argv[1:]) self._parse_args(args_str) if not self._args.ttl: self._args.ttl = 86400 if self._args.ttl < 0 or self._args.ttl > 2147483647: print 'Invalid ttl value ' , self._args.ttl return if not DnsProvisioner.is_valid_ipv4_address(self._args.api_server_ip): print 'Invalid IPv4 address ', self._args.api_server_ip return if not DnsProvisioner.is_valid_dns_name(self._args.dns_domain): print 'Domain name does not satisfy DNS name requirements: ', self._args.dns_domain return try: dp_obj = DnsProvisioner(self._args.admin_user, self._args.admin_password, self._args.admin_tenant_name, self._args.api_server_ip, self._args.api_server_port) except ConnectionError: print 'Connection to API server failed ' return if self._args.dyn_updates: dyn_updates = 'true' else: dyn_updates = 'false' if self._args.external_visible: external_visible = 'true' else: external_visible = 'false' if self._args.reverse_resolution: reverse_resolution = 'true' else: reverse_resolution = 'false' dp_obj.add_virtual_dns(self._args.name, self._args.domain_name, self._args.dns_domain, dyn_updates, self._args.record_order, self._args.ttl, self._args.next_vdns, self._args.floating_ip_record, external_visible, reverse_resolution)