Пример #1
0
"""
Calm HTTP Endpoint Sample with Auth
"""
from calm.dsl.runbooks import read_local_file
from calm.dsl.runbooks import CalmEndpoint as Endpoint

AUTH_USERNAME = read_local_file(".tests/runbook_tests/auth_username")
AUTH_PASSWORD = read_local_file(".tests/runbook_tests/auth_password")
URL = read_local_file(".tests/runbook_tests/url")

DslHTTPEndpoint = Endpoint.HTTP(URL,
                                verify=True,
                                auth=Endpoint.Auth(AUTH_USERNAME,
                                                   AUTH_PASSWORD))
Пример #2
0
)

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

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
Пример #3
0
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:

            if d.ok:
                Task.Exec.ssh(
                    name="SUCCESS1", script="echo 'SUCCESS'", target=endpoints[0]
                )

            else: