Spec for aws_syncr options
437988
def aws_syncr_spec(self):
        """"""
        formatted_string = formatted(string_spec(), MergedOptionStringFormatter, expected_type=string_types)
        return create_spec(AwsSyncr
            , extra = defaulted(formatted_string, "")
            , stage = defaulted(formatted_string, "")
            , debug = defaulted(boolean(), False)
            , dry_run = defaulted(boolean(), False)
            , location = defaulted(formatted_string, "ap-southeast-2")
            , artifact = formatted_string
            , environment = formatted_string
            , config_folder = directory_spec()
            )
1264333
function defaultOptions(opts) {
    opts.bucketSize = opts.bucketSize || 20;
    opts.concurrency = opts.concurrency || 3;
    opts.expireTime = opts.expireTime || 60 * 60 * 24;
    opts.refreshTime = opts.refreshTime || 60 * 60;
    opts.replicateTime = opts.replicateTime || 60 * 60;
    opts.republishTime = opts.republishTime || 60 * 60 * 24;
}
364684
def _aws_encode_changebatch(o):
    '''
    
    '''
    change_idx = 0
    while change_idx < len(o['Changes']):
        o['Changes'][change_idx]['ResourceRecordSet']['Name'] = aws_encode(o['Changes'][change_idx]['ResourceRecordSet']['Name'])
        if 'ResourceRecords' in o['Changes'][change_idx]['ResourceRecordSet']:
            rr_idx = 0
            while rr_idx < len(o['Changes'][change_idx]['ResourceRecordSet']['ResourceRecords']):
                o['Changes'][change_idx]['ResourceRecordSet']['ResourceRecords'][rr_idx]['Value'] = aws_encode(o['Changes'][change_idx]['ResourceRecordSet']['ResourceRecords'][rr_idx]['Value'])
                rr_idx += 1
        if 'AliasTarget' in o['Changes'][change_idx]['ResourceRecordSet']:
            o['Changes'][change_idx]['ResourceRecordSet']['AliasTarget']['DNSName'] = aws_encode(o['Changes'][change_idx]['ResourceRecordSet']['AliasTarget']['DNSName'])
        change_idx += 1
    return o
110653
def build_swagger_spec(user, repo, sha, serverName):
    
    if user and repo:
        # Init provenance recording
        prov_g = grlcPROV(user, repo)
    else:
        prov_g = None

    swag = swagger.get_blank_spec()
    swag['host'] = serverName

    try:
        loader = getLoader(user, repo, sha, prov_g)
    except Exception as e:
        # If repo does not exits
        swag['info'] = {
            'title': 'ERROR!',
            'description': str(e)
        }
        swag['paths'] = {}
        return swag

    prev_commit, next_commit, info, basePath = \
        swagger.get_repo_info(loader, sha, prov_g)
    swag['prev_commit'] = prev_commit
    swag['next_commit'] = next_commit
    swag['info'] = info
    swag['basePath'] = basePath

    # TODO: can we pass loader to build_spec ?
    spec = swagger.build_spec(user, repo, sha, prov_g)
    for item in spec:
        swag['paths'][item['call_name']] = swagger.get_path_for_item(item)

    if prov_g:
        prov_g.end_prov_graph()
        swag['prov'] = prov_g.serialize(format='turtle')
    return swag
338673
def sync(config, group, accounts=(), dryrun=False, region=None):
    
    config = validate.callback(config)
    destination = config.get('destination')
    client = boto3.Session().client('s3')

    for account in config.get('accounts', ()):
        if accounts and account['name'] not in accounts:
            continue

        session = get_session(account['role'], region)
        account_id = session.client('sts').get_caller_identity()['Account']
        prefix = destination.get('prefix', '').rstrip('/') + '/%s' % account_id
        prefix = "%s/%s" % (prefix, group)

        exports = get_exports(client, destination['bucket'], prefix + "/")

        role = account.pop('role')
        if isinstance(role, six.string_types):
            account['account_id'] = role.split(':')[4]
        else:
            account['account_id'] = role[-1].split(':')[4]
        account.pop('groups')

        if exports:
            last_export = exports.pop()
            account['export'] = last_export
        else:
            account['export'] = 'missing'
            last_export = None
        try:
            tag_set = client.get_object_tagging(
                Bucket=destination['bucket'], Key=prefix).get('TagSet', [])
        except ClientError:
            tag_set = []

        tags = {t['Key']: t['Value'] for t in tag_set}
        tagged_last_export = None

        if 'LastExport' in tags:
            le = parse(tags['LastExport'])
            tagged_last_export = (le.year, le.month, le.day)
            account['sync'] = tagged_last_export
        else:
            account['sync'] = account['export'] != 'missing' and 'sync' or 'missing'

        if last_export is None:
            continue

        if tagged_last_export == last_export or account['export'] == 'missing':
            continue

        if dryrun:
            continue

        client.put_object(
            Bucket=destination['bucket'],
            Key=prefix,
            Body=json.dumps({}),
            ACL="bucket-owner-full-control",
            ServerSideEncryption="AES256")

        export_time = datetime.now().replace(tzinfo=tzlocal()).astimezone(tzutc())
        export_time = export_time.replace(
            year=last_export[0], month=last_export[1], day=last_export[2],
            minute=0, second=0, microsecond=0, hour=0)
        client.put_object_tagging(
            Bucket=destination['bucket'], Key=prefix,
            Tagging={
                'TagSet': [{
                    'Key': 'LastExport',
                    'Value': export_time.isoformat()}]})

    accounts_report = []
    for a in config.get('accounts'):
        if accounts and a['name'] not in accounts:
            continue
        if isinstance(a['sync'], tuple):
            a['sync'] = "%s/%s/%s" % (a['sync'])
        if isinstance(a['export'], tuple):
            a['export'] = "%s/%s/%s" % (a['export'])
        accounts_report.append(a)

    accounts_report.sort(key=operator.itemgetter('export'), reverse=True)
    print(tabulate(accounts_report, headers='keys'))
433050
function syncItems(system, front, customProps) {
  return front.specs(customProps).then(function(specs) {
    removeItemsFromFront(system, front);

    var remoteItems = addLocalFunctions(specs, front);
    system.addItems(remoteItems);

    return system;
  });
}
1333602
function (source, target, callback) {
    source = fss.slashify(source);
    target = fss.slashify(target);

    if (!shell.which('rsync')) {
        log('sync error', 'no rsync command found');
        callback();
    } else {
        log('rsync', fss.baseRelative(source));
        log('remote', target);
        var cmd = [config.rsync, source, target].join(' ');
        var opt = { maxBuffer: 5000*1024 };
        exec(cmd, opt, rsync_end(callback));
    }
}
287861
def create_synccopy_specifications(ctx_cli_options, config):
    # type: (dict, dict) -> List[blobxfer.models.synccopy.Specification]
    
    cli_conf = ctx_cli_options[ctx_cli_options['_action']]
    cli_options = cli_conf['options']
    specs = []
    for conf in config['synccopy']:
        if 'options' in conf:
            conf_options = conf['options']
        else:
            conf_options = {}
        # get source mode
        mode = _merge_setting(
            cli_options, conf_options, 'mode', default='auto').lower()
        if mode == 'auto':
            mode = blobxfer.models.azure.StorageModes.Auto
        elif mode == 'append':
            mode = blobxfer.models.azure.StorageModes.Append
        elif mode == 'block':
            mode = blobxfer.models.azure.StorageModes.Block
        elif mode == 'file':
            mode = blobxfer.models.azure.StorageModes.File
        elif mode == 'page':
            mode = blobxfer.models.azure.StorageModes.Page
        else:
            raise ValueError('unknown source mode: {}'.format(mode))
        # get destination mode
        destmode = _merge_setting(
            cli_options, conf_options, 'dest_mode', name_cli='dest_mode')
        if blobxfer.util.is_none_or_empty(destmode):
            destmode = mode
        else:
            destmode = destmode.lower()
            if destmode == 'auto':
                destmode = blobxfer.models.azure.StorageModes.Auto
            elif destmode == 'append':
                destmode = blobxfer.models.azure.StorageModes.Append
            elif destmode == 'block':
                destmode = blobxfer.models.azure.StorageModes.Block
            elif destmode == 'file':
                destmode = blobxfer.models.azure.StorageModes.File
            elif destmode == 'page':
                destmode = blobxfer.models.azure.StorageModes.Page
            else:
                raise ValueError('unknown dest mode: {}'.format(destmode))
        # create specification
        conf_sod = conf_options.get('skip_on', {})
        cli_sod = cli_options['skip_on']
        scs = blobxfer.models.synccopy.Specification(
            synccopy_options=blobxfer.models.options.SyncCopy(
                access_tier=_merge_setting(
                    cli_options, conf_options, 'access_tier', default=None),
                delete_extraneous_destination=_merge_setting(
                    cli_options, conf_options,
                    'delete_extraneous_destination', default=False),
                dest_mode=destmode,
                mode=mode,
                overwrite=_merge_setting(
                    cli_options, conf_options, 'overwrite', default=True),
                recursive=_merge_setting(
                    cli_options, conf_options, 'recursive', default=True),
                rename=_merge_setting(
                    cli_options, conf_options, 'rename', default=False),
            ),
            skip_on_options=blobxfer.models.options.SkipOn(
                filesize_match=_merge_setting(
                    cli_sod, conf_sod, 'filesize_match', default=False),
                lmt_ge=_merge_setting(
                    cli_sod, conf_sod, 'lmt_ge', default=False),
                md5_match=_merge_setting(
                    cli_sod, conf_sod, 'md5_match', default=False),
            ),
        )
        # create remote source paths
        for src in conf['source']:
            sa = next(iter(src))
            asp = blobxfer.operations.azure.SourcePath()
            asp.add_path_with_storage_account(src[sa], sa)
            incl = _merge_setting(cli_conf, conf, 'include', default=None)
            if blobxfer.util.is_not_empty(incl):
                asp.add_includes(incl)
            excl = _merge_setting(cli_conf, conf, 'exclude', default=None)
            if blobxfer.util.is_not_empty(excl):
                asp.add_excludes(excl)
            scs.add_azure_source_path(asp)
        # create remote destination paths
        for dst in conf['destination']:
            if len(dst) != 1:
                raise RuntimeError(
                    'invalid number of destination pairs specified per entry')
            sa = next(iter(dst))
            adp = blobxfer.operations.azure.DestinationPath()
            adp.add_path_with_storage_account(dst[sa], sa)
            scs.add_azure_destination_path(adp)
        # append spec to list
        specs.append(scs)
    return specs
254501
function setCliConfiguration() {
  return yargs
    .usage('usage: $0 [options] <aws-elasticsearch-cluster-endpoint>')
    .option('h', {
      alias: 'host',
      default: HOST || '127.0.0.1',
      demand: false,
      describe: 'Host IP Address',
      type: 'string',
    })
    .option('p', {
      alias: 'port',
      default: PORT || 9200,
      demand: false,
      describe: 'Host Port',
      type: 'number',
    })
    .option('r', {
      alias: 'region',
      default: REGION || 'us-west-2',
      demand: false,
      describe: 'AWS region',
      type: 'string',
    })
    .option('e', {
      alias: 'endpoint',
      default: ENDPOINT,
      demand: true,
      describe: 'AWS Elasticsearch Endpoint',
      type: 'string',
    })
    .option('c', {
      alias: 'profile',
      default: AWS_PROFILE || 'default',
      demand: false,
      describe: 'AWS Credentials Profile',
      type: 'string',
    })
    .option('d', {
      alias: 'debug',
      default: DEBUG || false,
      demand: false,
      describe: 'Provides debug logging',
      type: 'boolean',
    })
    .help()
    .version()
    .strict()
}
517347
def fetch_single_spec(source_uri, spec_name)
      @fetch_error = nil

      begin
        marshal_uri = source_uri + "quick/Marshal.#{Gem.marshal_version}/#{spec_name}.gemspec.rz"
        zipped = fetcher.fetch_path marshal_uri
        return Marshal.load(unzip(zipped))
      rescue => ex
        @fetch_error = ex

        if Gem.configuration.really_verbose then
          say "unable to fetch marshal gemspec #{marshal_uri}: #{ex.class} - #{ex}"
        end
      end

      begin
        yaml_uri = source_uri + "quick/#{spec_name}.gemspec.rz"
        zipped = fetcher.fetch_path yaml_uri
        return YAML.load(unzip(zipped))
      rescue => ex
        @fetch_error = ex
        if Gem.configuration.really_verbose then
          say "unable to fetch YAML gemspec #{yaml_uri}: #{ex.class} - #{ex}"
        end
      end

      nil
    end
789609
def get_default_config_help(self):
        
        config = super(cloudwatchHandler, self).get_default_config_help()

        config.update({
            'region': 'AWS region',
            'metric': 'Diamond metric name',
            'namespace': 'CloudWatch metric namespace',
            'name': 'CloudWatch metric name',
            'unit': 'CloudWatch metric unit',
            'collector': 'Diamond collector name',
            'collect_by_instance': 'Collect metrics for instances separately',
            'collect_without_dimension': 'Collect metrics without dimension'
        })

        return config
873045
def ec2
      @ec2 ||= begin
       AWS::EC2::Base.new( aws_options )
      rescue AWS::ArgumentError => e # AWS credentials missing?
        puts "Error contacting AWS: #{e}"
        raise e
      rescue Exception => e
        puts "Generic error #{e.class}: #{e}"
      end
    end
419840
def handle_snapshot(config_spec, object_ref, reloc_spec, template, vm_):
    '''
    
    '''
    if 'snapshot' not in vm_:
        return None

    allowed_types = [
        FLATTEN_DISK_FULL_CLONE,
        COPY_ALL_DISKS_FULL_CLONE,
        CURRENT_STATE_LINKED_CLONE,
        QUICK_LINKED_CLONE,
    ]

    clone_spec = get_clonespec_for_valid_snapshot(
        config_spec,
        object_ref,
        reloc_spec,
        template,
        vm_)
    if not clone_spec:
        raise SaltCloudSystemExit('Invalid disk move type specified'
                                  ' supported types are'
                                  ' {0}'.format(' '.join(allowed_types)))
    return clone_spec
858642
def _meta_get_resource_sync(md_uuid):
    """"""
    isogeo.resource(id_resource=md_uuid)

    elapsed = default_timer() - START_TIME
    time_completed_at = "{:5.2f}s".format(elapsed)
    print("{0:<30} {1:>20}".format(md_uuid, time_completed_at))

    return
502867
function (syncOptions, serverResponses) {
    const syncs = [];
    if (syncOptions.pixelEnabled && serverResponses.length) {
      try {
        serverResponses[0].body.ext.telaria.userSync.forEach(url => syncs.push({type: 'image', url: url}));
      } catch (e) {}
    }
    return syncs;
  }
90879
def sync=(sync)
      validator = EnumAttributeValidator.new('String', ["true", "false"])
      unless validator.valid?(sync)
        fail ArgumentError, "invalid value for 'sync', must be one of #{validator.allowable_values}."
      end
      @sync = sync
    end
158752
def list_tasks(collector):
    """"""
    print("Usage: aws_syncr <environment> <task>")
    print("")
    print("Available environments to choose from are")
    print("-----------------------------------------")
    print("")
    for environment in os.listdir(collector.configuration_folder):
        location = os.path.join(collector.configuration_folder, environment)
        if os.path.isdir(location) and not environment.startswith("."):
            print("\t{0}".format(environment))

    print("")
    print("Available tasks to choose from are:")
    print("-----------------------------------")
    print("")
    keygetter = lambda item: item[1].label
    tasks = sorted(available_actions.items(), key=keygetter)
    sorted_tasks = sorted(list(tasks), key=lambda item: len(item[0]))
    max_length = max(len(name) for name, _ in sorted_tasks)
    for key, task in sorted_tasks:
        desc = dedent(task.__doc__ or "").strip().split('\n')[0]
        print("\t{0}{1} :-: {2}".format(" " * (max_length-len(key)), key, desc))
    print("")