當前位置: 首頁>>代碼示例>>Python>>正文


Python DynectRest.execute方法代碼示例

本文整理匯總了Python中dynect.DynectDNS.DynectRest.execute方法的典型用法代碼示例。如果您正苦於以下問題:Python DynectRest.execute方法的具體用法?Python DynectRest.execute怎麽用?Python DynectRest.execute使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在dynect.DynectDNS.DynectRest的用法示例。


在下文中一共展示了DynectRest.execute方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: point_dns_to_stack

# 需要導入模塊: from dynect.DynectDNS import DynectRest [as 別名]
# 或者: from dynect.DynectDNS.DynectRest import execute [as 別名]
def point_dns_to_stack(environment, stack_type, name):
    import sys
    from dynect.DynectDNS import DynectRest # sudo pip install https://github.com/dyninc/Dynect-API-Python-Library/zipball/master
    
    rest_iface = DynectRest()

    if 'AWS_CONFIG_DIR' in os.environ:
        user_data_filename = os.path.join(os.environ['AWS_CONFIG_DIR'], 'dynect.json')
    else:
        user_data_filename = 'config/dynect.json'

    with open(user_data_filename, 'r') as f:
        dynect_credentials = json.load(f)
    
    # Log in
    response = rest_iface.execute('/Session/', 'POST', dynect_credentials)
    
    if response['status'] != 'success':
      sys.exit("Incorrect credentials")
    
    # Perform action
    response = rest_iface.execute('/CNAMERecord/anosrep.org/www.anosrep.org/', 'GET')
    
    # Log out, to be polite
    rest_iface.execute('/Session/', 'DELETE')
開發者ID:6a68,項目名稱:identity-ops,代碼行數:27,代碼來源:stack_control.py

示例2: update_dynect

# 需要導入模塊: from dynect.DynectDNS import DynectRest [as 別名]
# 或者: from dynect.DynectDNS.DynectRest import execute [as 別名]
def update_dynect(rules, ip, customername, username, password, recover = False):
        """
        Check id there needs to be updates made and if so call update record for each one
        """
        if ip in rules:
                dynect = DynectRest()
                login(customername, username, password, dynect)
                try:
                        for match in rules[ip]:
                                if recover:
                                        if update_record(match["zone"], match["fqdn"], match["secondary"], ip, dynect):
                                                print match["fqdn"] + " has recoverd to IP address " + ip
                                else:
                                        if update_record(match["zone"], match["fqdn"], ip, match["secondary"], dynect):
                                                print match["fqdn"] + " has failed over to IP address " + match["secondary"]
                except  Exception:
                        print Exception
                        traceback.print_exc()
                        rules = {}

                finally:
                        # Log out, to be polite
                        dynect.execute('/Session/', 'DELETE')
開發者ID:dyninc,項目名稱:DNS-Syslog_Responder-Python,代碼行數:25,代碼來源:failover_listener.py

示例3: queryDynect

# 需要導入模塊: from dynect.DynectDNS import DynectRest [as 別名]
# 或者: from dynect.DynectDNS.DynectRest import execute [as 別名]
    def queryDynect(self):

        LOG.info('Query DynECT to get the state of GSLBs')
        try:
            rest_iface = DynectRest()
            if CONF.debug and CONF.use_stderr:
                rest_iface.verbose = True

            # login
            credentials = {
                'customer_name': CONF.dynect_customer,
                'user_name': CONF.dynect_username,
                'password': CONF.dynect_password,
            }
            LOG.debug('credentials = %s', credentials)
            response = rest_iface.execute('/Session/', 'POST', credentials)

            if response['status'] != 'success':
                LOG.error('Failed to create API session: %s', response['msgs'][0]['INFO'])
                self.updating = False
                return

            # Discover all the Zones in DynECT
            response = rest_iface.execute('/Zone/', 'GET')
            LOG.debug('/Zone/ => %s', json.dumps(response, indent=4))
            zone_resources = response['data']

            # Discover all the LoadBalancers
            for resource in zone_resources:
                zone = resource.split('/')[3]  # eg. /REST/Zone/guardiannews.com/
                response = rest_iface.execute('/LoadBalance/' + zone + '/', 'GET')
                LOG.debug('/LoadBalance/%s/ => %s', zone, json.dumps(response, indent=4))
                gslb = response['data']

                # Discover LoadBalancer pool information.
                for lb in gslb:
                    fqdn = lb.split('/')[4]  # eg. /REST/LoadBalance/guardiannews.com/id.guardiannews.com/
                    response = rest_iface.execute('/LoadBalance/' + zone + '/' + fqdn + '/', 'GET')
                    LOG.debug('/LoadBalance/%s/%s/ => %s', zone, fqdn, json.dumps(response, indent=4))
                    status = response['data']['status']
                    monitor = response['data']['monitor']
                    self.info['gslb-' + fqdn] = {'status': status, 'gslb': fqdn, 'rawData': monitor}

                    for pool in response['data']['pool']:
                        name = '%s-%s' % (fqdn, pool['label'].replace(' ', '-'))
                        status = '%s:%s:%s' % (pool['status'], pool['serve_mode'], pool['weight'])
                        self.info['pool-' + name] = {'status': status, 'gslb': fqdn, 'rawData': pool}

            LOG.info('Finished object discovery query.')
            LOG.debug('GSLBs and Pools: %s', json.dumps(self.info, indent=4))

            # logout
            rest_iface.execute('/Session/', 'DELETE')

        except Exception, e:
            LOG.error('Failed to discover GSLBs: %s', e)
            self.updating = False
開發者ID:MailOnline,項目名稱:alerta,代碼行數:59,代碼來源:daemon.py

示例4: queryDynect

# 需要導入模塊: from dynect.DynectDNS import DynectRest [as 別名]
# 或者: from dynect.DynectDNS.DynectRest import execute [as 別名]
def queryDynect():

    global info

    logging.info('Quering DynECT to get the state of GSLBs')

    # Creating DynECT API session 
    try:

        rest_iface = DynectRest()

        response = rest_iface.execute('/Session/', 'POST', config)

        if response['status'] != 'success':
            logging.error('Incorrect credentials')
            sys.exit(1)

        # Discover all the Zones in DynECT
        response = rest_iface.execute('/Zone/', 'GET')
        zone_resources = response['data']

        # Discover all the LoadBalancers
        for item in zone_resources:
            zone = item.split('/')[3]
            response = rest_iface.execute('/LoadBalance/'+zone+'/', 'GET')
            gslb = response['data']

            # Discover LoadBalancer pool information.
            for lb in gslb:
                fqdn = lb.split('/')[4]
                response = rest_iface.execute('/LoadBalance/'+zone+'/'+fqdn+'/', 'GET')
                info['gslb-'+fqdn] = response['data']['status'], 'gslb-'+fqdn

                for i in response['data']['pool']:
                    name = '%s-%s' % (fqdn, i['label'].replace(' ','-'))
                    state = '%s:%s:%s' % (i['status'], i['serve_mode'], i['weight'])
                    parent = 'gslb-'+fqdn
                    info['pool-'+name] = state, parent

        logging.info('Finish quering and object discovery.')
        logging.info('GSLBs and Pools: %s', json.dumps(info))

        rest_iface.execute('/Session/', 'DELETE')

    except Exception, e:
        logging.error('Failed to discover GSLBs: %s', e)
        pass
開發者ID:DiegoVazquezNanini,項目名稱:alerta,代碼行數:49,代碼來源:alert-dynect.py

示例5: DynectRest

# 需要導入模塊: from dynect.DynectDNS import DynectRest [as 別名]
# 或者: from dynect.DynectDNS.DynectRest import execute [as 別名]
rest_iface = DynectRest()

# Inputs from user for login to the DynECT API.
customer = raw_input("Enter your Customer Name: ")
username = raw_input("Enter your Username: ")
password = raw_input("Enter your password: ")
    
# Declaring the credentials for logging into the DynECT API.
login_arg = {
    'customer_name': customer,
    'user_name': username,
    'password': password,
    }
    
# Sending the POST command to the DynECT API for login proposes.
response = rest_iface.execute('/Session/', 'POST', login_arg)
    
# Checking to see if the Login to the DynECT API is successful.
if response['status'] != 'success':
    sys.exit("Incorrect credentials")
elif response['status'] == 'success':
    print 'Login Successful to DynECT API.'

# Inputs from user to path to Zone Files.
path = raw_input("Enter your path to your Zone Files: ")

# Going through the Zone Files Directory.
for zoneFileName in os.listdir(path):

    zone_path = os.path.join(path, zoneFileName)
開發者ID:dbrenner4,項目名稱:DNS,代碼行數:32,代碼來源:BulkImportZoneFiles.py

示例6: DynectRest

# 需要導入模塊: from dynect.DynectDNS import DynectRest [as 別名]
# 或者: from dynect.DynectDNS.DynectRest import execute [as 別名]
from dynect.DynectDNS import DynectRest
from pprint import PrettyPrinter
import sys

api = DynectRest()

# We need to login
print "Logging in to API"

args = {
        'customer_name': 'ciscocloud',
        'user_name': 'UserName',
        'password': 'UserAPIKey',
}

response = api.execute('/REST/Session/', 'POST', args)

if response['status'] != 'success':
        pretty = PrettyPrinter()
        msg = "Login to API failed: %s" % pretty.pformat(response)
        sys.exit(msg)
"""
zones = {
	'rname' : 'www.gslb.com',
	'ttl' : '3600',
	'zone' : 'gslb.com',
}
"""
report_data = {
	'breakdown' : 'zones',
	'end_ts' : '1446535242',
開發者ID:mady4ever,項目名稱:GSLB,代碼行數:33,代碼來源:create_qps_report.py

示例7: DynectRest

# 需要導入模塊: from dynect.DynectDNS import DynectRest [as 別名]
# 或者: from dynect.DynectDNS.DynectRest import execute [as 別名]
import sys
from dynect.DynectDNS import DynectRest
from pprint import PrettyPrinter

rest_iface = DynectRest()

# Log in
print "Logging in to API"
arguments = {
    'customer_name': 'ciscocloud',
    'user_name': 'UserName',  
    'password': 'UserAPIKey',
}
# ciscocloud UserName Cisco!gs1b
response = rest_iface.execute('/Session/', 'POST', arguments)

if response['status'] != 'success':
    sys.exit("Incorrect credentials")

# Perform action
print "Get AF services as authentication succeded"

response = rest_iface.execute('/REST/Failover/gslb.com/www.gslb.com', 'GET')
if response['status'] != 'success':
	pretty = PrettyPrinter()
	msg = "Getting AF service failed: %s " % pretty.pformat(response)
	sys.exit(msg)

zone_resources = response['data']

print "Getting AF succeded"
開發者ID:mady4ever,項目名稱:GSLB,代碼行數:33,代碼來源:get_specific_active_failover_service.py

示例8: DynectRest

# 需要導入模塊: from dynect.DynectDNS import DynectRest [as 別名]
# 或者: from dynect.DynectDNS.DynectRest import execute [as 別名]
from dynect.DynectDNS import DynectRest
from pprint import PrettyPrinter
import sys

api = DynectRest()

# We need to login
print "Logging in to API"

args = {
        'customer_name': 'ciscocloud',
        'user_name': 'UserName',
        'password': 'UserAPIKey',
}

response = api.execute('/REST/Session/', 'POST', args)

if response['status'] != 'success':
        pretty = PrettyPrinter()
        msg = "Login to API failed: %s" % pretty.pformat(response)
        sys.exit(msg)

traffic_srv_id = '54eHrIuDkcKpg9DdnmrThgpGCsI'

response_pool= {
	 'label':'AsiaDC',
	 'publish' : 'Y'    # Mahendra - always publish otherwise it will not be seen on the UI, as changes will get discarded.
}
"""
response_pool= {
	'serviceid' : traffic_srv_id,
開發者ID:mady4ever,項目名稱:GSLB,代碼行數:33,代碼來源:create_response_pool.py

示例9: DynectRest

# 需要導入模塊: from dynect.DynectDNS import DynectRest [as 別名]
# 或者: from dynect.DynectDNS.DynectRest import execute [as 別名]
import sys
from dynect.DynectDNS import DynectRest
from pprint import PrettyPrinter

rest_iface = DynectRest()

# Log in
print "Logging in to API"
arguments = {
    'customer_name': 'ciscocloud',
    'user_name': 'UserName',  
    'password': 'UserAPIKey',
}
# ciscocloud UserName Cisco!gs1b
response = rest_iface.execute('/Session/', 'POST', arguments)

if response['status'] != 'success':
    sys.exit("Incorrect credentials")

# Perform action
print "Get traffic director service as authentication succeded"

services = {
	'label' : 'Test*',
	'detail' : 'true',	
}
response = rest_iface.execute('/REST/DSF/', 'GET', services)

if response['status'] != 'success':
	pretty = PrettyPrinter()
	msg = "Getting traffic director service : %s " % pretty.pformat(response)
開發者ID:mady4ever,項目名稱:GSLB,代碼行數:33,代碼來源:get_traffic_director_service.py

示例10: DynectRest

# 需要導入模塊: from dynect.DynectDNS import DynectRest [as 別名]
# 或者: from dynect.DynectDNS.DynectRest import execute [as 別名]
import sys, getpass, string
from dynect.DynectDNS import DynectRest   # API module available from dynect site

print "Username: ",
user = sys.stdin.readline(80).rstrip()
passwd = getpass.getpass("Password: ")
login_args = { 'customer_name': 'mycompany',
               'user_name': user,
               'password': passwd, }

zones = [ u'/AllRecord/mycompany.net/', u'/AllRecord/mycompany.co.jp/', 
          u'/AllRecord/mycompany.com/', ]

try:
    rest_iface = DynectRest()
    response = rest_iface.execute('/Session/', 'POST', login_args)
    if response['status'] != 'success':
        sys.exit("Incorrect credentials")
    
    for zone in zones:
        response = rest_iface.execute(zone, 'GET')
        zone_resources = response['data']
        print "\nrecord_type\trecord\t\ttarget"
        for resource in zone_resources:
            res = rest_iface.execute(resource, 'GET')
            rtype = string.lower(res['data']['record_type'])
            if rtype == 'cname':
                print "%s\t%s\t\t%s" % \
                      ( res['data']['record_type'], res['data']['fqdn'], res['data']['rdata'][rtype] )
            elif rtype == 'a':
                print "%s\t%s\t\t%s" % \
開發者ID:dcherry-calamp,項目名稱:linux-scripts,代碼行數:33,代碼來源:dynect-dump.py

示例11: point_dns_to_stack

# 需要導入模塊: from dynect.DynectDNS import DynectRest [as 別名]
# 或者: from dynect.DynectDNS.DynectRest import execute [as 別名]
def point_dns_to_stack(region, stack_type, application, name):
    import sys
    import os
    import json
    import boto.ec2.elb

    from dynect.DynectDNS import DynectRest  # sudo pip install https://github.com/dyninc/Dynect-API-Python-Library/zipball/master

    if stack_type == 'stage':
        zone = 'anosrep.org'
        if application == 'persona':
            elbs = {'firefoxos.anosrep.org': 'w-anosrep-org',
                    'login.anosrep.org': 'w-anosrep-org',
                    'www.anosrep.org': 'w-anosrep-org',
                    'static.login.anosrep.org': 'w-login-anosrep-org',
                    'verifier.login.anosrep.org': 'w-login-anosrep-org'}
        elif application == 'bridge-yahoo':
            elbs = {'yahoo.login.anosrep.org': 'yahoo-login-anosrep-org'}
        elif application == 'bridge-gmail':
            elbs = {'gmail.login.anosrep.org': 'gmail-login-anosrep-org'}
        else:
            raise ValueError("application value is bad : %s" % application)
    elif stack_type == 'prod':
        zone = 'persona.org'
        if application == 'persona':
            elbs = {'login.persona.org': 'persona-org',
                    'www.persona.org': 'persona-org'}
        elif application == 'bridge-yahoo':
            elbs = {'yahoo.login.persona.org': 'yahoo-login-persona-org'}
        elif application == 'bridge-gmail':
            elbs = {'gmail.login.persona.org': 'gmail-login-persona-org'}
        else:
            raise ValueError("application value is bad : %s" % application)
    new_names = {}

    # TODO : This doesn't work for prod because we need to inject multiple regions into traffic mangement
    
    conn_elb = boto.ec2.elb.connect_to_region(region)
    load_balancers = conn_elb.get_all_load_balancers(load_balancer_names=['%s-%s' % (x, name) for x in set(elbs.values())])
    for load_balancer in load_balancers:
        new_names['-'.join(load_balancer.name.split('-')[:-1])] = load_balancer.dns_name

    rest_iface = DynectRest()
    if 'AWS_CONFIG_DIR' in os.environ:
        user_data_filename = os.path.join(os.environ['AWS_CONFIG_DIR'], 'dynect.json')
    else:
        user_data_filename = 'config/dynect.json'

    with open(user_data_filename, 'r') as f:
        dynect_credentials = json.load(f)
    
    # Log in
    response = rest_iface.execute('/Session/', 'POST', dynect_credentials)
    
    if response['status'] != 'success':
      sys.exit("Incorrect credentials")
    
    for record in elbs.keys():
        # Get record_id
        uri = '/CNAMERecord/%s/%s/' % (zone, record)
        response = rest_iface.execute(uri, 'GET')
        record_id = response['data'][0].split('/')[-1]
        uri = uri + record_id + '/'
    
        # Get current record
        response = rest_iface.execute(uri, 'GET')
        old_name = response['data']['rdata']['cname']
        
        # Set new record
        new_name = new_names[elbs[record]] + '.'
        arguments = {'rdata': {'cname': new_name}}
        logging.info('calling "%s" to change the record from "%s" to "%s"' % (uri, old_name, new_name))
        response = rest_iface.execute(uri, 'PUT', arguments)
        logging.info(json.dumps(response['msgs']))

    # Publish the new zone
    response = rest_iface.execute('/Zone/%s' % zone, 'PUT', {'publish': 1})
    logging.info('new zone published with updates at serial number %s' % response['data']['serial'])

    # Log out, to be polite
    rest_iface.execute('/Session/', 'DELETE')
開發者ID:jrgm,項目名稱:identity-ops,代碼行數:83,代碼來源:stack_control.py

示例12: DynectRest

# 需要導入模塊: from dynect.DynectDNS import DynectRest [as 別名]
# 或者: from dynect.DynectDNS.DynectRest import execute [as 別名]
from dynect.DynectDNS import DynectRest
from pprint import PrettyPrinter
import sys

api = DynectRest()

# We need to login
print "Logging in to API"

args = {
        'customer_name': 'ciscocloud',
        'user_name': 'UserName',
        'password': 'UserAPIKey',
}

response = api.execute('/REST/Session/', 'POST', args)

if response['status'] != 'success':
        pretty = PrettyPrinter()
        msg = "Login to API failed: %s" % pretty.pformat(response)
        sys.exit(msg)

nodes = [ { 'zone' : 'gslb.com' , 'node' : 'www.gslb.com',}]
criteria = {
	'geoip' : { 'country' : [ 'US' ] }
	}
records = [
{
	'label' : 'USEast007',
	'weight' : '5',
	'automation' : 'auto',
開發者ID:mady4ever,項目名稱:GSLB,代碼行數:33,代碼來源:create_traffic_director_service.py

示例13: DynectRest

# 需要導入模塊: from dynect.DynectDNS import DynectRest [as 別名]
# 或者: from dynect.DynectDNS.DynectRest import execute [as 別名]
from dynect.DynectDNS import DynectRest
from pprint import PrettyPrinter
import sys

api = DynectRest()

# We need to login
print "Logging in to API"

args = {
        'customer_name': 'ciscocloud',
        'user_name': 'UserName',
        'password': 'UserAPIKey',
}

response = api.execute('/REST/Session/', 'POST', args)

if response['status'] != 'success':
        pretty = PrettyPrinter()
        msg = "Login to API failed: %s" % pretty.pformat(response)
        sys.exit(msg)

A_srv_name = 'www3.gslb.com'

arecord = { 'fqdn' : 'www3.gslb.com', 'zone' : 'gslb.com', }
print "Deleting A Record"

url = "/REST/ARecord/gslb.com/%s" % A_srv_name

response = api.execute(url,'DELETE',arecord);
開發者ID:mady4ever,項目名稱:GSLB,代碼行數:32,代碼來源:delete_A_record.py

示例14: get_creds

# 需要導入模塊: from dynect.DynectDNS import DynectRest [as 別名]
# 或者: from dynect.DynectDNS.DynectRest import execute [as 別名]
    for uri in response['data']:
        dsf = dyn_iface.execute( uri, 'GET')
        for node_dict in dsf['data']['nodes']:
            if node_dict['fqdn'] == fqdn:
                return uri
    return 0

#read API credentials from file
try:
    creds = get_creds()
except:
    sys.exit('Unable to open configuation file: config.cfg')

dyn_iface = DynectRest()
# Log in
response = dyn_iface.execute('/Session/', 'POST', creds)
if response['status'] != 'success':
    sys.exit("Unable to Login to DynECT DNS API.  Please check credentials in config.cfg")

#obtain parent uri for DSF service by FQDN
#also possible to get DSF directly by label
dsf_uri = get_dsf_byfqdn( dyn_iface, 'example.dsfexample.com' ) 
#get full description of service using URI
dsf_desc = dyn_iface.execute(dsf_uri, 'GET')

#grab IDs from service description
#can be used later to direclty access service or other URIs
dsf_id = dsf_desc['data']['service_id']

#at this point we could look at rulesets->response pools->records by parsing the DSF object
#instead we will use paramaters to enumerate specific records for demonstration purposes
開發者ID:StoneTools,項目名稱:DNS-TD_Example,代碼行數:33,代碼來源:TD_update.py

示例15: TestDynDns

# 需要導入模塊: from dynect.DynectDNS import DynectRest [as 別名]
# 或者: from dynect.DynectDNS.DynectRest import execute [as 別名]
class TestDynDns():

    def setUp(self):
        self.customer_name = os.environ.get('TEST_DYNDNS_CUSTOMER_NAME')
        self.user_name = os.environ.get('TEST_DYNDNS_USER_NAME')
        self.password = os.environ.get('TEST_DYNDNS_PASSWORD')
        self.zone = os.environ.get('TEST_DYNDNS_ZONE')
        if not all((self.customer_name, self.user_name, self.password, self.zone)):
            raise SkipTest('Please set env variables TEST_DYNDNS_CUSTOMER_NAME, TEST_DYNDNS_USER_NAME, TEST_DYNDNS_PASSWORD and TEST_DYNDNS_ZONE.')
        arguments = {
            'customer_name': self.customer_name,
            'user_name': self.user_name,
            'password': self.password,
        }
        self.rest_iface = DynectRest()
        self.rest_iface.execute('/Session/', 'POST', arguments)
        self.rest_iface.execute('/Node/%s/root.%s/' % (self.zone, self.zone), 'DELETE')
        self.rest_iface.execute('/Node/%s/cname1.%s/' % (self.zone, self.zone), 'DELETE')
        self.rest_iface.execute('/Node/%s/cname2.%s/' % (self.zone, self.zone), 'DELETE')
        self.rest_iface.execute('/ARecord/%s/root.%s/' % (self.zone, self.zone), 'POST', {'rdata': {'address': '127.0.0.1'}, 'ttl': 10})
        self.rest_iface.execute('/ARecord/%s/root.%s/' % (self.zone, self.zone), 'POST', {'rdata': {'address': '127.0.0.2'}, 'ttl': 10})
        self.rest_iface.execute('/ARecord/%s/root.%s/' % (self.zone, self.zone), 'POST', {'rdata': {'address': '127.0.0.3'}, 'ttl': 10})
        self.rest_iface.execute('/ARecord/%s/root.%s/' % (self.zone, self.zone), 'POST', {'rdata': {'address': '127.0.0.4'}, 'ttl': 10})
        self.rest_iface.execute('/AAAARecord/%s/root.%s/' % (self.zone, self.zone), 'POST', {'rdata': {'address': '::1'}, 'ttl': 10})
        self.rest_iface.execute('/AAAARecord/%s/root.%s/' % (self.zone, self.zone), 'POST', {'rdata': {'address': '::2'}, 'ttl': 10})
        self.rest_iface.execute('/CNAMERecord/%s/cname1.%s/' % (self.zone, self.zone), 'POST', {'rdata': {'cname': 'root.%s.' % self.zone}, 'ttl': 10})
        self.rest_iface.execute('/CNAMERecord/%s/cname2.%s/' % (self.zone, self.zone), 'POST', {'rdata': {'cname': 'cname1.%s.' % self.zone}, 'ttl': 10})
        self.rest_iface.execute('/Zone/%s/' % self.zone, 'PUT', {'publish': 'true'})

    def test_remove_records_with_disabled_readd_feature(self):
        dyndns = DynDns(
            dry_run=False,
            customer_name=self.customer_name,
            user_name=self.user_name,
            password=self.password,
        )
        dyndns.sync_records(
            failed=[
                Checkpoint(url='http://127.0.0.1/health/', host='cname2.%s' % self.zone, record='root.%s.' % self.zone, ip='127.0.0.1', type='A'), # remove this
                Checkpoint(url='http://127.0.0.4/health/', host='root.%s' % self.zone, record='root.%s.' % self.zone, ip='127.0.0.4', type='A'), # remove this
                Checkpoint(url='http://127.0.0.104/health/', host='root.%s' % self.zone, record='root.%s.' % self.zone, ip='127.0.0.4', type='A'), # non existent
                Checkpoint(url='http://[::2]/health/', host='root.%s' % self.zone, record='root.%s.' % self.zone, ip='::2', type='AAAA'), # ipv6
            ],
            passed=[],
            enable_readd=False,
        )

        # IPv4 removed
        tools.assert_equal(
            set([
                '127.0.0.2',
                '127.0.0.3',
            ]),
            set([
                self.rest_iface.execute(url, 'GET')['data']['rdata']['address']
                for url in
                self.rest_iface.execute('/ARecord/%s/root.%s/' % (self.zone, self.zone), 'GET')['data']
            ])
        )
        # IPv6 removed
        tools.assert_equal(
            set([
                '::1',
            ]),
            set([
                self.rest_iface.execute(url, 'GET')['data']['rdata']['address']
                for url in
                self.rest_iface.execute('/AAAARecord/%s/root.%s/' % (self.zone, self.zone), 'GET')['data']
            ])
        )
        # CNAMEs kept
        tools.assert_equal(
            [{u'cname': u'root.pantheondnstestdomain.com.'}],
            [
                self.rest_iface.execute(url, 'GET')['data']['rdata']
                for url in
                self.rest_iface.execute('/CNAMERecord/%s/cname1.%s/' % (self.zone, self.zone), 'GET')['data']
            ]
        )
        tools.assert_equal(
            [{u'cname': u'cname1.pantheondnstestdomain.com.'}],
            [
                self.rest_iface.execute(url, 'GET')['data']['rdata']
                for url in
                self.rest_iface.execute('/CNAMERecord/%s/cname2.%s/' % (self.zone, self.zone), 'GET')['data']
            ]
        )
        dyndns.sync_records(
            failed=[
                Checkpoint(url='http://127.0.0.2/health/', host='cname2.%s' % self.zone, record='root.%s.' % self.zone, ip='127.0.0.1', type='A'),
                Checkpoint(url='http://127.0.0.3/health/', host='root.%s' % self.zone, record='root.%s.' % self.zone, ip='127.0.0.4', type='A'),
            ],
            passed=[],
            enable_readd=False,
        )
        # IPv4 not removed - we are not deleting when all records fails
        tools.assert_equal(
            set([
                '127.0.0.2',
                '127.0.0.3',
#.........這裏部分代碼省略.........
開發者ID:whiskybar,項目名稱:ddcheck,代碼行數:103,代碼來源:test_dyndns.py


注:本文中的dynect.DynectDNS.DynectRest.execute方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。