Esempio n. 1
0
CRED_WINDOWS_USERNAME = read_local_file(".tests/runbook_tests/windows_username")
CRED_PASSWORD = read_local_file(".tests/runbook_tests/password")

HTTP_AUTH_USERNAME = read_local_file(".tests/runbook_tests/auth_username")
HTTP_AUTH_PASSWORD = read_local_file(".tests/runbook_tests/auth_password")
HTTP_URL = read_local_file(".tests/runbook_tests/url")

VMWARE_ACCOUNT_NAME = get_vmware_account_from_datacenter()

http_endpoint = Endpoint.HTTP(
    HTTP_URL,
    verify=False,
    auth=Endpoint.Auth(HTTP_AUTH_USERNAME, HTTP_AUTH_PASSWORD),
)

LinuxCred = basic_cred(CRED_USERNAME, CRED_PASSWORD, name="endpoint_cred")
WindowsCred = basic_cred(CRED_WINDOWS_USERNAME, CRED_PASSWORD, name="endpoint_cred")

linux_endpoint = Endpoint.Linux.ip([linux_ip], cred=LinuxCred)

# Linux AHV VM Endpoint with static VM ID values
linux_ahv_static_vm_endpoint = Endpoint.Linux.vm(
    vms=[Ref.Vm(uuid=AHV_LINUX_ID)],
    cred=LinuxCred,
    account=Ref.Account("NTNX_LOCAL_AZ"),
)

# Linux AHV VM Endpoint with Dynamic filter name equals filter
linux_ahv_dynamic_vm_endpoint1 = Endpoint.Linux.vm(
    filter="name==" + AHV_LINUX_VM_NAME,
    cred=LinuxCred,
Esempio n. 2
0
from calm.dsl.runbooks import read_local_file, basic_cred
from calm.dsl.runbooks import CalmEndpoint as Endpoint

linux_ip = read_local_file(".tests/runbook_tests/vm_ip")
CRED_USERNAME = read_local_file(".tests/runbook_tests/username")
CRED_PASSWORD = read_local_file(".tests/runbook_tests/password")

LinuxCred = basic_cred(CRED_USERNAME, CRED_PASSWORD, name="linux_cred")

LinuxEndpoint = Endpoint.Linux.ip([linux_ip], cred=LinuxCred)
Esempio n. 3
0
from calm.dsl.runbooks import runbook
from calm.dsl.runbooks import RunbookTask as Task, Status, RunbookVariable as Variable
from calm.dsl.runbooks import CalmEndpoint as Endpoint
from calm.dsl.runbooks import read_local_file, basic_cred

linux_ip = read_local_file(".tests/runbook_tests/vm_ip")
windows_ip = read_local_file(".tests/runbook_tests/windows_vm_ip")
CRED_USERNAME = read_local_file(".tests/runbook_tests/username")
CRED_WINDOWS_USERNAME = read_local_file(".tests/runbook_tests/windows_username")
CRED_PASSWORD = read_local_file(".tests/runbook_tests/password")
URL = read_local_file(".tests/runbook_tests/url")
AUTH_USERNAME = read_local_file(".tests/runbook_tests/auth_username")
AUTH_PASSWORD = read_local_file(".tests/runbook_tests/auth_password")

LinuxCred = basic_cred(CRED_USERNAME, CRED_PASSWORD, name="linux_cred")
WindowsCred = basic_cred(CRED_WINDOWS_USERNAME, CRED_PASSWORD, name="windows_cred")

linux_endpoint = Endpoint.Linux.ip([linux_ip], cred=LinuxCred)
windows_endpoint = Endpoint.Windows.ip([windows_ip], cred=WindowsCred)
http_endpoint = Endpoint.HTTP(
    URL, verify=False, auth=Endpoint.Auth(AUTH_USERNAME, AUTH_PASSWORD)
)


@runbook
def WhileTask(endpoints=[linux_endpoint, windows_endpoint, http_endpoint]):
    "Runbook Service example"
    with Task.Loop(10, exit_condition=Status.SUCCESS):
        with Task.Decision.ssh(name="Task1", script="exit 0", target=endpoints[0]) as d:
Esempio n. 4
0
"""
Calm VM Endpoint Example with Dynamic Filter
"""

from calm.dsl.runbooks import read_local_file
from calm.dsl.runbooks import basic_cred, Ref
from calm.dsl.runbooks import CalmEndpoint as Endpoint

CRED_USERNAME = read_local_file(".tests/runbook_tests/username")
CRED_PASSWORD = read_local_file(".tests/runbook_tests/password")
LinuxCred = basic_cred(CRED_USERNAME, CRED_PASSWORD, name="endpoint_cred")

AHVDynamicVMEndpoint = Endpoint.Linux.vm(
    filter="name==linux_vm.*;category==cat1:value1",
    cred=LinuxCred,
    account=Ref.Account("NTNX_LOCAL_AZ"),
)


def main():
    print(AHVDynamicVMEndpoint.json_dumps(pprint=True))


if __name__ == "__main__":
    main()
Esempio n. 5
0
  8. calm watch runbook_execution <RUNLOG_UUID>
  9. calm pause runbook_execution <RUNLOG_UUID>
  10. calm resume runbook_execution <RUNLOG_UUID>
  11. calm abort runbook_execution <RUNLOG_UUID>

"""
import json

from calm.dsl.runbooks import RunbookVariable as Variable
from calm.dsl.runbooks import RunbookTask as Task, CalmEndpoint as Endpoint
from calm.dsl.runbooks import runbook, basic_cred
from calm.dsl.runbooks import parallel, branch


# Create Endpoints
Cred = basic_cred("vm_username", "vm_password", name="endpoint_cred")
PCEndpoint = Endpoint.HTTP("https://10.42.64.39:9440/api/nutanix/v3")
IPEndpoint = Endpoint.Linux.ip(["VM_IP"], cred=Cred)


@runbook
def Hello(endpoints=[PCEndpoint, IPEndpoint]):
    """ Sample runbook for Hello """

    # Defining variables for entity counts
    endpoints_count  = Variable.Simple.int("0", runtime=True)  # noqa
    blueprints_count = Variable.Simple.int("0", runtime=True)  # noqa
    runbooks_count   = Variable.Simple.int("0", runtime=True)  # noqa
    apps_count       = Variable.Simple.int("0", runtime=True)  # noqa

    # HTTP Tasks to get CALM Entity Counts