class PHPDeployment(SimpleDeployment): """PHP deployment description""" # Add dependency to MySQL and to K8SDeployment1(deployment-level) dependencies = [ref(MySQLDeployment), ref(K8SDeployment1)] # Variables foo = Var("baz") # VM Spec provider_spec = read_provider_spec("specs/ahv_provider_spec.yaml") # Deployment level properties max_replicas = "2" # Service actions @action def test_action(): blah = Var("2") # noqa Task.Exec.ssh(name="Task6", script='echo "Hello"') Task.Exec.ssh(name="Task7", script='echo "Hello again"') @action def __install__(): Task.Exec.ssh(name="Task8", script="echo @@{foo}@@")
class AHVVMforPHP(Substrate): """AHV VM config given by reading a spec file""" provider_spec = read_provider_spec("specs/ahv_provider_spec.yaml") provider_spec.spec["resources"]["nic_list"][0]["subnet_reference"][ "uuid" ] = SUBNET_UUID
class CreateELBSubstrate(Substrate): """ Existing Machine VM3 Substrate """ provider_type = "EXISTING_VM" provider_spec = read_provider_spec("vm3_em_spec.yaml") readiness_probe = {"credential": ref(ROOT)}
class VmDeployment(SimpleDeployment): """Single VM service""" # VM Spec provider_spec = read_provider_spec("specs/ahv_provider_spec.yaml") provider_spec.spec["resources"]["nic_list"][0]["subnet_reference"][ "uuid"] = SUBNET_UUID
class PostgresEraSubstrate(Substrate): os_type = 'Linux' provider_type = 'EXISTING_VM' provider_spec = read_provider_spec('specs/postgres_era.yaml') readiness_probe = readiness_probe( connection_type='SSH', disabled=True, retries='5', connection_port=22, address='@@{ip_address}@@', delay_secs='60', credential=ref(CENTOS_CRED) ) @action def __pre_create__(self): CalmTask.SetVariable.escript(filename='scripts/era_get_profile_ids.py', name='get profile ids', variables=['CLUSTER_ID', 'SOFTWARE_ID', 'SOFTWARE_VERSION', 'COMPUTE_ID', 'NETWORK_ID', 'DB_PARAMETER', 'SLA_ID']) CalmTask.SetVariable.escript(filename='scripts/era_initiate_provision.py', name='initiate db provision', variables=['OPERATION_ID']) CalmTask.Exec.escript(filename='scripts/era_wait_for_operation.py', name='wait for operation') CalmTask.SetVariable.escript(filename='scripts/era_get_db_details.py', name='get db details', variables=['DB_ID', 'DBSERVER_ID', 'DBSERVER_IP']) @action def __post_delete__(self): CalmTask.Exec.escript(filename='scripts/era_delete_database.py', name='delete_postgres')
class AHV_Worker(Substrate): """ Worker AHV Spec Default 2 CPU & 2 GB of memory 3 disks (3 X container data) """ provider_spec = read_provider_spec("ahv_spec_worker.yaml")
class AHV_Master(Substrate): """ Master AHV Spec Default 2 CPU & 2 GB of memory 6 disks (3 X etcd data & 3 X container data) """ provider_spec = read_provider_spec("ahv_spec_master.yaml")
class AHVPostgres(SimpleDeployment): """ AHV Postgres Deployment """ provider_spec = read_provider_spec("ahv_spec.yaml") @action def __install__(): Task.Exec.ssh(name="Install Postgres", filename="scripts/postgres_PackageInstallTask.sh")
class eGenterpriseSubstrate(Substrate): os_type = "Windows" provider_spec = read_provider_spec("ahv_spec_win.yaml") readiness_probe = { "disabled": False, "delay_secs": "90", "connection_type": "POWERSHELL", "connection_port": 5985, "credential": ref(DefaultCred), }
class XtractVMS(Substrate): """Xtract Substrate""" provider_spec = read_provider_spec("ahv_spec.yaml") readiness_probe = { "disabled": True, "delay_secs": "0", "connection_type": "SSH", "connection_port": 22, "credential": ref(DefaultCred), }
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 AWSRedisMasterSubstrate(Substrate): provider_spec = read_provider_spec("specs/substrate/aws_spec_centos.yaml") provider_spec.spec["name"] = "Redis_Master-@@{calm_array_index}@@-@@{calm_random}@@" provider_type = "AWS_VM" os_type = "Linux" readiness_probe = { "disabled": False, "delay_secs": "60", "connection_type": "SSH", "connection_port": 22, "credential": ref(DefaultCred), }
class HaProxy_AHV(Substrate): """HaProxy AHV Substrate""" provider_spec = read_provider_spec("ahv_spec.yaml") provider_spec.spec["name"] = "ha-@@{calm_time}@@" readiness_probe = { "disabled": False, "delay_secs": "10", "connection_type": "SSH", "connection_port": 22, "credential": ref(CentOsCreds), }
class AzureRedisSlaveSubstrate(Substrate): os_type = "Linux" provider_type = "AZURE_VM" provider_spec = read_provider_spec("specs/substrate/azure_spec_centos.yaml") provider_spec.spec["name"] = "Redis_Slave-@@{calm_array_index}@@-@@{calm_random}@@" readiness_probe = { "disabled": False, "delay_secs": "60", "connection_type": "SSH", "connection_port": 22, "credential": ref(DefaultCred), }
class Hadoop_Slave_AHV(Substrate): """Hadoop Slave Substrate""" provider_spec = read_provider_spec("ahv_spec.yaml") provider_spec.spec["name"] = "Hadoop_Slave-@@{calm_array_index}@@-@@{calm_time}@@" readiness_probe = { "disabled": False, "delay_secs": "0", "connection_type": "SSH", "connection_port": 22, "credential": ref(DefaultCred), }
class AhvSubstrate(Substrate): """AHV VM config given by reading a spec file""" provider_spec = read_provider_spec("specs/ahv_provider_spec.yaml") provider_spec_editables = read_spec("specs/ahv_substrate_editable.yaml") readiness_probe = readiness_probe( connection_type="SSH", credential=ref(DefaultCred), disabled=True, editables_list=["connection_port", "retries"], )
class WebServer2_AWS(Substrate): """WebServer2 AWS Substrate""" provider_type = "AWS_VM" provider_spec = read_provider_spec("aws_spec.yaml") provider_spec.spec["name"] = "wb2-aws-@@{calm_time}@@" readiness_probe = { "disabled": False, "delay_secs": "60", "connection_type": "SSH", "connection_port": 22, "credential": ref(CentOsCreds), }
class Locust_AHV(Substrate): """Locust Load Generator AHV Substrate""" provider_spec = read_provider_spec("ahv_spec.yaml") provider_spec.spec["name"] = "Locust-@@{calm_time}@@" provider_spec.spec["resources"]["memory_size_mib"] = 2048 readiness_probe = { "disabled": False, "delay_secs": "0", "connection_type": "SSH", "connection_port": 22, "credential": ref(CentOsCreds), }
class CentosDeployment(SimpleDeployment): provider_spec = read_provider_spec('specs/centos-8.yaml') os_type = 'Linux' @action def __create__(self): CalmTask.Exec.escript(name='add_vm_to_hycu', filename='scripts/add_vm_to_hycu.py') @action def __install__(self): # CalmTask.Exec.ssh(name='Update CentOS', script='sudo yum -y --quiet update') CalmTask.Exec.ssh(name='Update CentOS', script='echo "hello world"')
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 MSSQLDeployment(SimpleDeployment): provider_spec = read_provider_spec("ahv_spec.yaml") os_type = "Windows" @action def __install__(): CalmTask.Exec.powershell(name="PreRequisite", filename="scripts/PreRequisite.ps1") CalmTask.Exec.powershell(name="Install MSSQL", filename="scripts/Install.ps1") CalmTask.Exec.powershell(name="Open Firewall", filename="scripts/OpenFirewall.ps1")
class VM_AHV_Small_Substrate(Substrate): os_type = "Windows" provider_type = "AHV_VM" provider_spec = read_provider_spec("specs/vdi-spec.yaml") provider_spec.spec["resources"]["guest_customization"]["sysprep"][ "unattend_xml"] = read_file(os.path.join("scripts", "Autounattend.xml")) readiness_probe = { "credential": ref(Windows_Local_Administrator), "connection_type": "POWERSHELL", "connection_port": 5985, "delay_secs": "120", "retries": "20", }
class AristaSubstrate(Substrate): os_type = 'Linux' provider_type = 'EXISTING_VM' provider_spec = read_provider_spec('specs/arista_specs.yaml') readiness_probe = readiness_probe( connection_type='SSH', disabled=True, retries='5', connection_port=22, address='@@{ip_address}@@', delay_secs='60', credential=ref(ARISTA_CRED) )
class RemoteVMS(Substrate): """Remote Desktop Substrate""" provider_spec = read_provider_spec('templates/singleVM_1nic_domain.yaml') readiness_probe = { 'disabled': True, 'connection_type': 'POWERSHELL', 'connection_port': 5985, 'credential': ref(LAB_DEFAULT) } os_type = 'Windows' @action def __pre_create__(self): CalmTask.SetVariable.escript(name='set lab network', filename='scripts/set_network_uuid.py', variables=['EXTERNAL_NETWORK'])
class SRV1VMS(Substrate): """SRV1 Substrate""" provider_spec = read_provider_spec('templates/mcsa-20-41-SRV1.yaml') readiness_probe = { 'disabled': True, 'connection_type': 'POWERSHELL', 'connection_port': 5985, 'credential': ref(LAB_DEFAULT) } os_type = 'Windows' @action def __pre_create__(self): CalmTask.SetVariable.escript(name='set lab network', filename='scripts/set_network_uuid.py', variables=['LAB_NETWORK'])
class MySQLDeployment(SimpleDeployment): """MySQL deployment description""" ENV = Var.WithOptions.Predefined.string(["DEV", "PROD"], default="DEV", is_mandatory=True, runtime=True) # VM Spec provider_spec = read_provider_spec("specs/ahv_provider_spec.yaml") # All service, package and substrate system actions @action def __install__(): Task.Exec.ssh(name="Task1", filename="scripts/mysql_install_script.sh") @action def __start__(): Task.Exec.ssh(name="Task2", script="echo 'Service start in ENV=@@{ENV}@@'") @action def __stop__(): Task.Exec.ssh(name="Task3", script="echo 'Service stop in ENV=@@{ENV}@@'") @action def __pre_create__(): Task.Exec.escript(name="Pre Create Task", script="print 'Hello!'") # Custom service actions @action def custom_action_1(): blah = Var("2") # noqa Task.Exec.ssh(name="Task4", script='echo "Hello"') Task.Exec.ssh(name="Task5", script='echo "Hello again"') @action def custom_action_2(): with parallel( ): # All tasks within this context will be run in parallel Task.Exec.ssh(name="Task41", script="date") Task.Exec.ssh(name="Task51", script="date")
class VmDeployment(SimpleDeployment): """Single VM service""" # VM Spec provider_spec = read_provider_spec("specs/ahv_provider_spec.yaml")
class AHVPostgresSubstrate(Substrate): """Postgres Substrate""" provider_spec = read_provider_spec("ahv_spec.yaml")
class SampleVM(Substrate): """Azure VM config given by reading a spec file""" os_type = "Windows" provider_type = "AZURE_VM" provider_spec = read_provider_spec("provider_spec.yaml")
class VMWSubstrate(Substrate): os_type = "Linux" provider_type = "VMWARE_VM" provider_spec = read_provider_spec( "../../cli/blueprints/provider_spec.yaml")