MCPcopy
hub / github.com/saltstack/salt / update

Method update

salt/utils/gitfs.py:3544–3592  ·  view source on GitHub ↗

.. versionchanged:: 2018.3.0 The remotes argument was added. This being a list of remote URLs, it will only update matching remotes. This actually matches on repo.id Execute a git fetch on all of the repos and perform maintenance on the f

(self, remotes=None)

Source from the content-addressed store, hash-verified

3542 return locked, errors
3543
3544 def update(self, remotes=None):
3545 """
3546 .. versionchanged:: 2018.3.0
3547 The remotes argument was added. This being a list of remote URLs,
3548 it will only update matching remotes. This actually matches on
3549 repo.id
3550
3551 Execute a git fetch on all of the repos and perform maintenance on the
3552 fileserver cache.
3553 """
3554 # data for the fileserver event
3555 data = {"changed": False, "backend": "gitfs"}
3556
3557 data["changed"] = self.clear_old_remotes()
3558 if self.fetch_remotes(remotes=remotes):
3559 data["changed"] = True
3560
3561 # A masterless minion will need a new env cache file even if no changes
3562 # were fetched.
3563 refresh_env_cache = self.opts["__role"] == "minion"
3564
3565 if data["changed"] is True or not os.path.isfile(self.env_cache):
3566 env_cachedir = os.path.dirname(self.env_cache)
3567 if not os.path.exists(env_cachedir):
3568 os.makedirs(env_cachedir)
3569 refresh_env_cache = True
3570
3571 if refresh_env_cache:
3572 new_envs = self.envs(ignore_cache=True)
3573 with salt.utils.files.fopen(self.env_cache, "wb+") as fp_:
3574 fp_.write(salt.payload.dumps(new_envs))
3575 log.trace("Wrote env cache data to %s", self.env_cache)
3576
3577 # if there is a change, fire an event
3578 if self.opts.get("fileserver_events", False):
3579 with salt.utils.event.get_event(
3580 "master",
3581 self.opts["sock_dir"],
3582 opts=self.opts,
3583 listen=False,
3584 ) as event:
3585 event.fire_event(data, tagify(["gitfs", "update"], prefix="fileserver"))
3586 try:
3587 salt.fileserver.reap_fileserver_cache_dir(
3588 self.hash_cachedir, self.find_file
3589 )
3590 except OSError:
3591 # Hash file won't exist if no files have yet been served up
3592 pass
3593
3594 def update_intervals(self):
3595 """

Callers 15

_run_with_coverageFunction · 0.45
__init__Method · 0.45
upload_artifactsFunction · 0.45
sync_os_labelsFunction · 0.45
_environment_slugsFunction · 0.45
__call__Method · 0.45
__call__Method · 0.45
get_salt_releasesFunction · 0.45
get_file_checksumFunction · 0.45
download_fileFunction · 0.45
download_artifactFunction · 0.45

Calls 11

clear_old_remotesMethod · 0.95
fetch_remotesMethod · 0.95
tagifyFunction · 0.90
traceMethod · 0.80
existsMethod · 0.45
envsMethod · 0.45
writeMethod · 0.45
dumpsMethod · 0.45
getMethod · 0.45
get_eventMethod · 0.45
fire_eventMethod · 0.45

Tested by 15

__init__Method · 0.36
__eauthMethod · 0.36
salt_master_factoryFunction · 0.36
add_profile_configMethod · 0.36
file_checksumMethod · 0.36
salt_master_factoryFunction · 0.36
salt_masterFunction · 0.36
runaway_minionFunction · 0.36
existing_certFunction · 0.36
existing_privkeyFunction · 0.36