Update the fileserver backends, requires that a salt.fileserver.Fileserver
    object be passed in
428360
def fileserver_update(fileserver):
    '''
    
    '''
    try:
        if not fileserver.servers:
            log.error(
                'No fileservers loaded, the master will not be able to '
                'serve files to minions'
            )
            raise salt.exceptions.SaltMasterError('No fileserver backends available')
        fileserver.update()
    except Exception as exc:
        log.error(
            'Exception %s occurred in file server update', exc,
            exc_info_on_loglevel=logging.DEBUG
        )
1192504
def __setup_fileserver(self):
        '''
        
        '''
        # Avoid circular import
        import salt.fileserver
        self.fs_ = salt.fileserver.Fileserver(self.opts)
        self._serve_file = self.fs_.serve_file
        self._file_find = self.fs_._find_file
        self._file_hash = self.fs_.file_hash
        self._file_hash_and_stat = self.fs_.file_hash_and_stat
        self._file_list = self.fs_.file_list
        self._file_list_emptydirs = self.fs_.file_list_emptydirs
        self._dir_list = self.fs_.dir_list
        self._symlink_list = self.fs_.symlink_list
        self._file_envs = self.fs_.file_envs
36617
def sync(opts,
         form,
         saltenv=None,
         extmod_whitelist=None,
         extmod_blacklist=None):
    '''
    
    '''
    if saltenv is None:
        saltenv = ['base']

    if extmod_whitelist is None:
        extmod_whitelist = opts['extmod_whitelist']
    elif isinstance(extmod_whitelist, six.string_types):
        extmod_whitelist = {form: extmod_whitelist.split(',')}
    elif not isinstance(extmod_whitelist, dict):
        log.error('extmod_whitelist must be a string or dictionary: %s',
                  extmod_whitelist)

    if extmod_blacklist is None:
        extmod_blacklist = opts['extmod_blacklist']
    elif isinstance(extmod_blacklist, six.string_types):
        extmod_blacklist = {form: extmod_blacklist.split(',')}
    elif not isinstance(extmod_blacklist, dict):
        log.error('extmod_blacklist must be a string or dictionary: %s',
                  extmod_blacklist)

    if isinstance(saltenv, six.string_types):
        saltenv = saltenv.split(',')
    ret = []
    remote = set()
    source = salt.utils.url.create('_' + form)
    mod_dir = os.path.join(opts['extension_modules'], '{0}'.format(form))
    touched = False
    with salt.utils.files.set_umask(0o077):
        try:
            if not os.path.isdir(mod_dir):
                log.info('Creating module dir \'%s\'', mod_dir)
                try:
                    os.makedirs(mod_dir)
                except (IOError, OSError):
                    log.error(
                        'Cannot create cache module directory %s. Check '
                        'permissions.', mod_dir
                    )
            fileclient = salt.fileclient.get_file_client(opts)
            for sub_env in saltenv:
                log.info(
                    'Syncing %s for environment \'%s\'', form, sub_env
                )
                cache = []
                log.info('Loading cache from %s, for %s', source, sub_env)
                # Grab only the desired files (.py, .pyx, .so)
                cache.extend(
                    fileclient.cache_dir(
                        source, sub_env, include_empty=False,
                        include_pat=r'E@\.(pyx?|so|zip)$', exclude_pat=None
                    )
                )
                local_cache_dir = os.path.join(
                        opts['cachedir'],
                        'files',
                        sub_env,
                        '_{0}'.format(form)
                        )
                log.debug('Local cache dir: \'%s\'', local_cache_dir)
                for fn_ in cache:
                    relpath = os.path.relpath(fn_, local_cache_dir)
                    relname = os.path.splitext(relpath)[0].replace(os.sep, '.')
                    if extmod_whitelist and form in extmod_whitelist and relname not in extmod_whitelist[form]:
                        continue
                    if extmod_blacklist and form in extmod_blacklist and relname in extmod_blacklist[form]:
                        continue
                    remote.add(relpath)
                    dest = os.path.join(mod_dir, relpath)
                    log.info('Copying \'%s\' to \'%s\'', fn_, dest)
                    if os.path.isfile(dest):
                        # The file is present, if the sum differs replace it
                        hash_type = opts.get('hash_type', 'md5')
                        src_digest = salt.utils.hashutils.get_hash(fn_, hash_type)
                        dst_digest = salt.utils.hashutils.get_hash(dest, hash_type)
                        if src_digest != dst_digest:
                            # The downloaded file differs, replace!
                            shutil.copyfile(fn_, dest)
                            ret.append('{0}.{1}'.format(form, relname))
                    else:
                        dest_dir = os.path.dirname(dest)
                        if not os.path.isdir(dest_dir):
                            os.makedirs(dest_dir)
                        shutil.copyfile(fn_, dest)
                        ret.append('{0}.{1}'.format(form, relname))

                    # If the synchronized module is an utils
                    # directory, we add it to sys.path
                    for util_dir in opts['utils_dirs']:
                        if mod_dir.endswith(util_dir) and mod_dir not in sys.path:
                            sys.path.append(mod_dir)

            touched = bool(ret)
            if opts['clean_dynamic_modules'] is True:
                current = set(_listdir_recursively(mod_dir))
                for fn_ in current - remote:
                    full = os.path.join(mod_dir, fn_)
                    if os.path.isfile(full):
                        touched = True
                        os.remove(full)
                # Cleanup empty dirs
                while True:
                    emptydirs = _list_emptydirs(mod_dir)
                    if not emptydirs:
                        break
                    for emptydir in emptydirs:
                        touched = True
                        shutil.rmtree(emptydir, ignore_errors=True)
        except Exception as exc:
            log.error('Failed to sync %s module: %s', form, exc)
    return ret, touched
813715
def update(self, of):
        """"""

        # The other values should be set when the file object is created with dataset.bsfile()
        for p in ('mime_type', 'preference', 'state', 'hash', 'modified', 'size', 'contents', 'source_hash', 'data'):
            setattr(self, p, getattr(of, p))

        return self
604010
def update(self, *args, **kwargs):
        
        if request.method == 'PUT':
            logging.warning("Called not implemented resource method PUT")

        resource = super(JsonServerResource, self).update(*args, **kwargs)

        if resource:
            return resource
        else:
            return NOT_FOUND
42680
def serve_file(self, load):
        '''
        
        '''
        ret = {'data': '',
               'dest': ''}

        if 'env' in load:
            # "env" is not supported; Use "saltenv".
            load.pop('env')

        if 'path' not in load or 'loc' not in load or 'saltenv' not in load:
            return ret
        if not isinstance(load['saltenv'], six.string_types):
            load['saltenv'] = six.text_type(load['saltenv'])

        fnd = self.find_file(load['path'], load['saltenv'])
        if not fnd.get('back'):
            return ret
        fstr = '{0}.serve_file'.format(fnd['back'])
        if fstr in self.servers:
            return self.servers[fstr](load, fnd)
        return ret
777031
def update_post(params)
      post_file   = params[:post][:name]
      post        = jekyll_post(post_file)
      yaml_config = merge_config(post.data, params)
      write_post_contents(params[:post][:content], yaml_config, post_file)

      post_file
    end
1123457
def update_items(self, ocean_backend, enrich_backend):
        """"""

        fltr = {
            'name': 'origin',
            'value': [self.perceval_backend.origin]
        }

        logger.debug("[update-items] Checking commits for %s.", self.perceval_backend.origin)

        git_repo = GitRepository(self.perceval_backend.uri, self.perceval_backend.gitpath)

        try:
            current_hashes = set([commit for commit in git_repo.rev_list()])
        except Exception as e:
            logger.error("Skip updating branch info for repo %s, git rev-list command failed: %s", git_repo.uri, e)
            return

        raw_hashes = set([item['data']['commit']
                          for item in ocean_backend.fetch(ignore_incremental=True, _filter=fltr)])

        hashes_to_delete = list(raw_hashes.difference(current_hashes))

        to_process = []
        for _hash in hashes_to_delete:
            to_process.append(_hash)

            if len(to_process) != MAX_BULK_UPDATE_SIZE:
                continue

            # delete documents from the raw index
            self.remove_commits(to_process, ocean_backend.elastic.index_url,
                                'data.commit', self.perceval_backend.origin)
            # delete documents from the enriched index
            self.remove_commits(to_process, enrich_backend.elastic.index_url,
                                'hash', self.perceval_backend.origin)

            to_process = []

        if to_process:
            # delete documents from the raw index
            self.remove_commits(to_process, ocean_backend.elastic.index_url,
                                'data.commit', self.perceval_backend.origin)
            # delete documents from the enriched index
            self.remove_commits(to_process, enrich_backend.elastic.index_url,
                                'hash', self.perceval_backend.origin)

        logger.debug("[update-items] %s commits deleted from %s with origin %s.",
                     len(hashes_to_delete), ocean_backend.elastic.anonymize_url(ocean_backend.elastic.index_url),
                     self.perceval_backend.origin)
        logger.debug("[update-items] %s commits deleted from %s with origin %s.",
                     len(hashes_to_delete), enrich_backend.elastic.anonymize_url(enrich_backend.elastic.index_url),
                     self.perceval_backend.origin)

        # update branch info
        self.delete_commit_branches(enrich_backend)
        self.add_commit_branches(git_repo, enrich_backend)
1317392
def update_backends(cls, id_mapping, custom_trees, backend=None):
        
        backend = Store.current_backend if backend is None else backend
        # Update the custom option entries for the current backend
        Store.custom_options(backend=backend).update(custom_trees)

        # Propagate option ids for non-selected backends
        for b in Store.loaded_backends():
            if b == backend:
                continue
            backend_trees = Store._custom_options[b]
            for (old_id, new_id) in id_mapping:
                tree = backend_trees.get(old_id, None)
                if tree is not None:
                    backend_trees[new_id] = tree
1106360
def update_build(self, updated_files):
        
        for f in updated_files:
            self.compiled_scripts[f] = self.compile_and_process(f)

        return self.collect_output()
304992
def upgradeUpload(self, file):
        """"""
        files = {'upfile': open(file, 'rb')}
        return self.__post_files('/upgrade/upload',
                                 files=files)
130544
def update_resources(self, data, type_, names=None, languages=None):
        
        UpdateResources(self.filename, data, type_, names, languages)
421941
function update(requestObj, callback) {

            var i, found, storedData, storage;

            storage = this;

            callback = callback || function(){};

            if ((typeof requestObj) === 'undefined' || requestObj === null) {
                callback(null);
                return this;
            }
            
            requestObj.config = {};
            requestObj.config.url = requestObj.config.url || this.url.put;
            requestObj.config.type = requestObj.config.type || this.constructor.REQUEST_TYPE_POST;

            if (requestObj.data) {
                for (i = 0; i < storage.preprocessors.length; i++) {
                    requestObj.data = storage.preprocessors[i](requestObj.data, requestObj);
                }
            }

            this.constructor._sendRequest(requestObj, function(data){
                for (i = 0; i < storage.processors.length; i++) {
                    data = storage.processors[i](data, requestObj);
                }
                callback(data);
            });

            return this;
        }
1038799
def update(self, name, **kwargs):
        
        # These arguments are allowed
        self.allowed('update', kwargs, ['hostname', 'port', 'status',
                     'storage_hostname', 'volume_type_name', 'size'])
        # Remove parameters that are None
        kwargs = self.unused(kwargs)
        return self.http_post('/nodes/%s' % name, params=kwargs)
794923
def update_file(finfo, sample_info, config, pass_uptodate=False):
    
    storage_dir = utils.safe_makedir(_get_storage_dir(finfo, config))
    if finfo.get("type") == "directory":
        return _copy_finfo_directory(finfo, storage_dir)
    else:
        return _copy_finfo(finfo, storage_dir, pass_uptodate=pass_uptodate)
991681
def serve_file(load, fnd):
    '''
    
    '''
    ret = {'data': '',
           'dest': ''}
    required_load_keys = ('path', 'loc', 'saltenv')
    if not all(x in load for x in required_load_keys):
        log.debug(
            'Not all of the required keys present in payload. Missing: %s',
            ', '.join(required_load_keys.difference(load))
        )
        return ret
    if not fnd['path']:
        return ret
    ret['dest'] = fnd['rel']
    gzip = load.get('gzip', None)
    fpath = os.path.normpath(fnd['path'])
    with salt.utils.files.fopen(fpath, 'rb') as fp_:
        fp_.seek(load['loc'])
        data = fp_.read(__opts__['file_buffer_size'])
        if data and six.PY3 and not salt.utils.files.is_binary(fpath):
            data = data.decode(__salt_system_encoding__)
        if gzip and data:
            data = salt.utils.gzip_util.compress(data, gzip)
            ret['gzip'] = gzip
        ret['data'] = data
    return ret
1148776
private void updateServerStart(UpdateServerHeartbeat update)
  {
    // internal communication is non-ssl
    boolean isSSL = false;
    
    ServerHeartbeat server = _root.createServer(update.getAddress(),
                                                update.getPort(),
                                                isSSL,
                                                0,
                                                getCluster());
    
    server.setDisplayName(update.getDisplayName());
    //server.setMachineHash(serverUpdate.getMachineHash());

    updateServer(server, update);
    
    if (server.getRack() != null) {
      server.getRack().update();
    }
  }