class GCPRedisSlaveSubstrate(Substrate): os_type = "Linux" provider_type = "GCP_VM" provider_spec = read_provider_spec("specs/substrate/gcp_spec_centos.yaml") provider_spec.spec["resources"]["sshKeys"] = [read_local_file("secrets/public_key")] readiness_probe = { "disabled": False, "delay_secs": "60", "connection_type": "SSH", "address": "@@{platform.networkInterfaces[0].accessConfigs[0].natIP}@@", "connection_port": 22, "credential": ref(DefaultCred), }
class DefaultProfile(Profile): # Deployments under this profile deployments = [NginxDeployment] # Profile Variables INSTANCE_PUBLIC_KEY = Variable.Simple(read_local_file( os.path.join("keys", "centos_pub")), runtime=True) HOSTNAME = Variable.Simple("nginx-server", runtime=True) ENABLE_ACCESS_LOG = Variable.WithOptions.Predefined.string( ["yes", "no"], default="no", is_mandatory=True, runtime=True ) STATIC_EXPIRATION_DAYS = Variable.Simple("365", runtime=True)
from calm.dsl.builtins import SimpleDeployment, SimpleBlueprint from calm.dsl.builtins import read_local_file, basic_cred from calm.dsl.builtins import AhvVmResources, AhvVmDisk, AhvVmNic, AhvVmGC, AhvVm from calm.dsl.builtins import action, CalmTask, CalmVariable # Change values based on your calm environment IMAGE_NAME = 'centos-7' NETWORK_NAME = 'External' # Password file located under './.local' CENTOS_PASSWD = read_local_file('centos') CENTOS_CRED = basic_cred('centos', CENTOS_PASSWD, name='CENTOS_CRED', default=True) class CentosVmResources(AhvVmResources): memory = 4 vCPUs = 2 cores_per_vCPU = 1 disks = [ AhvVmDisk.Disk.Scsi.cloneFromImageService(IMAGE_NAME, bootable=True) ] nics = [AhvVmNic.DirectNic.ingress(NETWORK_NAME)] guest_customization = AhvVmGC.CloudInit( config={ 'password': CENTOS_PASSWD, 'ssh_pwauth': True, 'chpasswd': {
import json from calm.dsl.builtins import AhvVmDisk, AhvVmNic, AhvVmGC from calm.dsl.builtins import ref, basic_cred, AhvVmResources, AhvVm from calm.dsl.builtins import vm_disk_package, read_local_file from calm.dsl.builtins import Service, Package, Substrate from calm.dsl.builtins import Deployment, Profile, Blueprint from calm.dsl.builtins import CalmVariable, CalmTask, action from calm.dsl.builtins import Ref, Metadata CENTOS_KEY = read_local_file("keys/centos") CENTOS_PUBLIC_KEY = read_local_file("keys/centos_pub") PROJECT_NAME = read_local_file("project_name") DSL_CONFIG = json.loads(read_local_file(".tests/config.json")) NTNX_LOCAL_ACCOUNT = DSL_CONFIG["ACCOUNTS"]["NTNX_LOCAL_AZ"] SUBNET_NAME = NTNX_LOCAL_ACCOUNT["SUBNETS"][0]["NAME"] Centos = basic_cred("centos", CENTOS_KEY, name="Centos", type="KEY", default=True) Era_Disk = vm_disk_package( name="era_disk", config={ # By default image type is set to DISK_IMAGE "image": { "source":
import json from calm.dsl.builtins import ref, basic_cred from calm.dsl.builtins import read_local_file, readiness_probe from calm.dsl.builtins import CalmTask as Task from calm.dsl.builtins import CalmVariable as Var from calm.dsl.builtins import action from calm.dsl.builtins import AhvVmDisk, AhvVmNic, AhvVmGC from calm.dsl.builtins import AhvVmResources, ahv_vm from calm.dsl.builtins import VmProfile, VmBlueprint from calm.dsl.builtins import Metadata, Ref # Credentials CENTOS_KEY = read_local_file("keys/centos") CENTOS_PUBLIC_KEY = read_local_file("keys/centos_pub") Centos = basic_cred("centos", CENTOS_KEY, name="Centos", type="KEY", default=True) DNS_SERVER = read_local_file(".tests/dns_server") # projects DSL_CONFIG = json.loads(read_local_file(".tests/config.json")) CENTOS_7_CLOUD_INIT = DSL_CONFIG["AHV"]["IMAGES"]["DISK"]["CENTOS_7_CLOUD_INIT"] NETWORK1 = DSL_CONFIG["AHV"]["NETWORK"]["VLAN1211"] PROJECT = DSL_CONFIG["PROJECTS"]["PROJECT1"] PROJECT_NAME = PROJECT["NAME"] class SmallAhvVmResources(AhvVmResources):
""" Hadoop Blueprint """ from calm.dsl.builtins import ref, basic_cred from calm.dsl.builtins import action from calm.dsl.builtins import CalmTask from calm.dsl.builtins import CalmVariable from calm.dsl.builtins import Service, Package, Substrate from calm.dsl.builtins import Deployment, Profile, Blueprint from calm.dsl.builtins import read_provider_spec, read_local_file CENTOS_PASSWD = read_local_file(".tests/password") DefaultCred = basic_cred("centos", CENTOS_PASSWD, name="default cred", default=True) class Hadoop_Master(Service): """Hadoop_Master service""" @action def __create__(): CalmTask.Exec.ssh(name="ConfigureMaster", filename="scripts/ConfigureMaster.sh") @action def __start__(): CalmTask.Exec.ssh( name="StartMasterServices", filename="scripts/StartMasterServices.sh" )
""" Exsiting machine example. """ import json from calm.dsl.builtins import ref, basic_cred from calm.dsl.builtins import action, parallel from calm.dsl.builtins import CalmTask from calm.dsl.builtins import CalmVariable from calm.dsl.builtins import Service, Package, Substrate from calm.dsl.builtins import Deployment, Profile, Blueprint from calm.dsl.builtins import provider_spec, read_local_file DNS_SERVER = read_local_file(".tests/dns_server") DSL_CONFIG = json.loads(read_local_file(".tests/config.json")) TEST_PC_IP = DSL_CONFIG["EXISTING_MACHINE"]["IP_1"] CRED_USERNAME = DSL_CONFIG["EXISTING_MACHINE"]["CREDS"]["LINUX"]["USERNAME"] CRED_PASSWORD = DSL_CONFIG["EXISTING_MACHINE"]["CREDS"]["LINUX"]["PASSWORD"] DefaultCred = basic_cred(CRED_USERNAME, CRED_PASSWORD, name="default cred", default=True) # def test_ping_code(): # """Check if we can reach the VM""" # from calm.dsl.tools import ping
""" Redis Cluster (Blueprint consists of single pod) """ from calm.dsl.builtins import basic_cred from calm.dsl.builtins import Service, Profile, Blueprint, PODDeployment from calm.dsl.builtins import read_spec, read_local_file ROOT_PASSWD = read_local_file("root_passwd") class RedisService(Service): pass class RedisK8SDeployment(PODDeployment): """ Redis Deployment on K8S """ containers = [RedisService] deployment_spec = read_spec("deployment.yaml") service_spec = read_spec("service.yaml") class RedisProfile(Profile): """ Application Profile """ deployments = [RedisK8SDeployment] class RedisK8SBlueprint(Blueprint):
from calm.dsl.builtins import ref, basic_cred, CalmTask from calm.dsl.builtins import CalmVariable, action from calm.dsl.builtins import Service, Package, Substrate from calm.dsl.builtins import Deployment, Profile, Blueprint from calm.dsl.builtins import read_provider_spec from calm.dsl.builtins import read_ahv_spec, read_vmw_spec from calm.dsl.builtins import vm_disk_package from calm.dsl.builtins import read_local_file CENTOS_KEY = read_local_file("secrets/private_key") DefaultCred = basic_cred("centos", CENTOS_KEY, name="CENTOS", type="KEY", default=True) class RedisMaster(Service): """Redis Master Service""" class AHVMasterPackage(Package): """AHV Redis MasterPackage""" services = [ref(RedisMaster)] @action def __install__(): CalmTask.Exec.ssh( name="PackageInstallTask", filename="scripts/Master_Package.sh", cred=ref(DefaultCred), )
from calm.dsl.builtins import ref, basic_cred, CalmVariable, CalmTask, action from calm.dsl.builtins import Service, Package, Substrate from calm.dsl.builtins import Deployment, Profile, Blueprint from calm.dsl.builtins import read_provider_spec, read_local_file AZURE_VM_PASSWD = read_local_file("passwd") class SampleService(Service): """Sample service""" ENV = CalmVariable.Simple("DEV") class SamplePackage(Package): """Example package with variables, install tasks and link to service""" foo = CalmVariable.Simple("bar") services = [ref(SampleService)] @action def __install__(): CalmTask.Exec.ssh(name="Task1", script="echo @@{foo}@@") class AzureVM(Substrate): """Azure VM config given by reading a spec file""" provider_type = "AZURE_VM" provider_spec = read_provider_spec("azure_spec.yaml")
from calm.dsl.cli import main as cli from calm.dsl.builtins import read_local_file, get_valid_identifier from calm.dsl.decompile.file_handler import get_bp_dir from calm.dsl.decompile import init_decompile_context from calm.dsl.config import get_context from calm.dsl.log import get_logging_handle from calm.dsl.cli.bps import ( get_blueprint_module_from_file, get_blueprint_class_from_module, ) LOG = get_logging_handle(__name__) BP_FILE = "tests/decompile/test_decompile.py" CRED_PASSWORD = read_local_file(".tests/password") class TestDecompile: def setup_method(self): self.created_bp_list = [] self.bp_dir_list = [] def teardown_method(self): for bp_name in self.created_bp_list: LOG.info("Deleting Blueprint {}".format(bp_name)) runner = CliRunner() result = runner.invoke(cli, ["delete", "bp", bp_name]) assert result.exit_code == 0 for dir_location in self.bp_dir_list:
""" Application Deployment K8s Containers Blueprint """ from calm.dsl.builtins import ref, basic_cred from calm.dsl.builtins import action from calm.dsl.builtins import CalmTask from calm.dsl.builtins import CalmVariable from calm.dsl.builtins import Service, Package, Substrate from calm.dsl.builtins import Deployment, Profile, Blueprint, PODDeployment from calm.dsl.builtins import read_provider_spec, read_spec, read_local_file NutanixPassword = read_local_file("nutanix_password") NutanixUser = read_local_file("nutanix_user") NutanixCred = basic_cred(NutanixUser, name="Nutanix", type="PASSWORD", password=NutanixPassword, default=True) class mongo_db_service(Service): @action def __create__(): CalmTask.HTTP.get( name="Get Data", url= "@@{data_url}@@/peaks-demo-app/master/db/mongo/data/peaksdata.json", content_type="application/json", status_mapping={200: True}, response_paths={"insert_script": "$.entities"})
Calm DSL .DEV Copenhagen Hybrid Cloud Blueprint author: [email protected] date: 2019-09-27 """ from calm.dsl.builtins import ref, basic_cred from calm.dsl.builtins import action, parallel from calm.dsl.builtins import CalmTask from calm.dsl.builtins import CalmVariable from calm.dsl.builtins import Service, Package, Substrate from calm.dsl.builtins import Deployment, Profile, Blueprint, PODDeployment from calm.dsl.builtins import provider_spec, read_provider_spec, read_spec, read_local_file ERA_KEY = read_local_file("era_key") CENTOS_KEY = read_local_file("centos_key") KARBON_KEY = read_local_file("karbon_key") DB_PASSWD = read_local_file("db_passwd") EraCreds = basic_cred("admin", ERA_KEY, name="era_creds") CentOsCreds = basic_cred("centos", CENTOS_KEY, name="centos_creds", type="KEY", default=True) KarbonCreds = basic_cred("admin", KARBON_KEY, name="karbon") class Postgres(Service): pass
""" Sample single vm example to convert python dsl to calm v3 api spec """ import sys from calm.dsl.builtins import port, ref, setvar, basic_cred from calm.dsl.builtins import Port, Service, Package, Substrate from calm.dsl.builtins import Deployment, Profile, Blueprint from calm.dsl.builtins import read_provider_spec, CalmVariable, read_local_file CRED_USERNAME = read_local_file(".tests/username") CRED_PASSWORD = read_local_file(".tests/password") DNS_SERVER = read_local_file(".tests/dns_server_two_vm_example") MYSQL_PORT = read_local_file(".tests/mysql_port") # Setting the recursion limit to max for sys.setrecursionlimit(100000) class MySQLService(Service): """Sample mysql service with inline port definition""" ports = [port(target_port=MYSQL_PORT)] class MySQLPackage(Package): """Example package with variables and link to service""" # use var_name = vartype(attrs) to define a package variable ENV = CalmVariable.Simple("DEV")
from calm.dsl.builtins import read_local_file, basic_cred # Change values based on your calm environment IMAGE_NAME = 'centos-7' NETWORK_NAME = 'Network-1' VM_USERNAME = '******' # Secret variables (.local file store) CENTOS_KEY = read_local_file('centos') ERA_PASSWORD_VALUE = read_local_file('era') DB_PASSWORD_VALUE = read_local_file('db_password') # Blueprint credentials CENTOS_CRED = basic_cred(VM_USERNAME, CENTOS_KEY, name='CENTOS_CRED', type='KEY', default=True) ERA_CRED = basic_cred('admin', ERA_PASSWORD_VALUE, name='ERA_CRED', type='PASSWORD')
""" Xtract Blueprint """ from calm.dsl.builtins import ref, basic_cred from calm.dsl.builtins import Service, Package, Substrate from calm.dsl.builtins import Deployment, Profile, Blueprint from calm.dsl.builtins import read_provider_spec, read_local_file ADMIN_PASSWD = read_local_file("admin_passwd") DefaultCred = basic_cred("admin", ADMIN_PASSWD, name="default cred", default=True) class XtractVM(Service): """Xtract service""" pass class XtractPackage(Package): """Xtract package""" services = [ref(XtractVM)] class XtractVMS(Substrate):
from calm.dsl.builtins import Brownfield as BF from calm.dsl.builtins import read_local_file INSTANCE_NAME = read_local_file("brownfield_instance_name") class AhvVmDeployment(BF.Deployment): # Note: If multiple instance with same name exists, send ip_address or instance_id too # Ex: instance = [BF.Vm.Ahv(name=<instance_name>, ip_address = [ip1, ip2], instance_id = 'instance_id')] instances = [BF.Vm.Ahv(INSTANCE_NAME)]
from calm.dsl.builtins import Brownfield as BF from calm.dsl.builtins import read_local_file VM_IP = read_local_file("vm_ip") class AhvVmDeployment(BF.Deployment): instances = [BF.Vm.Ahv(ip_address=[VM_IP])]
from calm.dsl.builtins import AhvVmDisk, AhvVmNic, AhvVmGC from calm.dsl.builtins import ref, basic_cred, AhvVmResources, AhvVm from calm.dsl.builtins import vm_disk_package, read_spec from calm.dsl.builtins import Service, Package, Substrate from calm.dsl.builtins import Deployment, Profile, Blueprint from calm.dsl.builtins import CalmVariable, CalmTask, action from calm.dsl.builtins import read_local_file CENTOS_PASSWORD = read_local_file("password") CENTOS_KEY = read_local_file("private_key") DefaultCred = basic_cred("centos", CENTOS_PASSWORD, name="CENTOS") CentosKeyCred = basic_cred( "centos", CENTOS_KEY, name="CENTOS_KEY", type="KEY", default=True ) Era_Disk = vm_disk_package( name="era_disk", config=read_spec("image_configs/era_disk.yaml") ) Virtio_CdRom = vm_disk_package( name="virtio_cdrom", config_file="image_configs/virtio_cdrom.yaml" ) class MySQLService(Service): """Sample mysql service""" ENV = CalmVariable.Simple("DEV")
from distutils.version import LooseVersion as LV from click.testing import CliRunner from calm.dsl.cli import main as cli from calm.dsl.builtins.models.metadata_payload import get_metadata_payload from calm.dsl.builtins import read_local_file from calm.dsl.config import get_context from calm.dsl.store import Version from calm.dsl.log import get_logging_handle LOG = get_logging_handle(__name__) DSL_PROJECT_PATH = "tests/project/test_project_in_pc.py" DSL_PROJECT_WITH_ENV_PATH = "tests/project/test_project_with_env.py" DSL_CONFIG = json.loads(read_local_file(".tests/config.json")) USER = DSL_CONFIG["USERS"][0] USER_NAME = USER["NAME"] # calm_version CALM_VERSION = Version.get_version("Calm") class TestProjectCommands: def setup_method(self): """"Reset the context changes""" ContextObj = get_context() ContextObj.reset_configuration() def teardown_method(self): """"Reset the context changes"""
from calm.dsl.builtins import ( ref, basic_cred, CalmVariable, CalmTask, action, ) from calm.dsl.builtins import Service, Package, Substrate from calm.dsl.builtins import Deployment, Profile, Blueprint from calm.dsl.builtins import read_provider_spec, read_local_file, read_spec from calm.dsl.builtins import readiness_probe CRED_USERNAME = read_local_file(".tests/username") CRED_PASSWORD = read_local_file(".tests/password") DNS_SERVER = read_local_file(".tests/dns_server") DefaultCred = basic_cred(CRED_USERNAME, CRED_PASSWORD, name="default cred", default=True) class AhvService(Service): """Sample mysql service""" ENV = CalmVariable.Simple("DEV") class AhvPackage(Package): """Example package with variables, install tasks and link to service"""
from calm.dsl.builtins import AhvVmDisk, AhvVmNic, AhvVmGC from calm.dsl.builtins import ref, basic_cred, AhvVmResources, AhvVm from calm.dsl.builtins import vm_disk_package, read_local_file from calm.dsl.builtins import Service, Package, Substrate from calm.dsl.builtins import Deployment, Profile, Blueprint from calm.dsl.builtins import CalmVariable, CalmTask, action from calm.dsl.builtins import Ref, Metadata CENTOS_KEY = read_local_file("keys/centos") CENTOS_PUBLIC_KEY = read_local_file("keys/centos_pub") PROJECT_NAME = read_local_file("project_name") Centos = basic_cred("centos", CENTOS_KEY, name="Centos", type="KEY", default=True) Era_Disk = vm_disk_package( name="era_disk", config={ # By default image type is set to DISK_IMAGE "image": { "source": "http://download.nutanix.com/era/1.1.1/ERA-Server-build-1.1.1-340d9db1118eac81219bec98507d4982045d8799.qcow2" } }, )
""" AHV_K8S_Discourse Blueprint """ from calm.dsl.builtins import ref, basic_cred from calm.dsl.builtins import action from calm.dsl.builtins import CalmTask from calm.dsl.builtins import CalmVariable from calm.dsl.builtins import Service, Package, Substrate from calm.dsl.builtins import Deployment, Profile, Blueprint, PODDeployment from calm.dsl.builtins import read_provider_spec, read_spec, read_local_file SSH_USERNAME = read_local_file("username") SSH_PASSWORD = read_local_file("password") DISCOURSE_PASSWORD = read_local_file("discourse_password") DefaultCred = basic_cred(SSH_USERNAME, SSH_PASSWORD, name="CENTOS", default=True) class AHVPostgresService(Service): """Postgres Service""" pass class AHVPostgresPackage(Package): """Postgres Package"""
from calm.dsl.builtins import basic_cred from calm.dsl.builtins import SimpleDeployment, SimpleBlueprint from calm.dsl.builtins import read_provider_spec from calm.dsl.builtins import CalmTask as Task from calm.dsl.builtins import CalmVariable as Var from calm.dsl.builtins import action, read_local_file SSH_PASSWD = read_local_file("passwd") CHEF_PASSWD = read_local_file("passwd") class ChefDeployment(SimpleDeployment): provider_spec = read_provider_spec("ahv_spec.yaml") @action def __install__(): Task.Exec.ssh(name="Install Chef", filename="scripts/Install.sh") @action def __create__(): Task.Exec.ssh(name="Configure", filename="scripts/Configure.sh") class ChefBlueprint(SimpleBlueprint): CHEF_SERVER_VERSION = Var.Simple.string("12.17.5", is_mandatory=True, runtime=True) CHEF_USERNAME = Var.Simple.string("chefadmin", is_mandatory=True,
import json from calm.dsl.builtins import ( ref, basic_cred, CalmVariable, CalmTask, action, Ref, Metadata, ) from calm.dsl.builtins import Service, Package, Substrate from calm.dsl.builtins import Deployment, Profile, Blueprint from calm.dsl.builtins import read_provider_spec, read_local_file CRED_USERNAME = read_local_file(".tests/username") CRED_PASSWORD = read_local_file(".tests/password") DNS_SERVER = read_local_file(".tests/dns_server") DSL_CONFIG = json.loads(read_local_file(".tests/config.json")) # project constants PROJECT = DSL_CONFIG["PROJECTS"]["PROJECT1"] PROJECT_NAME = PROJECT["NAME"] ENV_NAME = PROJECT["ENVIRONMENTS"][0]["NAME"] NTNX_LOCAL_ACCOUNT = DSL_CONFIG["ACCOUNTS"]["NTNX_LOCAL_AZ"] SUBNET_UUID = NTNX_LOCAL_ACCOUNT["SUBNETS"][0]["UUID"] class MySQLService(Service): """Sample mysql service"""
from calm.dsl.builtins import AhvVmDisk, AhvVmNic, AhvVmGC, AhvVmGpu from calm.dsl.builtins import basic_cred, ahv_vm_resources from calm.dsl.builtins import vm_disk_package, read_local_file from calm.dsl.builtins.models.metadata_payload import get_metadata_payload AhvVm = ahv_vm_resources() CENTOS_USERNAME = read_local_file(".tests/centos_username") CENTOS_PASSWORD = read_local_file(".tests/centos_password") CENTOS_SSH_USERNAME = read_local_file(".tests/centos_ssh_username") CENTOS_SSH_KEY = read_local_file(".tests/centos_ssh_key") DefaultCred = basic_cred(CENTOS_USERNAME, CENTOS_PASSWORD, name="CENTOS", default=True) DefaultKeyCred = basic_cred(CENTOS_SSH_USERNAME, CENTOS_SSH_KEY, name="CENTOS_KEY", type="key") Era = vm_disk_package(name="era", config_file="specs/era_image_config.yaml") class MyAhvVm(AhvVm): memory = 2 vCPUs = 2 cores_per_vCPU = 1 disks = [ AhvVmDisk(image_name="Centos7", bootable=True), AhvVmDisk.CdRom(image_name="SQLServer2014SP2"),
from calm.dsl.builtins import read_local_file CRED_USERNAME = read_local_file(".tests/username") CRED_PASSWORD = read_local_file(".tests/password") variable_list = [ {"value": {"value": "foo1_new_val"}, "context": "DefaultProfile", "name": "foo1"}, {"value": {"value": "foo2_new_val"}, "context": "DefaultProfile", "name": "foo2"}, ] substrate_list = [ { "value": { "readiness_probe": {"retries": "7", "connection_port": 22}, "spec": { "resources": { "nic_list": { "0": { "subnet_reference": { "kind": "subnet", "name": "", "uuid": "c37571b5-51d2-4340-8db0-d62c89ce3c9e", } } }, "serial_port_list": { "0": {"is_connected": False}, "1": {"is_connected": True}, }, "num_vcpus_per_socket": 2,
from calm.dsl.builtins import ref, basic_cred from calm.dsl.builtins import vm_disk_package, read_local_file from calm.dsl.builtins import Service, Package, Substrate from calm.dsl.builtins import Profile, Blueprint from calm.dsl.builtins import CalmVariable, CalmTask, action from calm.dsl.builtins import Brownfield as BF CENTOS_KEY = read_local_file(".tests/keys/centos") CENTOS_PUBLIC_KEY = read_local_file(".tests/keys/centos_pub") Centos = basic_cred("centos", CENTOS_KEY, name="Centos", type="KEY", default=True) Era_Disk = vm_disk_package( name="era_disk", config={ # By default image type is set to DISK_IMAGE "image": { "source": "http://download.nutanix.com/era/1.1.1/ERA-Server-build-1.1.1-340d9db1118eac81219bec98507d4982045d8799.qcow2" } }, ) class AhvVmService(Service): """Sample mysql service"""
import os from calm.dsl.builtins import Service, Package, Substrate from calm.dsl.builtins import Deployment, Profile, Blueprint from calm.dsl.builtins import CalmVariable as Variable from calm.dsl.builtins import CalmTask as Task from calm.dsl.builtins import action, parallel, ref, basic_cred from calm.dsl.builtins import read_local_file from calm.dsl.builtins import vm_disk_package, AhvVmDisk, AhvVmNic from calm.dsl.builtins import AhvVmGC, AhvVmResources, AhvVm # SSH Credentials CENTOS_USER = "******" CENTOS_KEY = read_local_file(os.path.join("keys", "centos")) CENTOS_PUBLIC_KEY = read_local_file(os.path.join("keys", "centos_pub")) CentosCred = basic_cred( CENTOS_USER, CENTOS_KEY, name="Centos", type="KEY", default=True, ) # OS Image details for VM CENTOS_IMAGE_SOURCE = "http://download.nutanix.com/calm/CentOS-7-x86_64-1810.qcow2" CentosPackage = vm_disk_package( name="centos_disk", config={"image": {"source": CENTOS_IMAGE_SOURCE}}, ) class HelloService(Service): """Sample Service"""
import json from calm.dsl.builtins import SimpleDeployment, SimpleBlueprint from calm.dsl.builtins import read_provider_spec, Ref, Metadata from calm.dsl.builtins import read_local_file, basic_cred DSL_CONFIG = json.loads(read_local_file(".tests/config.json")) CENTOS_KEY = read_local_file(".tests/keys/centos") CENTOS_PUBLIC_KEY = read_local_file(".tests/keys/centos_pub") # project constants PROJECT = DSL_CONFIG["PROJECTS"]["PROJECT1"] PROJECT_NAME = PROJECT["NAME"] ENV_NAME = PROJECT["ENVIRONMENTS"][0]["NAME"] Centos = basic_cred("centos", CENTOS_KEY, name="Centos", type="KEY", default=True) class VmDeployment(SimpleDeployment): """Single VM service""" # VM Spec provider_spec = read_provider_spec("specs/ahv_provider_spec.yaml") class SingleVmBlueprint(SimpleBlueprint):