in hostfactory/host_provider/src/cyclecloud_provider.py [0:0]
def generate_sample_template(self):
buckets = self.cluster.get_buckets()
template_dict = {}
for bucket in buckets:
autoscale_enabled = bucket.software_configuration.get("autoscaling", {}).get("enabled", False)
if not autoscale_enabled:
print("Autoscaling is disabled in CC for nodearray %s" % bucket.nodearray, file=sys.stderr)
continue
if template_dict.get(bucket.nodearray) is None:
template_dict[bucket.nodearray] = {}
template_dict[bucket.nodearray]["templateId"] = bucket.nodearray
template_dict[bucket.nodearray]["attributes"] = {}
# Assuming slot size with ncpus = 1 and nram = 4096
template_dict[bucket.nodearray]["attributes"]["type"] = ["String", "X86_64"]
template_dict[bucket.nodearray]["attributes"]["nram"] = ["Numeric", "4096"]
template_dict[bucket.nodearray]["attributes"]["ncpus"] = ["Numeric", "1"]
template_dict[bucket.nodearray]["attributes"]["ncores"] = ["Numeric", "1"]
template_dict[bucket.nodearray]["vmTypes"] = {}
if self.config.get("symphony.ncpus_use_vcpus", True):
weight = bucket.resources.get("ncores", bucket.vcpu_count)
else:
weight = bucket.resources.get("ncores", bucket.pcpu_count)
# Here maxNumber is defined based on SKU with lowest weight.
template_dict[bucket.nodearray]["maxNumber"] = (bucket.max_count * weight)
template_dict[bucket.nodearray]["vmTypes"].update({bucket.vm_size: weight})
else:
weight = bucket.resources.get("ncores", bucket.vcpu_count)
template_dict[bucket.nodearray]["vmTypes"].update({bucket.vm_size: weight})
templates = {"templates": list(template_dict.values())}
print(json.dumps(templates, indent=4))