in lib/muchos/azure.py [0:0]
def add_specialized_configs(self, hosts_file):
if self.config.use_multiple_vmss():
vmss_hosts = open(
path.join(
self.config.deploy_path, "conf/azure_vmss_to_hosts.conf"
),
"r",
)
print("\n", file=hosts_file)
for line in vmss_hosts:
print(line.rstrip("\n"), file=hosts_file)
for curr_vmss in self.config.azure_multiple_vmss_vars["vars_list"]:
vmss_group_name = (
self.config.cluster_name + "-" + curr_vmss["name_suffix"]
)
profile = curr_vmss["perf_profile"]
with open(
path.join(
self.config.deploy_path,
"ansible/group_vars/"
+ vmss_group_name.replace("-", "_"),
),
"w",
) as vmss_file:
for (name, value) in self.config.items(profile):
print("{0}: {1}".format(name, value), file=vmss_file)
# use VMSS-specific mount root if one is defined or
# the global mount root if there is no VMSS-specific value
curr_mount_root = curr_vmss.get(
"mount_root", self.config.mount_root()
)
# write the mount root out to the per-VMSS group vars
print(
"{0}: {1}".format("mount_root", curr_mount_root),
file=vmss_file,
)
# also include per-VMSS worker_data_dirs
curr_worker_dirs = self.config.data_dirs_internal(
"worker",
curr_vmss["data_disk_count"],
curr_mount_root,
curr_vmss["sku"],
)
print(
"{0}: {1}".format(
"worker_data_dirs",
curr_worker_dirs,
),
file=vmss_file,
)
# per-VMSS default_data_dirs
curr_default_dirs = self.config.data_dirs_internal(
"default",
curr_vmss["data_disk_count"],
curr_mount_root,
curr_vmss["sku"],
)
print(
"{0}: {1}".format(
"default_data_dirs",
curr_default_dirs,
),
file=vmss_file,
)
# also write out per-VMSS disk path and pattern
# using the global value from muchos.props as default
# if the VMSS does not define a custom value
print(
"{0}: {1}".format(
"azure_disk_device_path",
curr_vmss.get(
"azure_disk_device_path",
self.config.azure_disk_device_path(),
),
),
file=vmss_file,
)
print(
"{0}: {1}".format(
"azure_disk_device_pattern",
curr_vmss.get(
"azure_disk_device_pattern",
self.config.azure_disk_device_pattern(),
),
),
file=vmss_file,
)
# these nested loops are a tight (if slightly less
# readable way) of creating the various directory ordinals
for dirtype in ["default", "worker"]:
for ordinal in range(3):
print(
"{0}: {1}".format(
"{0}dir_ordinal{1}".format(
dirtype, ordinal
),
0
if len(
curr_default_dirs
if dirtype == "default"
else curr_worker_dirs
)
< ordinal + 1
else ordinal,
),
file=vmss_file,
)