Пример #1
0
def create_vm(idx, password):
    VM_NAME = INT_DNS_NAME.format(idx)

    IMAGE_NAME = "/subscriptions/" + utils.get_subscription_id() + \
                 "/resourceGroups/admin_resources/providers/Microsoft.Compute/images/ubuntu_gpu_image1_" + region
    data_disks = "255 255 255 255"

    user_pass = password
    cloud_init_fn = cloud_init_fill_template("configs/cloud_init_sirius_template.txt", user_pass, postfix=str(idx))
    utils.create_vm(VM_NAME, rg_name, region, IMAGE_NAME, NIC_NAME.format(idx), vm_size, None, OS_DISK_NAME.format(idx),
                    user_pass, cloud_init_fn, data_disks)

    print("{} public IP: {}".format(VM_NAME, utils.get_public_ip(IP_NAME.format(idx), rg_name)))
Пример #2
0
def create_cluster_node(idx, user_pass):
    IP_NAME = "ip_cluster{0}".format(idx)
    NIC_NAME = "nic_cluster{0}".format(idx)
    INT_DNS_NAME = "cluster{0}".format(idx)
    OS_DISK_NAME = "cluster{0}_os_disk".format(idx)
    VM_NAME = INT_DNS_NAME
    IP = "10.0.1.2{0}".format(idx)

    if idx != 1:
        IP_NAME = None

    if args.create_aux:
        # create public IP
        if IP_NAME is not None:
            utils.create_public_ip(IP_NAME, rg_name)

        # Create network card with fixed private IP
        utils.create_nic_with_private_ip(NIC_NAME, rg_name, VNET_NAME,
                                         SUBNET_NAME, NSG_NAME, IP_NAME,
                                         INT_DNS_NAME, IP)

    # create VM https://docs.microsoft.com/en-us/azure/virtual-machines/virtual-machines-windows-sizes
    IMAGE_NAME = "/subscriptions/" + utils.get_subscription_id() + \
                 "/resourceGroups/admin_resources/providers/Microsoft.Compute/images/" + \
                 "cluster{0}".format(idx) + "_image1_" + region
    data_disks = "255 255 255 255"

    if idx == 1:
        cloud_init_fn = cloud_init_fill_template(
            "configs/cloud_init_cluster_master_template.txt", user_pass)
    else:
        cloud_init_fn = "configs/cloud_init_cluster_slave.txt"
    utils.create_vm(VM_NAME, rg_name, region, IMAGE_NAME, NIC_NAME, vm_size,
                    None, OS_DISK_NAME, user_pass, cloud_init_fn, data_disks,
                    "Standard_LRS")

    if RESIZE_OS_DISK:
        utils.deallocate_vm(VM_NAME, rg_name)
        utils.resize_managed_disk(rg_name, OS_DISK_NAME, OS_DISK_SIZE)
        utils.start_vm(VM_NAME, rg_name)
Пример #3
0
IP = "10.0.1.10"

if args.create_aux:
    # create public IP
    utils.create_public_ip(IP_NAME, RG_NAME)

    # Create network card with fixed private IP
    utils.create_nic_with_private_ip(NIC_NAME, RG_NAME, VNET_NAME, SUBNET_NAME,
                                     NSG_NAME, IP_NAME, INT_DNS_NAME, IP)

# create VM
VM_NAME = INT_DNS_NAME

IMAGE_NAME = "/subscriptions/" + utils.get_subscription_id() + \
             "/resourceGroups/" + RG_NAME + "/providers/Microsoft.Compute/images/" + UBUNTUGPU_IMAGE
data_disks = "255 255 255 255"

user_pass = utils.generate_pass()
cloud_init_fn = cloud_init_fill_template(
    "configs/cloud_init_ubuntugpu_template.txt", user_pass)
utils.create_vm(VM_NAME, RG_NAME, REGION, IMAGE_NAME, NIC_NAME, VM_SIZE, None,
                OS_DISK_NAME, user_pass, cloud_init_fn, data_disks)

if RESIZE_OS_DISK:
    utils.deallocate_vm(VM_NAME, RG_NAME)
    utils.resize_managed_disk(RG_NAME, OS_DISK_NAME, OS_DISK_SIZE)
    utils.start_vm(VM_NAME, RG_NAME)

print("ubuntugpu public IP: {}".format(utils.get_public_ip(IP_NAME, RG_NAME)))
print("password:", user_pass)