Esempio n. 1
0
def create_aux(idx):
    # create public IP
    utils.create_public_ip(IP_NAME.format(idx), rg_name)

    # Create network card with fixed private IP
    utils.create_nic_with_private_ip(NIC_NAME.format(idx), rg_name,
                                     VNET_NAME, SUBNET_NAME, NSG_NAME, IP_NAME.format(idx),
                                     INT_DNS_NAME.format(idx), IP.format(idx+10))
Esempio n. 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)
Esempio n. 3
0
RESIZE_OS_DISK = False
OS_DISK_SIZE = 1023

if args.create_shared:
    utils.create_shared(RG_NAME, REGION, VNET_NAME, NSG_NAME, SUBNET_NAME)

IP_NAME = "ip_ubuntugpu"
NIC_NAME = "nic_ubuntugpu"
INT_DNS_NAME = UBUNTUGPU_VM
OS_DISK_NAME = "ubuntugpu_os_disk"
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)
Esempio n. 4
0
RESIZE_OS_DISK = False
OS_DISK_SIZE = 1023

if args.create_shared:
    utils.create_shared(rg_name, region)

IP_NAME = "ip_ubuntugpu"
NIC_NAME = "nic_ubuntugpu"
INT_DNS_NAME = "ubuntugpu"
OS_DISK_NAME = "ubuntugpu_os_disk"
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/admin_resources/providers/Microsoft.Compute/images/ubuntu_gpu_image1_" + region
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)