Create zone.

    Arguments:

        prs:  parser object of argparse
        conn: dictionary of connection information
192227
def parse_create_zone(prs, conn):
    
    prs_zone_create = prs.add_parser('zone_create', help='create zone')
    prs_zone_create.add_argument(
        '--domain', action='store', required=True, help='specify zone')
    prs_zone_create.add_argument('--dnsaddr', action='store', required=True,
                                 help='specify IP address of DNS master')
    group_zone_create = prs_zone_create.add_mutually_exclusive_group()
    group_zone_create.add_argument('-S', action='store_true',
                                   help='create zone to SLAVE')
    group_zone_create.add_argument('-N', action='store_true',
                                   help='create zone to NATIVE')
    conn_options(prs_zone_create, conn)
    prs_zone_create.set_defaults(func=create_zone)
604451
def add_port(zone, port, permanent=True):
    '''
    
    '''
    cmd = '--zone={0} --add-port={1}'.format(zone, port)

    if permanent:
        cmd += ' --permanent'

    return __firewall_cmd(cmd)
1353152
def create_connection(self):
        
        attempts = 0
        while True:
            attempts += 1
            try:
                self.connection = Connection('127.0.0.1', 'guest', 'guest')
                break
            except amqpstorm.AMQPError as why:
                LOGGER.exception(why)
                if self.max_retries and attempts > self.max_retries:
                    break
                time.sleep(min(attempts * 2, 30))
            except KeyboardInterrupt:
                break
511928
def _prepare_connection(**kwargs):
    '''
    
    '''
    pyeapi_kwargs = __salt__['config.get']('pyeapi', {})
    pyeapi_kwargs.update(kwargs)  # merge the CLI args with the opts/pillar
    init_kwargs, fun_kwargs = __utils__['args.prepare_kwargs'](pyeapi_kwargs, PYEAPI_INIT_KWARGS)
    if 'transport' not in init_kwargs:
        init_kwargs['transport'] = 'https'
    conn = pyeapi.client.connect(**init_kwargs)
    node = pyeapi.client.Node(conn, enablepwd=init_kwargs.get('enablepwd'))
    return node, fun_kwargs
1030139
def cli(env, zone, data, record, ttl, type):
    """"""

    manager = SoftLayer.DNSManager(env.client)
    table = formatting.Table(['id', 'record', 'type', 'ttl', 'data'])

    table.align['ttl'] = 'l'
    table.align['record'] = 'r'
    table.align['data'] = 'l'

    zone_id = helpers.resolve_id(manager.resolve_ids, zone, name='zone')

    records = manager.get_records(zone_id,
                                  record_type=type,
                                  host=record,
                                  ttl=ttl,
                                  data=data)

    for the_record in records:
        table.add_row([
            the_record['id'],
            the_record['host'],
            the_record['type'].upper(),
            the_record['ttl'],
            the_record['data']
        ])

    env.fout(table)
767176
def add_connections(self, conns):
        
        rets = []
        for addr, kwargs in conns:
            r = self.add_connection(addr, **kwargs)
            rets.append(r)
        return rets
841647
def create(name, launch_config_name, availability_zones, min_size, max_size,
           desired_capacity=None, load_balancers=None, default_cooldown=None,
           health_check_type=None, health_check_period=None,
           placement_group=None, vpc_zone_identifier=None, tags=None,
           termination_policies=None, suspended_processes=None,
           scaling_policies=None, scheduled_actions=None, region=None,
           notification_arn=None, notification_types=None,
           key=None, keyid=None, profile=None):
    '''
    
    '''
    conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)
    if isinstance(availability_zones, six.string_types):
        availability_zones = salt.utils.json.loads(availability_zones)
    if isinstance(load_balancers, six.string_types):
        load_balancers = salt.utils.json.loads(load_balancers)
    if isinstance(vpc_zone_identifier, six.string_types):
        vpc_zone_identifier = salt.utils.json.loads(vpc_zone_identifier)
    if isinstance(tags, six.string_types):
        tags = salt.utils.json.loads(tags)
    # Make a list of tag objects from the dict.
    _tags = []
    if tags:
        for tag in tags:
            try:
                key = tag.get('key')
            except KeyError:
                log.error('Tag missing key.')
                return False
            try:
                value = tag.get('value')
            except KeyError:
                log.error('Tag missing value.')
                return False
            propagate_at_launch = tag.get('propagate_at_launch', False)
            _tag = autoscale.Tag(key=key, value=value, resource_id=name,
                                 propagate_at_launch=propagate_at_launch)
            _tags.append(_tag)
    if isinstance(termination_policies, six.string_types):
        termination_policies = salt.utils.json.loads(termination_policies)
    if isinstance(suspended_processes, six.string_types):
        suspended_processes = salt.utils.json.loads(suspended_processes)
    if isinstance(scheduled_actions, six.string_types):
        scheduled_actions = salt.utils.json.loads(scheduled_actions)
    retries = 30
    while True:
        try:
            _asg = autoscale.AutoScalingGroup(
                name=name, launch_config=launch_config_name,
                availability_zones=availability_zones,
                min_size=min_size, max_size=max_size,
                desired_capacity=desired_capacity, load_balancers=load_balancers,
                default_cooldown=default_cooldown,
                health_check_type=health_check_type,
                health_check_period=health_check_period,
                placement_group=placement_group, tags=_tags,
                vpc_zone_identifier=vpc_zone_identifier,
                termination_policies=termination_policies,
                suspended_processes=suspended_processes)
            conn.create_auto_scaling_group(_asg)
            # create scaling policies
            _create_scaling_policies(conn, name, scaling_policies)
            # create scheduled actions
            _create_scheduled_actions(conn, name, scheduled_actions)
            # create notifications
            if notification_arn and notification_types:
                conn.put_notification_configuration(_asg, notification_arn, notification_types)
            log.info('Created ASG %s', name)
            return True
        except boto.exception.BotoServerError as e:
            if retries and e.code == 'Throttling':
                log.debug('Throttled by AWS API, retrying in 5 seconds...')
                time.sleep(5)
                retries -= 1
                continue
            log.error(e)
            msg = 'Failed to create ASG %s', name
            log.error(msg)
            return False
956104
def init(opts):
    '''
    
    '''
    proxy_dict = opts.get('proxy', {})
    conn_args = proxy_dict.copy()
    conn_args.pop('proxytype', None)
    opts['multiprocessing'] = conn_args.get('multiprocessing', True)
    # This is not a SSH-based proxy, so it should be safe to enable
    # multiprocessing.
    try:
        conn = pyeapi.client.connect(**conn_args)
        node = pyeapi.client.Node(conn, enablepwd=conn_args.get('enablepwd'))
        pyeapi_device['connection'] = node
        pyeapi_device['initialized'] = True
        pyeapi_device['up'] = True
    except pyeapi.eapilib.ConnectionError as cerr:
        log.error('Unable to connect to %s', conn_args['host'], exc_info=True)
        return False
    return True
56261
def setup_parser():
    """"""
    parser = argparse.ArgumentParser()
    parser.add_argument('-p', '--port', type=int, default=5005)
    parser.add_argument('-i', '--interval', type=int, default=480)
    parser.add_argument('host', type=str, help='hostname')
    return parser
202606
def parse_update(prs, conn):
    

    prs_update = prs.add_parser(
        'update', help='update record of specific zone')
    set_option(prs_update, 'domain')
    set_option(prs_update, 'update')
    conn_options(prs_update, conn)
    prs_update.set_defaults(func=update)
282713
def create(self):
        
        self.service.create()
        os.environ[self.__module__ + '.uri'] = self.service.settings.data['url']
        os.environ[self.__module__ + '.zone_id'] = self.get_predix_zone_id()
951983
def cli(env, zonefile, dry_run):
    """"""

    manager = SoftLayer.DNSManager(env.client)
    with open(zonefile) as zone_f:
        zone_contents = zone_f.read()

    zone, records, bad_lines = parse_zone_details(zone_contents)

    env.out("Parsed: zone=%s" % zone)
    for record in records:
        env.out("Parsed: %s" % RECORD_FMT.format(**record))

    for line in bad_lines:
        env.out("Unparsed: %s" % line)

    if dry_run:
        return

    # Find zone id or create the zone if it doesn't exist
    try:
        zone_id = helpers.resolve_id(manager.resolve_ids, zone,
                                     name='zone')
    except exceptions.CLIAbort:
        zone_id = manager.create_zone(zone)['id']
        env.out(click.style("Created: %s" % zone, fg='green'))

    # Attempt to create each record
    for record in records:
        try:
            manager.create_record(zone_id,
                                  record['record'],
                                  record['type'],
                                  record['data'],
                                  record['ttl'])

            env.out(click.style("Created: %s" % RECORD_FMT.format(**record),
                                fg='green'))
        except SoftLayer.SoftLayerAPIError as ex:
            env.out(click.style("Failed: %s" % RECORD_FMT.format(**record),
                                fg='red'))
            env.out(click.style(str(ex), fg='red'))

    env.out(click.style("Finished", fg='green'))
763637
def create(cls, paas_info, vhost, alter_zone, background):
        
        if not background and not cls.intty():
            background = True

        params = {'paas_id': paas_info['id'],
                  'vhost': vhost,
                  'zone_alter': alter_zone}
        result = cls.call('paas.vhost.create', params, dry_run=True)

        if background:
            return result

        cls.echo('Creating a new vhost.')
        cls.display_progress(result)
        cls.echo('Your vhost %s has been created.' % vhost)

        return result
927650
def pipe_createrss(context=None, _INPUT=None, conf=None, **kwargs):
    
    conf = DotDict(conf)

    for item in _INPUT:
        item = DotDict(item)

        yield {
            value: item.get(conf.get(key, **kwargs))
            for key, value in RSS_FIELDS.items()}
791704
def create(
    name,
    attributes=None,
    region=None,
    key=None,
    keyid=None,
    profile=None,
):
    '''
    
    '''
    conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)

    if attributes is None:
        attributes = {}
    attributes = _preprocess_attributes(attributes)

    try:
        conn.create_queue(QueueName=name, Attributes=attributes)
    except botocore.exceptions.ClientError as e:
        return {'error': __utils__['boto3.get_error'](e)}
    return {'result': True}
713088
def get_zones(region, auth_kwargs):
    
    ec2_conn = boto.ec2.connect_to_region(region, **auth_kwargs)
    return [zone.name for zone in ec2_conn.get_all_zones()]
264845
def create_topic(Name, region=None, key=None, keyid=None, profile=None):
    '''
    
    '''
    conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)
    try:
        ret = conn.create_topic(Name=Name)
        log.info('SNS topic %s created with ARN %s', Name, ret['TopicArn'])
        return ret['TopicArn']
    except botocore.exceptions.ClientError as e:
        log.error('Failed to create SNS topic %s: %s', Name, e)
        return None
    except KeyError:
        log.error('Failed to create SNS topic %s', Name)
        return None