Exemplo n.º 1
0
class TestDecompile(Blueprint):
    """Calm DSL .NEXT demo"""

    credentials = [
        basic_cred(CRED_USERNAME, CRED_PASSWORD),
        GLOBAL_BP_CRED,
        basic_cred(CRED_USERNAME, CRED_PASSWORD, name="while"),
    ]
    services = [MySQLService, PHPService]
    packages = [MySQLPackage, PHPPackage, Era_Disk]
    substrates = [AHVVMforMySQL, AHVVMforPHP]
    profiles = [DefaultProfile]
Exemplo n.º 2
0
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,
                                      runtime=True)
    CHEF_PASSWORD = Var.Simple.Secret(CHEF_PASSWD,
                                      is_hidden=True,
                                      is_mandatory=True,
                                      runtime=True)
    CHEF_ORG_NAME = Var.Simple.string("calm-dev",
                                      is_mandatory=True,
                                      runtime=True)
    FIRST_NAME = Var.Simple.string("first_name",
                                   is_mandatory=True,
                                   runtime=True)
    MIDDLE_NAME = Var.Simple.string("middle_name",
                                    is_mandatory=True,
                                    runtime=True)
    LAST_NAME = Var.Simple.string("last_name", is_mandatory=True, runtime=True)
    EMAIL = Var.Simple.string("*****@*****.**",
                              is_mandatory=True,
                              runtime=True)
    CHEF_ORG_FULL_NAME = Var.Simple.string("example",
                                           is_mandatory=True,
                                           runtime=True)

    credentials = [
        basic_cred("centos", SSH_PASSWD, name="CENTOS", default=True)
    ]
    deployments = [ChefDeployment]
Exemplo n.º 3
0
class AzureBlueprint(Blueprint):
    """Sample azure blueprint"""

    credentials = [basic_cred("azureusername", AZURE_VM_PASSWD, default=True)]
    services = [SampleService]
    packages = [SamplePackage]
    substrates = [AzureVM]
    profiles = [DefaultProfile]
Exemplo n.º 4
0
class K8SBlueprint(Blueprint):
    """Calm Kubernetes POD Support demo"""

    credentials = [basic_cred(CRED_USERNAME, CRED_PASSWORD, default=True)]
    services = [MySQLService, PHPService]
    packages = [MySQLPackage, PHPPackage]
    substrates = [AHVVMforMySQL, AHVVMforPHP]
    profiles = [DefaultProfile]
class SampleBlueprint(Blueprint):
    """Sample blueprint"""

    credentials = [basic_cred("username", "password", default=True)]
    services = [SampleService]
    packages = [SamplePackage]
    substrates = [SampleVM]
    profiles = [DefaultProfile]
Exemplo n.º 6
0
class XtractDslBlueprint(SimpleBlueprint):
    """Xtract Blueprint"""

    credentials = [
        basic_cred("admin", ADMIN_PASSWD, name="default cred", default=True)
    ]
    nameserver = Var("10.40.64.15", label="Local DNS resolver")
    deployments = [XtractDeployment]
Exemplo n.º 7
0
class DownloadablImageBp(Blueprint):
    """Downloadable Image demo"""

    credentials = [basic_cred(CRED_USERNAME, CRED_PASSWORD, default=True)]
    services = [MySQLService]
    packages = [MySQLPackage, Virtio]
    substrates = [AHVVMforMySQL]
    profiles = [DefaultProfile]
Exemplo n.º 8
0
class TwoBlueprint(Blueprint):
    """sample bp description"""

    credentials = [basic_cred(CRED_USERNAME, CRED_PASSWORD, default=True)]
    services = [MySQLService, PHPService]
    packages = [MySQLPackage, PHPPackage]
    substrates = [AHVMedVM, AHVMedVMForPHP]
    profiles = [NxProfile]
Exemplo n.º 9
0
class NextDslBlueprint(Blueprint):
    """Calm DSL .NEXT demo"""

    credentials = [
        basic_cred(CRED_USERNAME, CRED_PASSWORD, default=True),
    ]
    services = [MySQLService, PHPService]
    packages = [MySQLPackage, PHPPackage]
    substrates = [AHVVMforMySQL, AHVVMforPHP]
    profiles = [DefaultProfile]
Exemplo n.º 10
0
class KubernetesDslBlueprint(Blueprint):
    """Kubernetes blueprint"""

    profiles = [Nutanix]
    services = [Master, Worker]
    substrates = [AHV_Master, AHV_Worker]
    packages = [MasterPackage, WorkerPackage]
    credentials = [
        basic_cred("centos", CENTOS_PASSWD, name="CENTOS", default=True)
    ]
Exemplo n.º 11
0
class NextDslBlueprint(Blueprint):
    """Calm DSL .NEXT demo"""

    credentials = [
        basic_cred(CRED_USERNAME, CRED_PASSWORD, default=True),
        secret_cred("root2", secret="admin_pass", name="secret1"),
        secret_cred("root3", secret="foo", name="secret2"),
    ]
    services = [MySQLService, PHPService]
    packages = [MySQLPackage, PHPPackage]
    substrates = [AHVVMforMySQL, AHVVMforPHP]
    profiles = [DefaultProfile]
class SimpleLampBlueprint(SimpleBlueprint):
    """Simple blueprint Spec"""

    nameserver = Var(DNS_SERVER, label="Local DNS resolver")

    credentials = [
        basic_cred(CRED_USERNAME, CRED_PASSWORD, name="default cred", default=True)
    ]
    deployments = [MySQLDeployment, PHPDeployment, K8SDeployment1]

    @action
    def test_profile_action():

        # Profile level action
        Task.Exec.ssh(name="Task9", script='echo "Hello"', target=ref(MySQLDeployment))

        # Call other actions
        PHPDeployment.test_action(name="Task10")
Exemplo n.º 13
0
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


class WebServer1(Service):
    """WebServer1 AHV Service"""

    dependencies = [ref(Postgres)]

    @action
Exemplo n.º 14
0
class RedisK8SBlueprint(Blueprint):
    """ Sample K8S Blueprint """

    services = [RedisService]
    credentials = [basic_cred("root", ROOT_PASSWD, default=True)]
    profiles = [RedisProfile]
Exemplo n.º 15
0
"""
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):
Exemplo n.º 16
0
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': {
Exemplo n.º 17
0
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")

Exemplo n.º 18
0
"""

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"""

    services = [ref(AHVPostgresService)]

    @action
Exemplo n.º 19
0
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 ref, basic_cred, read_local_file, read_provider_spec
from calm.dsl.builtins import AhvVmResources, AhvVm
from calm.dsl.builtins import (
    Substrate,
    Deployment,
    Service,
    Package,
    Profile,
    Blueprint,
)

CRED_USERNAME = read_local_file(".tests/username")
CRED_PASSWORD = read_local_file(".tests/password")
DefaultCred = basic_cred(CRED_USERNAME,
                         CRED_PASSWORD,
                         name="credential",
                         default=True)


class AHVService(Service):
    name = "AHVService"


class AHVPackage(Package):
    services = [ref(AHVService)]


class AHVResources(AhvVmResources):
    memory = 2
    vCPUs = 1
    cores_per_vCPU = 1
Exemplo n.º 21
0
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,
    editables={"username": True, "secret": True},
)


class AhvService(Service):
    """Sample mysql service"""

    ENV = CalmVariable.Simple("DEV")


class AhvPackage(Package):
    """Example package with variables, install tasks and link to service"""

    foo = CalmVariable.Simple("bar")
    services = [ref(AhvService)]
Exemplo n.º 22
0
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"
        )
Exemplo n.º 23
0
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"""

    # Service Variables
    ENV = Variable.WithOptions.Predefined.string(
        ["DEV", "PROD"], default="DEV", is_mandatory=True, runtime=True
Exemplo n.º 24
0
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"
        }
    },
)

Exemplo n.º 25
0
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"})
        CalmTask.Exec.ssh(name="Load MongoDB Data",
Exemplo n.º 26
0
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')
Exemplo n.º 27
0
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

#     assert ping(TEST_PC_IP) is True

# def test_ping_code_negative():
#     """Check if we fail to reach the VM"""
#     from calm.dsl.tools import ping

#     assert ping("1.2.3.4") is False

Exemplo n.º 28
0
from calm.dsl.builtins import basic_cred, CalmTask, action
from calm.dsl.builtins import SimpleDeployment, SimpleBlueprint
from calm.dsl.builtins import read_provider_spec
from calm.dsl.builtins import CalmVariable
from calm.dsl.store import Secret

CENTOS = basic_cred('nutanix', 'nutanix/4u', name='CENTOS', default=True)
HYCU_CRED = basic_cred('admin', 'admin', name='HYCU_CRED', default=False)


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 HYCUCentOS8(SimpleBlueprint):
    credentials = [CENTOS, HYCU_CRED]
    deployments = [CentosDeployment]
    VM_NAME = CalmVariable.Simple.string('CentOS-VM',
                                         label='VM Name',
                                         runtime=True)
Exemplo n.º 29
0
)
from calm.dsl.builtins import CalmVariable as Variable
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
from calm.dsl.builtins import AppEdit, PatchField, AhvUpdateConfigAttrs

# SSH Credentials
CENTOS_USER = "******"
CentosCred = basic_cred(
    CENTOS_USER,
    "PASSWORD",
    name="Centos",
    type="PASSWORD",
    default=True,
)


class HelloService(Service):
    """Sample Service"""

    # Service Variables
    ENV = Variable.WithOptions.Predefined.string(["DEV", "PROD"],
                                                 default="DEV",
                                                 is_mandatory=True,
                                                 runtime=True)

    # Custom service actions
Exemplo n.º 30
0
eG Enterprise is an end-to-end performance management solution for Nutanix hyper-converged infrastructure.
Using correlative intelligence and machine learning, eG Enterprise understands the interdependencies between the Nutanix platform and application workloads,
helping IT identify the root cause of performance slowdowns.
"""

from calm.dsl.builtins import ref, basic_cred, CalmTask
from calm.dsl.builtins import action
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

ADMIN_PASSWD = read_local_file("admin_passwd")

DefaultCred = basic_cred("administrator",
                         ADMIN_PASSWD,
                         name="LOCAL",
                         default=True)


class eGenterprise(Service):
    """eG Enterprise Service"""


class eGAgentPackage(Package):
    """Install eG agent"""

    services = [ref(eGenterprise)]

    @action
    def __install__():
        CalmTask.Exec.powershell(