Execute the contents of the VM map
193812
def run_map(self, dmap):
        '''
        
        '''
        if self._has_loop(dmap):
            msg = 'Uh-oh, that cloud map has a dependency loop!'
            log.error(msg)
            raise SaltCloudException(msg)
        # Go through the create list and calc dependencies
        for key, val in six.iteritems(dmap['create']):
            log.info('Calculating dependencies for %s', key)
            level = 0
            level = self._calcdep(dmap, key, val, level)
            log.debug('Got execution order %s for %s', level, key)
            dmap['create'][key]['level'] = level

        try:
            existing_list = six.iteritems(dmap['existing'])
        except KeyError:
            existing_list = six.iteritems({})

        for key, val in existing_list:
            log.info('Calculating dependencies for %s', key)
            level = 0
            level = self._calcdep(dmap, key, val, level)
            log.debug('Got execution order %s for %s', level, key)
            dmap['existing'][key]['level'] = level

        # Now sort the create list based on dependencies
        create_list = sorted(six.iteritems(dmap['create']), key=lambda x: x[1]['level'])
        full_map = dmap['create'].copy()
        if 'existing' in dmap:
            full_map.update(dmap['existing'])
        possible_master_list = sorted(six.iteritems(full_map), key=lambda x: x[1]['level'])
        output = {}
        if self.opts['parallel']:
            parallel_data = []
        master_name = None
        master_minion_name = None
        master_host = None
        master_finger = None
        for name, profile in possible_master_list:
            if profile.get('make_master', False) is True:
                master_name = name
                master_profile = profile

        if master_name:
            # If the master already exists, get the host
            if master_name not in dmap['create']:
                master_host = self.client.query()
                for provider_part in master_profile['provider'].split(':'):
                    master_host = master_host[provider_part]
                master_host = master_host[master_name][master_profile.get('ssh_interface', 'public_ips')]
                if not master_host:
                    raise SaltCloudSystemExit(
                        'Could not get the hostname of master {}.'.format(master_name)
                    )
            # Otherwise, deploy it as a new master
            else:
                master_minion_name = master_name
                log.debug('Creating new master \'%s\'', master_name)
                if salt.config.get_cloud_config_value(
                    'deploy',
                    master_profile,
                    self.opts
                ) is False:
                    raise SaltCloudSystemExit(
                        'Cannot proceed with \'make_master\' when salt deployment '
                        'is disabled(ex: --no-deploy).'
                    )

                # Generate the master keys
                log.debug('Generating master keys for \'%s\'', master_profile['name'])

                priv, pub = salt.utils.cloud.gen_keys(
                    salt.config.get_cloud_config_value(
                        'keysize',
                        master_profile,
                        self.opts
                    )
                )
                master_profile['master_pub'] = pub
                master_profile['master_pem'] = priv

                # Generate the fingerprint of the master pubkey in order to
                # mitigate man-in-the-middle attacks
                master_temp_pub = salt.utils.files.mkstemp()
                with salt.utils.files.fopen(master_temp_pub, 'w') as mtp:
                    mtp.write(pub)
                master_finger = salt.utils.crypt.pem_finger(master_temp_pub, sum_type=self.opts['hash_type'])
                os.unlink(master_temp_pub)

                if master_profile.get('make_minion', True) is True:
                    master_profile.setdefault('minion', {})
                    if 'id' in master_profile['minion']:
                        master_minion_name = master_profile['minion']['id']
                    # Set this minion's master as local if the user has not set it
                    if 'master' not in master_profile['minion']:
                        master_profile['minion']['master'] = '127.0.0.1'
                        if master_finger is not None:
                            master_profile['master_finger'] = master_finger

                # Generate the minion keys to pre-seed the master:
                for name, profile in create_list:
                    make_minion = salt.config.get_cloud_config_value(
                        'make_minion', profile, self.opts, default=True
                    )
                    if make_minion is False:
                        continue

                    log.debug('Generating minion keys for \'%s\'', profile['name'])
                    priv, pub = salt.utils.cloud.gen_keys(
                        salt.config.get_cloud_config_value(
                            'keysize',
                            profile,
                            self.opts
                        )
                    )
                    profile['pub_key'] = pub
                    profile['priv_key'] = priv
                    # Store the minion's public key in order to be pre-seeded in
                    # the master
                    master_profile.setdefault('preseed_minion_keys', {})
                    master_profile['preseed_minion_keys'].update({name: pub})

                local_master = False
                if master_profile['minion'].get('local_master', False) and \
                        master_profile['minion'].get('master', None) is not None:
                    # The minion is explicitly defining a master and it's
                    # explicitly saying it's the local one
                    local_master = True

                out = self.create(master_profile, local_master=local_master)

                if not isinstance(out, dict):
                    log.debug('Master creation details is not a dictionary: %s', out)

                elif 'Errors' in out:
                    raise SaltCloudSystemExit(
                        'An error occurred while creating the master, not '
                        'continuing: {0}'.format(out['Errors'])
                    )

                deploy_kwargs = (
                    self.opts.get('show_deploy_args', False) is True and
                    # Get the needed data
                    out.get('deploy_kwargs', {}) or
                    # Strip the deploy_kwargs from the returned data since we don't
                    # want it shown in the console.
                    out.pop('deploy_kwargs', {})
                )

                master_host = deploy_kwargs.get('salt_host', deploy_kwargs.get('host', None))
                if master_host is None:
                    raise SaltCloudSystemExit(
                        'Host for new master {0} was not found, '
                        'aborting map'.format(
                            master_name
                        )
                    )
                output[master_name] = out
        else:
            log.debug('No make_master found in map')
            # Local master?
            # Generate the fingerprint of the master pubkey in order to
            # mitigate man-in-the-middle attacks
            master_pub = os.path.join(self.opts['pki_dir'], 'master.pub')
            if os.path.isfile(master_pub):
                master_finger = salt.utils.crypt.pem_finger(master_pub, sum_type=self.opts['hash_type'])

        opts = self.opts.copy()
        if self.opts['parallel']:
            # Force display_ssh_output to be False since the console will
            # need to be reset afterwards
            log.info(
                'Since parallel deployment is in use, ssh console output '
                'is disabled. All ssh output will be logged though'
            )
            opts['display_ssh_output'] = False

        local_master = master_name is None

        for name, profile in create_list:
            if name in (master_name, master_minion_name):
                # Already deployed, it's the master's minion
                continue

            if 'minion' in profile and profile['minion'].get('local_master', False) and \
                    profile['minion'].get('master', None) is not None:
                # The minion is explicitly defining a master and it's
                # explicitly saying it's the local one
                local_master = True

            if master_finger is not None and local_master is False:
                profile['master_finger'] = master_finger

            if master_host is not None:
                profile.setdefault('minion', {})
                profile['minion'].setdefault('master', master_host)

            if self.opts['parallel']:
                parallel_data.append({
                    'opts': opts,
                    'name': name,
                    'profile': profile,
                    'local_master': local_master
                })
                continue

            # Not deploying in parallel
            try:
                output[name] = self.create(
                    profile, local_master=local_master
                )
                if self.opts.get('show_deploy_args', False) is False \
                        and 'deploy_kwargs' in output \
                        and isinstance(output[name], dict):
                    output[name].pop('deploy_kwargs', None)
            except SaltCloudException as exc:
                log.error(
                    'Failed to deploy \'%s\'. Error: %s',
                    name, exc, exc_info_on_loglevel=logging.DEBUG
                )
                output[name] = {'Error': str(exc)}

        for name in dmap.get('destroy', ()):
            output[name] = self.destroy(name)

        if self.opts['parallel'] and parallel_data:
            if 'pool_size' in self.opts:
                pool_size = self.opts['pool_size']
            else:
                pool_size = len(parallel_data)
            log.info('Cloud pool size: %s', pool_size)
            output_multip = enter_mainloop(
                _create_multiprocessing, parallel_data, pool_size=pool_size)
            # We have deployed in parallel, now do start action in
            # correct order based on dependencies.
            if self.opts['start_action']:
                actionlist = []
                grp = -1
                for key, val in groupby(six.itervalues(dmap['create']), lambda x: x['level']):
                    actionlist.append([])
                    grp += 1
                    for item in val:
                        actionlist[grp].append(item['name'])

                out = {}
                for group in actionlist:
                    log.info('Running %s on %s', self.opts['start_action'], ', '.join(group))
                    client = salt.client.get_local_client()
                    out.update(client.cmd(
                        ','.join(group), self.opts['start_action'],
                        timeout=self.opts['timeout'] * 60, tgt_type='list'
                    ))
                for obj in output_multip:
                    next(six.itervalues(obj))['ret'] = out[next(six.iterkeys(obj))]
                    output.update(obj)
            else:
                for obj in output_multip:
                    output.update(obj)

        return output
1135955
def execute
      options = {
        :_method => :run,
        :_rebootable => true,
        :auto_reboot => false
      }
      opts = OptionParser.new do |opts|
        opts.banner = "Usage: vagrant vbguest [vm-name] "\
                      "[--do start|rebuild|install] "\
                      "[--status] "\
                      "[-f|--force] "\
                      "[-b|--auto-reboot] "\
                      "[-R|--no-remote] "\
                      "[--iso VBoxGuestAdditions.iso] "\
                      "[--no-cleanup]"

        opts.separator ""

        opts.on("--do COMMAND", [:start, :rebuild, :install], "Manually `start`, `rebuild` or `install` GuestAdditions.") do |command|
          options[:_method] = command
          options[:force] = true
        end

        opts.on("--status", "Print current GuestAdditions status and exit.") do
          options[:_method] = :status
          options[:_rebootable] = false
        end

        opts.on("-f", "--force", "Whether to force the installation. (Implied by --do start|rebuild|install)") do
          options[:force] = true
        end

        opts.on("--auto-reboot", "-b", "Allow rebooting the VM after installation. (when GuestAdditions won't start)") do
          options[:auto_reboot] = true
        end

        opts.on("--no-remote", "-R", "Do not attempt do download the iso file from a webserver") do
          options[:no_remote] = true
        end

        opts.on("--iso file_or_uri", "Full path or URI to the VBoxGuestAdditions.iso") do |file_or_uri|
          options[:iso_path] = file_or_uri
        end

        opts.on("--no-cleanup", "Do not run cleanup tasks after installation. (for debugging)") do
          options[:no_cleanup] = true
        end

        build_start_options(opts, options)
      end


      argv = parse_options(opts)
      return if !argv

      if argv.empty?
        with_target_vms(nil) { |vm| execute_on_vm(vm, options) }
      else
        argv.each do |vm_name|
          with_target_vms(vm_name) { |vm| execute_on_vm(vm, options) }
        end
      end
    end
459956
def main(): # mini/unit test
    
    options = optionsParser().parse_args()
    params = getSelectionParams(options)
    if options.list or options.details:
        specifiedMaps = filterMapNames(
            options.mapname,
            records = filterMapAttrs(**params),
            excludeRegex=options.exclude,
            closestMatch=options.best
        )
        if specifiedMaps:
            for v in specifiedMaps:
                if options.details: v.display()
                else:               print(v)
            print("Found %d maps that match given criteria."%(len(specifiedMaps)))
        else:
            print("No matching maps found.")
    else:
        try:
            specifiedMaps = selectMap(
                options.mapname,
                excludeName =options.exclude,
                closestMatch=options.best,
                **params)
        except Exception as e:
            specifiedMaps = []
            print("No matching maps found: %s"%e)
        if not isinstance(specifiedMaps, list):
            specifiedMaps = [specifiedMaps]
        for m in specifiedMaps:
            if options.path:    print(m.path)
            else:               print(m.name)
115030
protected final void writeMapTo( Map<String,Object> map , RawDataBuffer out )
    {
    	if (map == null)
    	{
    		out.writeInt(0);
    		return;
    	}
    	
        out.writeInt(map.size());
        if (!map.isEmpty())
        {
            Iterator<Map.Entry<String,Object>> allEntries = map.entrySet().iterator();
            while (allEntries.hasNext())
            {
                Map.Entry<String,Object> entry = allEntries.next();
                out.writeUTF(entry.getKey());
                out.writeGeneric(entry.getValue());
            }
        }
    }
710246
def do_execute(self):
        
        iquery = InstanceQuery()
        iquery.db_url = str(self.resolve_option("db_url"))
        iquery.user = str(self.resolve_option("user"))
        iquery.password = str(self.resolve_option("password"))
        props = str(self.resolve_option("custom_props"))
        if (len(props) > 0) and os.path.isfile(props):
            iquery.custom_properties = props
        iquery.query = str(self.resolve_option("query"))
        data = iquery.retrieve_instances()
        self._output.append(Token(data))
        return None
964624
def map_data(self, map_name):
    """"""
    with gfile.Open(os.path.join(self.data_dir, "Maps", map_name), "rb") as f:
      return f.read()
1055949
@GwtIncompatible("Unnecessary")
  private void outputNameMaps() throws IOException {

    String propertyMapOutputPath = null;
    String variableMapOutputPath = null;

    // Check the create_name_map_files FLAG.
    if (config.createNameMapFiles) {
      String basePath = getMapPath(config.jsOutputFile);

      propertyMapOutputPath = basePath + "_props_map.out";
      variableMapOutputPath = basePath + "_vars_map.out";
    }

    // Check the individual FLAGS.
    if (!config.variableMapOutputFile.isEmpty()) {
      if (variableMapOutputPath != null) {
        throw new FlagUsageException("The flags variable_map_output_file and "
            + "create_name_map_files cannot both be used simultaneously.");
      }

      variableMapOutputPath = config.variableMapOutputFile;
    }

    if (!config.propertyMapOutputFile.isEmpty()) {
      if (propertyMapOutputPath != null) {
        throw new FlagUsageException("The flags property_map_output_file and "
            + "create_name_map_files cannot both be used simultaneously.");
      }

      propertyMapOutputPath = config.propertyMapOutputFile;
    }

    // Output the maps.
    if (variableMapOutputPath != null && compiler.getVariableMap() != null) {
      compiler.getVariableMap().save(variableMapOutputPath);
    }

    if (propertyMapOutputPath != null && compiler.getPropertyMap() != null) {
      compiler.getPropertyMap().save(propertyMapOutputPath);
    }
  }
551456
def run(self, **kwargs):
        """"""
        if 'timestamp' not in kwargs:
            kwargs['timestamp'] = datetime.datetime.utcnow().isoformat()
        if 'version' not in kwargs:
            kwargs['version'] = "Not Defined" #bibcat.__version__
        # log.debug("kwargs: %s", pprint.pformat({k:v for k, v in kwargs.items()
        #                                         if k != "dataset"}))
        # log.debug("parents: %s", self.parents)
        for map_key, triple_map in self.triple_maps.items():
            if map_key not in self.parents:
                self.execute(triple_map, **kwargs)
368642
def run_mapper(self, stdin=sys.stdin, stdout=sys.stdout):
        
        self.init_hadoop()
        self.init_mapper()
        outputs = self._map_input((line[:-1] for line in stdin))
        if self.reducer == NotImplemented:
            self.writer(outputs, stdout)
        else:
            self.internal_writer(outputs, stdout)
27552
public void execute() {
		Map<Partition, List<Node>> map = getNodesByPartition();
		for (Partition partition : map.keySet()) {
			List<Node> nodes = map.get(partition);
			partition.execute(nodes);
		}
	}
595222
public void map(K key, V value,
                  OutputCollector<V, K> output, Reporter reporter)
    throws IOException {
    output.collect(value, key);
  }
1226074
def execute(self, input_data):
        '''  '''
        md5 = input_data['meta']['md5']
        response = requests.get('http://www.virustotal.com/vtapi/v2/file/report', 
                                params={'apikey':self.apikey,'resource':md5, 'allinfo':1})

        # Make sure we got a json blob back
        try:
            vt_output = response.json()
        except ValueError:
            return {'vt_error': 'VirusTotal Query Error, no valid response... past per min quota?'}
        
        # Just pull some of the fields
        output = {field:vt_output[field] for field in vt_output.keys() if field not in self.exclude}
        
        # Check for not-found
        not_found = False if output else True        

        # Add in file_type
        output['file_type'] = input_data['meta']['file_type']
        
        # Toss back a not found
        if not_found:
            output['not_found'] = True
            return output

        # Organize the scans fields
        scan_results = collections.Counter()
        for scan in vt_output['scans'].values():
            if 'result' in scan:
                if scan['result']:
                    scan_results[scan['result']] += 1
        output['scan_results'] = scan_results.most_common(5)
        return output
1051812
def map(self,index_name, index_type, map_value):
        '''
        
        '''
        request = self.session
        url = 'http://%s:%s/%s/%s/_mapping' % (self.host, self.port, index_name, index_type)
        content = { index_type : { 'properties' : map_value } }
        if self.verbose:
            print content
        response = request.put(url,content)
        return response
53374
def dump(self):
        """"""
        for modpath in sorted(self.map):
            title = 'Used by %s' % modpath
            print('\n' + title + '\n' + '-'*len(title))
            for origin in sorted(self.get_used_origins(modpath)):
                print('  %s' % origin)
305554
def _exec(self, query, **kwargs):
        """"""
        variables = {'entity': self.username,
                     'project': self.project, 'name': self.name}
        variables.update(kwargs)
        return self.client.execute(query, variable_values=variables)
996926
def Execute(self, *params, **kw):
        """"""
        fp = self.__expandparamstodict(params, kw)
        return self._get_subfolder('execute/', GPExecutionResult, fp)
499414
def handle(cls, vm, args):
        
        docker = Iaas.info(vm)
        if not docker:
            raise Exception('docker vm %s not found' % vm)

        if docker['state'] != 'running':
            Iaas.start(vm)

        # XXX
        remote_addr = docker['ifaces'][0]['ips'][0]['ip']

        port = unixpipe.setup(remote_addr, 'root', '/var/run/docker.sock')

        os.environ['DOCKER_HOST'] = 'tcp://localhost:%d' % port
        cls.echo('using DOCKER_HOST=%s' % os.environ['DOCKER_HOST'])

        subprocess.call(['docker'] + list(args))