コード例 #1
0
class DefaultProfile(Profile):
    """Sample application profile with variables"""

    DISCOURSE_DB_NAME = CalmVariable.Simple("discourse", label="database name")
    DISCOURSE_DB_PASSWORD = CalmVariable.Simple.Secret(
        DISCOURSE_PASSWORD, label="database password")
    DISCOURSE_DB_USERNAME = CalmVariable.Simple("admin",
                                                label="database username")
    INSTANCE_PUBLIC_KEY = CalmVariable.Simple(
        "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDMGAS/K0Mb/uwFXwD+hkjguy7VMZk2hpuhwPl9FUZwVBrURf/i9QMJ5/paPEZixu8VlRx7Inu4iun7rQfrnfeIYInmBwspXHYiTK3oHJAgZnrAHVEf1p6YaxLINlT1NI5yOAGPRWW6of8rBDBH1ObwU2+wcSx/1H0uIs3aZNLufr+Rh628ACxAum2Gt8AVRj6ua2BPFyt5VTdclyysAmeh1AiixNgOZXOz6y/i4TbzpY78I3isuKpxsUeXX6jxEMQol406jHDUF6njEOPIQG2zVZ3QJlTG9OlN+NiyZG9WkZz0VG/6M8ixxIHHI2dNwUbBFv2HUu+8X9LTLFq2O7KjX9Hp7uZKBAySHA3eKaKHIp2bZuU1bT5PRPkggngX86xg+T+OMNnutbAiMnRJ8+FvD5So+5TIx4b9GgxAxure3x2yRPT9lOiQOB+CVpJPxR0Rn9bOI+wiPnD0kAGvK/fHT+pqL4PM+hTnJtp9rrCRzIQApBx1263jEcYffhW2epZQRO+he5CMawFJ5TBe08om2AaDJ8GQdrpF6YA3W8DzHbmL3DPVVHdmqPLn10o+LX4gv5SdIIDVGdjKOc1BCnLTRmM28d5+sLDt/M+kvcQgf0y0yDjMVjGECZkt39hbm4ELMHzZtzYLmHNhBZxRqHeJ7qFTuv1kx88OW3Xc5mbBNQ== [email protected]",
        label="public key",
    )

    deployments = [
        AHVPostgresDeployment,
        DiscourseDeployment,
        RedisDeployment,
        MailDeployment,
    ]

    @action
    def ScaleIn():
        COUNT = CalmVariable.Simple.int("1", is_mandatory=True,
                                        runtime=True)  # noqa
        CalmTask.Scaling.scale_in("@@{COUNT}@@",
                                  target=ref(DiscourseDeployment),
                                  name="Scale In")

    @action
    def ScaleOut():
        COUNT = CalmVariable.Simple.int("1", is_mandatory=True,
                                        runtime=True)  # noqa
        CalmTask.Scaling.scale_out("@@{COUNT}@@",
                                   target=ref(DiscourseDeployment),
                                   name="Scale Out")
コード例 #2
0
ファイル: MCSA20-410.py プロジェクト: halsayed/lab-builder
class RemoteVM(Service):
    """Remote Desktop VM service"""

    OWNER = CalmVariable.Simple('', runtime=False)
    DIRECTORY_UUID = CalmVariable.Simple('', runtime=False)

    @action
    def __create__(self):
        CalmTask.SetVariable.escript(
            filename='scripts/get_vm_owner_username.py',
            name='get owner username',
            variables=['OWNER'])
        CalmTask.SetVariable.escript(name='get directory uuid',
                                     filename='scripts/get_directory_uuid.py',
                                     variables=['DIRECTORY_UUID'])
        CalmTask.Exec.powershell(filename='scripts/join_domain.ps1',
                                 name='join domain',
                                 cred=LAB_DEFAULT)
        CalmTask.Delay(delay_seconds=60, name='wait for domain')
        CalmTask.Exec.powershell(
            script=
            'Add-LocalGroupMember -Group "Administrators" -Member @@{OWNER}@@',
            name='add owner to local admin',
            cred=DOMAIN_ADMIN)
        CalmTask.Exec.escript(filename='scripts/set_prism_owner.py',
                              name='set prism owner')
コード例 #3
0
ファイル: services.py プロジェクト: halsayed/calm
class Arista(Service):
    # Variables for network provisioning
    CLUSTER_UUID = CalmVariable.Simple('', is_hidden=True, runtime=False)
    VLAN_ID = CalmVariable.Simple('', is_hidden=True, runtime=False)
    NETWORK_UUID = CalmVariable.Simple('', is_hidden=True, runtime=False)

    @action
    def __create__(self):
        CalmTask.SetVariable.escript(name='Get cluster UUID',
                                     filename='scripts/01-get_cluster_uuid.py',
                                     variables=['CLUSTER_UUID'])
        CalmTask.SetVariable.escript(name='Get vlan ID',
                                     filename='scripts/02-get_next_vlan_id.py',
                                     variables=['VLAN_ID'])
        CalmTask.Exec.escript(name='Check category',
                              filename='scripts/03-check_category.py')
        CalmTask.Exec.escript(name='Check tenant key',
                              filename='scripts/04-check_tenant_key.py')
        CalmTask.SetVariable.escript(
            name='Create new network',
            filename='scripts/05-create_new_network.py',
            variables=['NETWORK_UUID'])
        CalmTask.Exec.escript(name='Assign network to project',
                              filename='scripts/06-update_project_network.py')
        CalmTask.Exec.escript(name='Create vlan on switch',
                              filename='scripts/07-create_vlan_on_switch.py')
コード例 #4
0
class HelloProfile(Profile):

    # Deployments under this profile
    deployments = [HelloDeployment]

    # Profile Variables
    var1 = Variable.Simple("sample_val1", runtime=True)
    var2 = Variable.Simple("sample_val2", runtime=True)
    var3 = Variable.Simple.int("2", validate_regex=True, regex=r"^[\d]*$")

    # Profile Actions
    @action
    def custom_profile_action_1():
        """Sample description for a profile action"""

        # Step 1: Run a task on a service in the profile
        Task.Exec.ssh(
            name="Task1",
            script='echo "Profile level action using @@{var1}@@ and @@{var2}@@ and @@{var3}@@"',
            target=ref(HelloService),
        )

        # Step 2: Call service action as a task.
        # It will execute all tasks under the given action.
        HelloService.custom_action_1(name="Task6")
コード例 #5
0
ファイル: blueprint.py プロジェクト: tuxtof/calm-dsl
class DefaultProfile(Profile):
    """Sample application profile with variables"""

    nameserver = CalmVariable.Simple(DNS_SERVER, label="Local DNS resolver")
    foo1 = CalmVariable.Simple("bar1", runtime=True)
    foo2 = CalmVariable.Simple("bar2", runtime=True)

    deployments = [AhvDeployment]

    @action
    def test_profile_action():
        """Sample description for a profile action"""
        var_run = CalmVariable.Simple(  # Noqa
            "mail",
            runtime=True,
        )
        var_nor = CalmVariable.Simple("efg", runtime=False)  # Noqa
        var_secret = CalmVariable.Simple.Secret(  # Noqa
            "secret_var_val",
            runtime=True,
        )
        var_with_choices = CalmVariable.WithOptions(  # Noqa
            ["mail1", "mail2"],
            default="mail1",
            runtime=True,
        )
        CalmTask.Exec.ssh(name="Task5",
                          script='echo "Hello"',
                          target=ref(AhvService))
        CalmTask.Exec.ssh(
            name="PrintActionVarTask",
            script=
            "echo @@{var_run}@@\necho @@{var_nor}@@\necho @@{var_secret}@@\necho @@{var_with_choices}@@",
            target=ref(AhvService),
        )
コード例 #6
0
ファイル: blueprint.py プロジェクト: tuxtof/calm-dsl
 def test_profile_action():
     """Sample description for a profile action"""
     var_run = CalmVariable.Simple(  # Noqa
         "mail",
         runtime=True,
     )
     var_nor = CalmVariable.Simple("efg", runtime=False)  # Noqa
     var_secret = CalmVariable.Simple.Secret(  # Noqa
         "secret_var_val",
         runtime=True,
     )
     var_with_choices = CalmVariable.WithOptions(  # Noqa
         ["mail1", "mail2"],
         default="mail1",
         runtime=True,
     )
     CalmTask.Exec.ssh(name="Task5",
                       script='echo "Hello"',
                       target=ref(AhvService))
     CalmTask.Exec.ssh(
         name="PrintActionVarTask",
         script=
         "echo @@{var_run}@@\necho @@{var_nor}@@\necho @@{var_secret}@@\necho @@{var_with_choices}@@",
         target=ref(AhvService),
     )
コード例 #7
0
ファイル: test_decompile.py プロジェクト: jkntnx/calm-dsl
class DefaultProfile(Profile):
    """Sample application profile with variables"""

    name = "default profile"

    nameserver = CalmVariable.Simple(DNS_SERVER, label="Local DNS resolver")
    foo1 = CalmVariable.Simple("bar1", runtime=True)
    foo2 = CalmVariable.Simple("bar2", runtime=True)

    deployments = [MySQLDeployment, PHPDeployment]

    @action
    def test_profile_action(name="test profile action"):
        """Sample description for a profile action"""
        CalmTask.Exec.ssh(name="Task5", script='echo "Hello"', target=ref(MySQLService))
        PHPService.test_action(name="Call Runbook Task")
        with parallel:
            CalmTask.Exec.escript(
                "print 'Hello World!'", name="Test Escript", target=ref(MySQLService)
            )
            CalmTask.SetVariable.escript(
                script="print 'var1=test'",
                name="Test Setvar Escript",
                variables=["var1"],
                target=ref(MySQLService),
            )
コード例 #8
0
class DefaultProfile(Profile):
    """Sample application profile with variables"""

    nameserver = CalmVariable.Simple("10.40.64.15", label="Local DNS resolver")
    foo1 = CalmVariable.Simple("bar1", runtime=True)
    foo2 = CalmVariable.Simple("bar2", runtime=True)

    deployments = [SampleDeployment]
コード例 #9
0
    def test_action():

        action_var1 = CalmVariable.Simple("val1")  # noqa
        action_var2 = CalmVariable.Simple("val2")  # noqa
        CalmTask.Exec.ssh(name="Task2", script='echo "Hello"; sleep 10')
        CalmTask.Exec.ssh(name="Task3",
                          script='echo "Hello again"; sleep 10',
                          cred=ref(DefaultCred))
コード例 #10
0
class DogService(AnimalService):

    dependencies = [ref(AnimalService)]
    sound = Variable.Simple("woof")
    dog_prop = Variable.Simple("loyal")

    @action
    def get_dog_props():
        """Example dog action"""
        Task.Exec.ssh(name="d1", script="echo @@{dog_prop}@@")
コード例 #11
0
class HuskyService(DogService):

    dependencies = [ref(DogService)]
    sound = Variable.Simple("howl")
    husky_prop = Variable.Simple("Siberian")

    @action
    def get_husky_props():
        """Example dog action"""
        Task.Exec.ssh(name="d1", script="echo @@{husky_prop}@@")
コード例 #12
0
class AnimalService(Service):
    """Example animal service"""

    sound = Variable.Simple("NotImplemented")
    animal_var = Variable.Simple("Pet")

    @action
    def get_sound():
        """Example animal action"""
        Task.Exec.ssh(name="sound_name", script="echo @@{sound}@@")
コード例 #13
0
class DefaultProfile(Profile):
    """Sample application profile with variables"""

    nameserver = CalmVariable.Simple("10.40.64.15", label="Local DNS resolver")
    foo1 = CalmVariable.Simple("bar1", runtime=True)
    foo2 = CalmVariable.Simple("bar2", runtime=True)

    deployments = [MySQLDeployment]

    @action
    def test_profile_action():
        """Sample description for a profile action"""
        CalmTask.Exec.ssh(name="Task5", script='echo "Hello"', target=ref(MySQLService))
コード例 #14
0
class DefaultProfile(Profile):
    """Sample application profile with variables"""

    nameserver = CalmVariable.Simple(DNS_SERVER, label="Local DNS resolver")
    foo1 = CalmVariable.Simple("bar1", runtime=True)
    foo2 = CalmVariable.Simple("bar2", runtime=True)

    deployments = [AhvDeployment]

    patch_list = [
        AppEdit.UpdateConfig("patch_update",
                             target=ref(AhvDeployment),
                             patch_attrs=AhvUpdateAttrs)
    ]
コード例 #15
0
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)
コード例 #16
0
class Nutanix(Profile):
    EXE_FILE_URL = CalmVariable.Simple(
        "http://download.eginnovations.com/nutanix/eGAgent_win2012_x64.exe",
        label="eG agent exe file public url",
        is_mandatory=True,
        runtime=True,
    )
    ISS_FILE_URL = CalmVariable.Simple(
        "http://download.eginnovations.com/nutanix/eGAgentInstall.iss",
        label="eG agent IIS file public url",
        is_mandatory=True,
        runtime=True,
    )
    URL_USERNAME = CalmVariable.Simple(
        "nutanix",
        label="Username for the URL to downalod the files",
        is_mandatory=True,
        runtime=True,
    )
    URL_PASSWORD = CalmVariable.Simple(
        "nutanixdemo",
        label="Password for the URL to downalod the files",
        is_mandatory=True,
        runtime=True,
    )
    UNINSTALL_ISS_FILE = CalmVariable.Simple(
        "http://download.eginnovations.com/nutanix/eGAgentUninstall.iss",
        label="ISS file public url for the uninstallation",
        is_mandatory=True,
        runtime=True,
    )

    deployments = [eGenterpriseDeployment]

    @action
    def NICK_CONFIGURATION():
        """This Nick configuration action is required to map customer details uniquely with egenterprise."""
        NICK_NAME = CalmVariable.Simple.string(  # noqa
            "unique",
            label="This is used for uniquely ",
            is_mandatory=True,
            runtime=True,
        )
        CalmTask.Exec.powershell(
            name="NICK_FILE_Creation",
            filename="scripts/NICK_CONFIGURATION.ps1",
            target=ref(eGenterprise),
            cred=ref(DefaultCred),
        )
コード例 #17
0
class HelloPackage(Package):
    """Sample Package"""

    # Services created by installing this Package
    services = [ref(HelloService)]

    # Package Variables
    sample_pkg_var = Variable.Simple("Sample package installation")

    # Package Actions
    @action
    def __install__():

        # Step 1
        Task.Exec.ssh(
            name="Task1", filename=os.path.join("scripts", "pkg_install_task.sh")
        )

    @action
    def __uninstall__():

        # Step 1
        Task.Exec.ssh(
            name="Task1", filename=os.path.join("scripts", "pkg_uninstall_task.sh")
        )
コード例 #18
0
    def test_action(name="php service test_action"):

        blah = CalmVariable.Simple("2")  # noqa
        CalmTask.Exec.ssh(name="Task2", script='echo "Hello"')
        CalmTask.Exec.ssh(name="Task3", script='echo "Hello again"')
        CalmTask.Exec.ssh(name="Task name with space",
                          script='echo "Hello once more"')
コード例 #19
0
ファイル: blueprint.py プロジェクト: tuxtof/calm-dsl
class AhvVmProfile2(Profile):
    """Sample application profile with variables"""

    nameserver = CalmVariable.Simple("10.40.64.15", label="Local DNS resolver")
    foo1 = CalmVariable.Simple("bar1", runtime=True)
    foo2 = CalmVariable.Simple("bar2", runtime=True)

    deployments = [AhvVmDeployment2]
    environments = [Ref.Environment(name=ENV_NAME)]

    @action
    def test_profile_action():
        """Sample description for a profile action"""
        CalmTask.Exec.ssh(name="Task5",
                          script='echo "Hello"',
                          target=ref(AhvVmService))
コード例 #20
0
    def test_action():

        # TODO: Need to fix this lint
        blah = CalmVariable.Simple("2")  # noqa
        CalmTask.Exec.ssh(name="Task2", script='echo "Hello"; sleep 10')
        CalmTask.Exec.ssh(
            name="Task3", script='echo "Hello again"; sleep 10', cred=ref(DefaultCred)
        )
コード例 #21
0
class MySQLPackage(Package):

    foo = CalmVariable.Simple("bar")
    services = [ref(MySQLService)]

    @action
    def __install__():
        CalmTask.Exec.ssh(name="Task1", script="echo @@{foo}@@", cred=ref(DefaultCred))
コード例 #22
0
class Worker(Service):
    """Kubernetes Worker service"""

    VERSION = CalmVariable.Simple("")  # noqa

    @action
    def __start__():
        CalmTask.Exec.ssh(name="Start", filename="scripts/Worker03.sh")
コード例 #23
0
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")

    # Services to configure after package is installed.
    services = [ref(MySQLService)]
コード例 #24
0
class HelloPackage(Package):
    """Sample Package"""

    # Services created by installing this Package
    services = [ref(HelloService)]

    # Package Variables
    sample_pkg_var = Variable.Simple("Sample package installation")
コード例 #25
0
class PHPPackage(Package):

    foo = CalmVariable.Simple("baz")
    services = [ref(PHPService)]

    @action
    def __install__():
        CalmTask.Exec.ssh(name="Task4", script="echo @@{foo}@@")
コード例 #26
0
ファイル: blueprint.py プロジェクト: darshanpyadav93/calm-dsl
class DefaultProfile(Profile):
    """Sample application profile with variables"""

    nameserver = CalmVariable.Simple(DNS_SERVER, label="Local DNS resolver")
    foo1 = CalmVariable.Simple("bar1", runtime=True)
    foo2 = CalmVariable.Simple("bar2", runtime=True)

    deployments = [MySQLDeployment, PHPDeployment]

    environments = [
        Ref.Environment(name=ENV_NAME),
    ]

    @action
    def test_profile_action():
        """Sample description for a profile action"""
        CalmTask.Exec.ssh(name="Task5", script='echo "Hello"', target=ref(MySQLService))
        PHPService.test_action(name="Task6")
コード例 #27
0
class AhvVmPackage(Package):
    """Example package with variables, install tasks and link to service"""

    foo = CalmVariable.Simple("bar")
    services = [ref(AhvVmService)]

    @action
    def __install__():
        CalmTask.Exec.ssh(name="Task1", script="echo @@{foo}@@")
コード例 #28
0
class NxProfile(Profile):
    """Sample application profile with variables"""

    # use var_name = vartype(attrs) to define a variable at class level
    DNS_Server = CalmVariable.Simple(DNS_SERVER, label="Local DNS resolver")

    # Use setvar(name, attrs) to define a variable under variable list
    variables = [setvar("env", "dev")]

    deployments = [MySQLDeployment, PHPDeployment]
コード例 #29
0
ファイル: profiles.py プロジェクト: halsayed/calm
class Production(Profile):

    deployments = [PostgresHAonEraDeployment]

    SLA_NAME = CalmVariable.WithOptions.Predefined([
        'NONE', 'DEFAULT_OOB_GOLD_SLA', 'DEFAULT_OOB_SILVER_SLA',
        'DEFAULT_OOB_BRONZE_SLA', 'DEFAULT_OOB_BRASS_SLA'
    ],
                                                   default='NONE',
                                                   runtime=True)
    NETWORK_PROFILE = CalmVariable.WithOptions.Predefined(['PostGresNW'],
                                                          default='PostGresNW',
                                                          runtime=True)
    COMPUTE_PROFILE = CalmVariable.WithOptions.Predefined(
        ['DEFAULT_OOB_COMPUTE', 'LOW_OOB_COMPUTE'],
        default='LOW_OOB_COMPUTE',
        runtime=True)
    DB_NAME = CalmVariable.Simple('app',
                                  label='DB Name',
                                  is_mandatory=True,
                                  runtime=True)
    DBSERVER_NAME = CalmVariable.Simple('DB1',
                                        label='DB Server Name',
                                        is_mandatory=True,
                                        runtime=True)
    DB_PASSWORD = CalmVariable.Simple.Secret(DB_PASSWORD_VALUE,
                                             label='DB Password',
                                             is_mandatory=True,
                                             runtime=True)

    # hidden parameters
    DATABASE_PARAMETER = CalmVariable.Simple('DEFAULT_POSTGRES_PARAMS',
                                             is_hidden=True,
                                             runtime=False)
    SOFTWARE_PROFILE = CalmVariable.Simple('POSTGRES_10.4_OOB',
                                           is_hidden=True,
                                           runtime=False)
    ERA_IP = CalmVariable.Simple('10.42.32.40',
                                 label='ERA IP',
                                 is_mandatory=True,
                                 runtime=True,
                                 is_hidden=True)

    DB_ID = CalmVariable.Simple('', is_hidden=True, runtime=False)
    DBSERVER_ID = CalmVariable.Simple('',
                                      label='DB Server UUID',
                                      runtime=False,
                                      is_hidden=True)
    DBSERVER_IP = CalmVariable.Simple('',
                                      label='DB Server IP Address',
                                      runtime=False,
                                      is_hidden=True)
コード例 #30
0
ファイル: test_decompile.py プロジェクト: jkntnx/calm-dsl
class MySQLService(Service):
    """Sample mysql service"""

    name = "my sql service"
    ENV = CalmVariable.Simple("DEV")

    @action
    def __create__():
        "System action for creating an application"

        CalmTask.Exec.ssh(name="Task1", script="echo 'Service create in ENV=@@{ENV}@@'")