Ejemplo n.º 1
0
def login():
    print('\nLOGIN')
    email = input('Email: ')
    pswrd = input('Password: '******'enter_security_code':
        security_code = input('Security Code: ')
        token = get_token(email, pswrd, security_code)
    print()
    return pswrd, token
Ejemplo n.º 2
0
def get(args):
    """Retrieve records.

    Argument:

        args: arguments object
    """
    password = get_password(args)
    token = connect.get_token(args.username, password, args.server)

    if args.__dict__.get('search'):
        # When using '--search' option
        keyword = args.search

    else:
        keyword = ''

    if args.__dict__.get('raw_flag'):
        raw_flag = True
    else:
        raw_flag = False

    if args.__dict__.get('domain'):
        # When specified zone
        domain = args.domain
        data = processing.get_zone(args.server, token, domain,
                                   keyword, raw_flag)
        return data

    else:
        # When get all zones
        processing.get_all_zone(args.server, token)
Ejemplo n.º 3
0
def get(args):
    """Retrieve records.

    Argument:

        args: arguments object
    """
    password = get_password(args)
    token = connect.get_token(args.username, password, args.server)

    if args.__dict__.get('search'):
        # When using '--search' option
        keyword = args.search

    else:
        keyword = ''

    if args.__dict__.get('raw_flag'):
        raw_flag = True
    else:
        raw_flag = False

    if args.__dict__.get('domain'):
        # When specified zone
        domain = args.domain
        data = processing.get_zone(args.server, token, domain, keyword,
                                   raw_flag)
        return data

    else:
        # When get all zones
        processing.get_all_zone(args.server, token)
Ejemplo n.º 4
0
def delete_zone(args):
    """Delete zone.

    Argument:

        args: arguments object
    """
    if args.__dict__.get('domain'):
        domain = args.domain

    password = get_password(args)
    token = connect.get_token(args.username, password, args.server)
    processing.delete_zone(args.server, token, domain)
Ejemplo n.º 5
0
def delete_tmpl(args):
    """Delete template.

    Argument:

        args: arguments object
    """
    if args.__dict__.get('template'):
        template = args.template

    password = get_password(args)
    token = connect.get_token(args.username, password, args.server)
    processing.delete_template(args.server, token, template)
Ejemplo n.º 6
0
def delete_zone(args):
    """Delete zone.

    Argument:

        args: arguments object
    """
    if args.__dict__.get('domain'):
        domain = args.domain

    password = get_password(args)
    token = connect.get_token(args.username, password, args.server)
    processing.delete_zone(args.server, token, domain)
Ejemplo n.º 7
0
def delete_tmpl(args):
    """Delete template.

    Argument:

        args: arguments object
    """
    if args.__dict__.get('template'):
        template = args.template

    password = get_password(args)
    token = connect.get_token(args.username, password, args.server)
    processing.delete_template(args.server, token, template)
Ejemplo n.º 8
0
def retrieve_tmpl(args):
    """Retrieve template.

    Argument:

        args: arguments object
    """
    password = get_password(args)
    token = connect.get_token(args.username, password, args.server)

    if args.__dict__.get('template'):
        # When specified template identifier
        template = args.template
        processing.get_template(args.server, token, template)

    else:
        # When get all templates
        processing.get_all_templates(args.server, token)
Ejemplo n.º 9
0
def retrieve_tmpl(args):
    """Retrieve template.

    Argument:

        args: arguments object
    """
    password = get_password(args)
    token = connect.get_token(args.username, password, args.server)

    if args.__dict__.get('template'):
        # When specified template identifier
        template = args.template
        processing.get_template(args.server, token, template)

    else:
        # When get all templates
        processing.get_all_templates(args.server, token)
Ejemplo n.º 10
0
def update_soa_serial(args):
    """Update SOA serial.

    Argument:

        args: arguments object
    """
    password = get_password(args)
    token = connect.get_token(args.username, password, args.server)
    soa_content = dict(domain=args.domain)
    if args.__dict__.get('mname'):
        soa_content['mname'] = args.mname
    if args.__dict__.get('rname'):
        soa_content['rname'] = args.rname
    if args.__dict__.get('refresh'):
        soa_content['refresh'] = args.refresh
    if args.__dict__.get('retry'):
        soa_content['retry'] = args.retry
    if args.__dict__.get('expire'):
        soa_content['expire'] = args.expire
    if args.__dict__.get('minimum'):
        soa_content['minimum'] = args.minimum
    processing.update_soa_serial(args.server, token, soa_content)
Ejemplo n.º 11
0
def update_soa_serial(args):
    """Update SOA serial.

    Argument:

        args: arguments object
    """
    password = get_password(args)
    token = connect.get_token(args.username, password, args.server)
    soa_content = dict(domain=args.domain)
    if args.__dict__.get('mname'):
        soa_content['mname'] = args.mname
    if args.__dict__.get('rname'):
        soa_content['rname'] = args.rname
    if args.__dict__.get('refresh'):
        soa_content['refresh'] = args.refresh
    if args.__dict__.get('retry'):
        soa_content['retry'] = args.retry
    if args.__dict__.get('expire'):
        soa_content['expire'] = args.expire
    if args.__dict__.get('minimum'):
        soa_content['minimum'] = args.minimum
    processing.update_soa_serial(args.server, token, soa_content)
Ejemplo n.º 12
0
def create_zone(args):
    """Create zone.

    Argument:

        args: arguments object
    """
    action = True

    password = get_password(args)
    token = connect.get_token(args.username, password, args.server)

    domain = args.domain
    template = args.domain.replace('.', '_')

    master = None
    dnsaddr = args.dnsaddr
    if args.__dict__.get('S'):
        dtype = 'SLAVE'
        master = dnsaddr
    elif args.__dict__.get('N'):
        dtype = 'NATIVE'
    else:
        dtype = 'MASTER'

    # generate template data
    o = JSONConverter(domain)
    o.generate_template(domain, dnsaddr, desc='')

    # create template
    processing.create_template(args.server, token, template, o.record)

    # create zone
    processing.create_zone(args.server, token, domain, template, dtype, master)

    # delete template
    processing.delete_template(args.server, token, template)
Ejemplo n.º 13
0
def create_zone(args):
    """Create zone.

    Argument:

        args: arguments object
    """
    action = True

    password = get_password(args)
    token = connect.get_token(args.username, password, args.server)

    domain = args.domain
    template = args.domain.replace('.', '_')

    master = None
    dnsaddr = args.dnsaddr
    if args.__dict__.get('S'):
        dtype = 'SLAVE'
        master = dnsaddr
    elif args.__dict__.get('N'):
        dtype = 'NATIVE'
    else:
        dtype = 'MASTER'

    # generate template data
    o = JSONConverter(domain)
    o.generate_template(domain, dnsaddr, desc='')

    # create template
    processing.create_template(args.server, token, template, o.record)

    # create zone
    processing.create_zone(args.server, token, domain, template, dtype, master)

    # delete template
    processing.delete_template(args.server, token, template)
Ejemplo n.º 14
0
def delete(args):
    """Delete records.

    Argument:

        args: arguments object
    """
    # for DELETE HTTP method
    action = False

    if ((args.__dict__.get('domain') and args.__dict__.get('name')
         and args.__dict__.get('rtype') and args.__dict__.get('content'))):
        # for delete sub-command

        domain = args.domain
        o = JSONConverter(domain)

        name, rtype, content, ttl, priority = get_record_params(args)
        record_dict = o.set_record(name, rtype, content, ttl, priority)

        json = set_json(domain, action, record=record_dict)

    else:
        # for bulk_delete sub-command
        if args.__dict__.get('domain'):
            domain = args.domain
        else:
            domain = check_infile(args.infile)
        json = set_json(domain, action, filename=args.infile)

    password = get_password(args)
    token = connect.get_token(args.username, password, args.server)
    processing.delete_records(args.server, token, json)

    if args.auto_update_soa == 'True':
        update_soa_serial(args)
Ejemplo n.º 15
0
def delete(args):
    """Delete records.

    Argument:

        args: arguments object
    """
    # for DELETE HTTP method
    action = False

    if ((args.__dict__.get('domain') and args.__dict__.get('name')
         and args.__dict__.get('rtype') and args.__dict__.get('content'))):
        # for delete sub-command

        domain = args.domain
        o = JSONConverter(domain)

        name, rtype, content, ttl, priority = get_record_params(args)
        record_dict = o.set_record(name, rtype, content, ttl, priority)

        json = set_json(domain, action, record=record_dict)

    else:
        # for bulk_delete sub-command
        if args.__dict__.get('domain'):
            domain = args.domain
        else:
            domain = check_infile(args.infile)
        json = set_json(domain, action, filename=args.infile)

    password = get_password(args)
    token = connect.get_token(args.username, password, args.server)
    processing.delete_records(args.server, token, json)

    if args.auto_update_soa == 'True':
        update_soa_serial(args)