示例#1
0
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,
    account=Ref.Account("NTNX_LOCAL_AZ"),
)

# Linux AHV VM Endpoint with Dynamic filter name starts with filter
linux_ahv_dynamic_vm_endpoint2 = Endpoint.Linux.vm(
    filter="name==" + AHV_LINUX_VM_NAME_PREFIX + ".*",
    cred=LinuxCred,
示例#2
0
"""
Calm VM Endpoint Example with Static 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")
AHV_LINUX_ID = read_local_file(".tests/runbook_tests/ahv_linux_id")
LinuxCred = basic_cred(CRED_USERNAME, CRED_PASSWORD, name="endpoint_cred")

AHVStaticVMEndpoint = Endpoint.Linux.vm(
    vms=[Ref.Vm(name="hitesh1")],
    cred=LinuxCred,
    account=Ref.Account("NTNX_LOCAL_AZ"),
)


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


if __name__ == "__main__":
    main()
示例#3
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()
示例#4
0
from calm.dsl.builtins.models.helper.common import get_vmware_account_from_datacenter

AHV_POWER_ON = read_local_file(".tests/runbook_tests/vm_actions_ahv_on")
AHV_POWER_OFF = read_local_file(".tests/runbook_tests/vm_actions_ahv_off")
VMWARE_POWER_ON = read_local_file(".tests/runbook_tests/vm_actions_vmware_on")
VMWARE_POWER_OFF = read_local_file(
    ".tests/runbook_tests/vm_actions_vmware_off")

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

VMWARE_ACCOUNT_NAME = get_vmware_account_from_datacenter()

AHVPoweredOnVM = Endpoint.Linux.vm(
    vms=[Ref.Vm(uuid=AHV_POWER_ON)],
    cred=LinuxCred,
    account=Ref.Account("NTNX_LOCAL_AZ"),
)

AHVPoweredOffVM = Endpoint.Linux.vm(
    vms=[Ref.Vm(uuid=AHV_POWER_OFF)],
    cred=LinuxCred,
    account=Ref.Account("NTNX_LOCAL_AZ"),
)

VMwarePoweredOnVM = Endpoint.Linux.vm(
    vms=[Ref.Vm(uuid=VMWARE_POWER_ON)],
    cred=LinuxCred,
    account=Ref.Account(VMWARE_ACCOUNT_NAME),
)