MCPcopy Create free account
hub / github.com/saltstack/salt / run

Method run

salt/cloud/cli.py:34–367  ·  view source on GitHub ↗

Execute the salt-cloud command line

(self)

Source from the content-addressed store, hash-verified

32
33class SaltCloud(salt.utils.parsers.SaltCloudParser):
34 def run(self):
35 """
36 Execute the salt-cloud command line
37 """
38 # Parse shell arguments
39 self.parse_args()
40
41 salt_master_user = self.config.get("user")
42 if salt_master_user is None:
43 salt_master_user = salt.utils.user.get_user()
44
45 if not check_user(salt_master_user):
46 self.error(
47 "If salt-cloud is running on a master machine, salt-cloud "
48 "needs to run as the same user as the salt-master, '{0}'. "
49 "If salt-cloud is not running on a salt-master, the "
50 "appropriate write permissions must be granted to '{1}'. "
51 "Please run salt-cloud as root, '{0}', or change "
52 "permissions for '{1}'.".format(salt_master_user, syspaths.CONFIG_DIR)
53 )
54
55 try:
56 if self.config["verify_env"]:
57 verify_env(
58 [os.path.dirname(self.config["conf_file"])],
59 salt_master_user,
60 root_dir=self.config["root_dir"],
61 )
62 except OSError as err:
63 log.error("Error while verifying the environment: %s", err)
64 sys.exit(err.errno)
65
66 if self.options.update_bootstrap:
67 ret = salt.utils.cloud.update_bootstrap(self.config)
68 salt.output.display_output(ret, self.options.output, opts=self.config)
69 self.exit(salt.defaults.exitcodes.EX_OK)
70
71 log.info("salt-cloud starting")
72 try:
73 mapper = salt.cloud.Map(self.config)
74 except SaltCloudSystemExit as exc:
75 self.handle_exception(exc.args, exc)
76 except SaltCloudException as exc:
77 msg = "There was an error generating the mapper."
78 self.handle_exception(msg, exc)
79
80 names = self.config.get("names", None)
81 if names is not None:
82 filtered_rendered_map = {}
83 for map_profile in mapper.rendered_map:
84 filtered_map_profile = {}
85 for name in mapper.rendered_map[map_profile]:
86 if name in names:
87 filtered_map_profile[name] = mapper.rendered_map[map_profile][
88 name
89 ]
90 if filtered_map_profile:
91 filtered_rendered_map[map_profile] = filtered_map_profile

Callers 1

salt_cloudFunction · 0.95

Calls 15

handle_exceptionMethod · 0.95
interpolated_mapMethod · 0.95
delete_mapMethod · 0.95
print_confirmMethod · 0.95
get_vmnames_by_actionMethod · 0.95
map_dataMethod · 0.95
run_mapMethod · 0.95
check_userFunction · 0.90
verify_envFunction · 0.90
formatMethod · 0.80
exitMethod · 0.80
provider_listMethod · 0.80

Tested by

no test coverage detected