lib/sles4sap/azure_cli.pm

SYNOPSIS

Library to compose and run Azure cli commands

az_group_create

az_group_create( name => 'openqa-rg', region => 'westeurope');
name - full name of the resource group
region - Azure region

az_network_vnet_create

az_network_vnet_create(
    resource_group => 'openqa-rg',
    region => 'westeurope',
    vnet => 'openqa-vnet',
    snet => 'openqa-subnet',
    address_prefixes => '10.0.1.0/16',
    subnet_prefixes => '10.0.1.0/24')

Create a virtual network
resource_group - existing resource group where to create the network
region - Azure region
vnet - name of the virtual network
snet - name of the subnet
address_prefixes - virtual network ip address space. Default 192.168.0.0/16
subnet_prefixes - subnet ip address space. Default 192.168.0.0/24

az_network_nsg_create

az_network_nsg_create(
    resource_group => 'openqa-rg',
    name => 'openqa-nsg')

Create a network security group
resource_group - existing resource group where to create the NSG
name - security group name

az_network_nsg_rule_create

az_network_nsg_rule_create(
    resource_group => 'openqa-rg',
    nsg => 'openqa-nsg',
    name => 'openqa-nsg-rule-ssh',
    port => 22)

Create a rule for an existing network security group
resource_group - existing resource group where to create the NSG
nsg - existing security group name
name - security rule name
port - allowed port

az_network_publicip_create

az_network_publicip_create(
    resource_group => 'openqa-rg',
    name => 'openqa-pip',
    zone => '1 2 3')

Create an IPv4 public IP resource
resource_group - existing resource group where to create the PubIP
name - public IP resource name
sku - default Standard
allocation_method - optionally add --allocation-method
zone - optionally add --zone

az_network_lb_create

az_network_lb_create(
    resource_group => 'openqa-rg',
    name => 'openqa-lb',
    vnet => 'openqa-vnet',
    snet => 'openqa-subnet',
    backend => 'openqa-be',
    frontend_ip => 'openqa-feip',
    sku => 'Standard')

Create a load balancer entity.
LB is mostly "just" a "group" definition
to link back-end and front-end resources (usually an IP)
# SKU Standard (and not Basic) is needed to get some Metrics
resource_group - existing resource group where to create lb
name - load balancer name
vnet - existing Virtual network name where to create LB in
snet - existing Subnet network name where to create LB in
backend - name to assign to created backend pool
frontend_ip - name to assign to created frontend ip, will be reused in "az network lb rule create"
sku - default Basic
fip - optionally add --private-ip-address

az_vm_as_create

az_vm_as_create(
    resource_group => 'openqa-rg',
    name => 'openqa-as',
    region => 'westeurope',
    fault_count => 2)

Create an availability set. Later on VM can be assigned to it.
resource_group - existing resource group where to create the Availability set
region - region where to create the Availability set
name - availability set name
fault_count - value for --platform-fault-domain-count

az_vm_create

az_vm_create(
    resource_group => 'openqa-rg',
    name => 'openqa-vm',
    region => 'westeurope',
    image => 'SUSE:sles-sap-15-sp5:gen2:latest')

Create a virtual machine
name - virtual machine name
resource_group - existing resource group where to create the VM
image - OS image name
vnet - optional name of the Virtual Network where to place the VM
snet - optional name of the SubNet where to connect the VM
size - VM size, default Standard_B1s
region - optional region where to create the VM
availability_set - optional inclusion in an availability set
username - optional admin username
nsg - optional inclusion in an network security group
nic - optional add to the VM a NIC created separately with 'az network nic create'
public_ip - optional add to the VM a public IP. Value like "" is a valid one and is not the same as not including the argument at all.
custom_data - optional provide a cloud-init script file
ssh_pubkey - optional inclusion in an availability set, if missing the command is configured to generate one

az_vm_openport

az_vm_openport(
    resource_group => 'openqa-rg',
    name => 'openqa-vm',
    port => 80)

Open a port on an existing VM
resource_group - existing resource group where to create the Availability set
name - name of an existing VM
port - port to open

az_vm_wait_cloudinit

az_vm_wait_cloudinit(
    resource_group => 'openqa-rg',
    name => 'openqa-vm')

Wait cloud-init completition on a running VM
resource_group - existing resource group where to create the Availability set
name - name of an existing VM
username - username default cloudadmin
timeout - max wait time in seconds. Default 3600.

az_nic_id_get

my $nic_id = az_nic_id_get(
    resource_group => 'openqa-rg',
    name => 'openqa-vm')

get the NIC ID of the first NIC of a given VM
resource_group - existing resource group where to create the Availability set
name - name of an existing VM

az_nic_get

get the NIC data from NIC ID
nic_id - existing NIC ID (eg. from az_nic_id_get)
filter - query filter

az_nic_name_get

my $nic_name = az_nic_name_get(
    resource_group => 'openqa-rg',
    name => 'openqa-vm')

get the NIC name from NIC ID
nic_id - existing NIC ID (eg. from az_nic_id_get)

az_ipconfig_name_get

my $ipconfig_name = az_ipconfig_name_get(
    resource_group => 'openqa-rg',
    name => 'openqa-vm')

get the name of the first IpConfig of a NIC from a NIC ID
nic_id - existing NIC ID (eg. from az_nic_id_get)