示例#1
0
 def init_vm_details(self):
     '''Populate the self.zones structure
        - with a physically ordered representation of the VMs in a scale set.
     '''
     self.init_zones()
     # get the model view
     self.vm_model_view = azurerm.list_vmss_vms(self.access_token,
                                                self.sub_id, self.rgname,
                                                self.name)
     # get the instance view
     self.vm_instance_view = azurerm.list_vmss_vm_instance_view(
         self.access_token, self.sub_id, self.rgname, self.name)
     # do a loop through the number of VMs and populate VMs properties in the zones structure
     # make an assumption that len(vm_model_view) == len(vm_instance_view)
     #   - true if not actively scaling
     for idx in range(len(self.vm_model_view['value'])):
         vm_id = self.vm_model_view['value'][idx]['instanceId']
         zone_num = self.vm_model_view['value'][idx]['zones'][0]
         power_state = self.get_power_state(
             self.vm_instance_view['value'][idx]['properties']
             ['instanceView']['statuses'])
         fault_domain = self.vm_instance_view['value'][idx]['properties'][
             'instanceView']['platformFaultDomain']
         vm_data = {'vmid': vm_id, 'power_state': power_state}
         self.zones[int(zone_num) -
                    1]['fds'][fault_domain]['vms'].append(vm_data)
示例#2
0
def get_vmss_properties(access_token, subscription_id):
   global vmssProperties
   global vmssVmProperties
   while True:
      try:
         # get VMSS details
         vmssget = azurerm.get_vmss(access_token, subscription_id, rgname, vmssname)
         name = vmssget['name']
         location = vmssget['location']
         capacity = vmssget['sku']['capacity']
         offer = vmssget['properties']['virtualMachineProfile']['storageProfile']['imageReference']['offer']
         sku = vmssget['properties']['virtualMachineProfile']['storageProfile']['imageReference']['sku']
         provisioningState = vmssget['properties']['provisioningState']
         vmssProperties = [name, capacity, location, rgname, offer, sku, provisioningState, dns, ipaddr]
         vmssvms = azurerm.list_vmss_vms(access_token, subscription_id, rgname, vmssname)
         # get VM details
         vmssVmProperties = []
         for vm in vmssvms['value']:
            instanceId = vm['instanceId']
            vmName = vm['name']
            provisioningState = vm['properties']['provisioningState']
            vmssVmProperties.append([instanceId, vmName, provisioningState])
      except:
         # this catches errors like throttling from the Azure server
         f = open('error.log', 'w')
         if len(vmssvms) > 0:
            for p in vmssvms.items():
               f.write("%s:%s\n" % p)
         f.close()
         # break out of loop when an error is encountered
         break
      # sleep before before each loop to avoid throttling
      time.sleep(2)
def get_vmss_properties(access_token, subscription_id):
    global vmssProperties
    global vmssVmProperties
    while True:
        try:
            # get VMSS details
            vmssget = azurerm.get_vmss(access_token, subscription_id, rgname,
                                       vmssname)
            vmssProperties['name'] = vmssget['name']
            vmssProperties['capacity'] = vmssget['sku']['capacity']
            vmssProperties['location'] = vmssget['location']
            vmssProperties['vmsize'] = vmssget['sku'][
                'name']  # needed for scale operations (and displayed on dashboard)
            vmssProperties['tier'] = vmssget['sku'][
                'tier']  # needed for scale operations
            vmssProperties['offer'] = \
                vmssget['properties']['virtualMachineProfile']['storageProfile']['imageReference']['offer']
            vmssProperties['sku'] = vmssget['properties'][
                'virtualMachineProfile']['storageProfile']['imageReference'][
                    'sku']
            vmssProperties['provisioningState'] = vmssget['properties'][
                'provisioningState']

            vmssvms = azurerm.list_vmss_vms(access_token, subscription_id,
                                            rgname, vmssname)
            # get VM details
            vmssVmTempProperties = []
            for vm in vmssvms['value']:
                instanceId = vm['instanceId']
                vmName = vm['name']
                provisioningState = vm['properties']['provisioningState']
                powerState = ''
                if provisioningState == 'Succeeded':
                    instanceView = azurerm.get_vmss_vm_instance_view(
                        access_token, subscription_id, rgname, vmssname,
                        instanceId)
                    powerState = instanceView['statuses'][1]['displayStatus']
                vmssVmTempProperties.append(
                    [instanceId, vmName, provisioningState, powerState])
            vmssVmProperties = list(vmssVmTempProperties)
            print(
                json.dumps(vmssVmProperties,
                           sort_keys=False,
                           indent=2,
                           separators=(',', ': ')))
        except:
            # this catches errors like throttling from the Azure server
            f = open('error.log', 'w')
            if len(vmssvms) > 0:
                for p in vmssvms.items():
                    f.write("%s:%s\n" % p)
            f.close()
            # break out of loop when an error is encountered
            break
        # sleep before before each loop to avoid throttling
        time.sleep(5)
示例#4
0
def get_vmss_properties(access_token, subscription_id):
    global vmssProperties
    global vmssVmProperties
    while True:
        try:
            # get VMSS details
            vmssget = azurerm.get_vmss(access_token, subscription_id, rgname, vmssname)
            vmssProperties['name'] = vmssget['name']
            vmssProperties['capacity'] = vmssget['sku']['capacity']
            vmssProperties['location'] = vmssget['location']
            vmssProperties['vmsize'] = vmssget['sku'][
                'name']  # needed for scale operations (and displayed on dashboard)
            vmssProperties['tier'] = vmssget['sku']['tier']  # needed for scale operations
            vmssProperties['offer'] = \
            vmssget['properties']['virtualMachineProfile']['storageProfile']['imageReference']['offer']
            vmssProperties['sku'] = vmssget['properties']['virtualMachineProfile']['storageProfile']['imageReference'][
                'sku']
            vmssProperties['provisioningState'] = vmssget['properties']['provisioningState']

            vmssvms = azurerm.list_vmss_vms(access_token, subscription_id, rgname, vmssname)
            # get VM details
            vmssVmTempProperties = []
            for vm in vmssvms['value']:
                instanceId = vm['instanceId']
                vmName = vm['name']
                provisioningState = vm['properties']['provisioningState']
                powerState = ''
                if provisioningState == 'Succeeded':
                    instanceView = azurerm.get_vmss_vm_instance_view(access_token, subscription_id, rgname, vmssname,
                                                                     instanceId)
                    powerState = instanceView['statuses'][1]['displayStatus']
                vmssVmTempProperties.append([instanceId, vmName, provisioningState, powerState])
            vmssVmProperties = list(vmssVmTempProperties)
            print(json.dumps(vmssVmProperties, sort_keys=False, indent=2, separators=(',', ': ')))
        except:
            # this catches errors like throttling from the Azure server
            f = open('error.log', 'w')
            if len(vmssvms) > 0:
                for p in vmssvms.items():
                    f.write("%s:%s\n" % p)
            f.close()
            # break out of loop when an error is encountered
            break
        # sleep before before each loop to avoid throttling
        time.sleep(5)
    def getAgents(self):
        """
        Get a list of all agents in the Pool.
        """
        tenant_id = self.config.get('Subscription', 'tenant_id')
        app_id = self.config.get('Subscription', 'app_id')
        app_secret = self.config.get('Subscription', 'app_secret')
        subscription_id = self.config.get('Subscription', 'subscription_id')
        rgname = self.config.get('Group', 'name')
        access_token = azurerm.get_access_token(tenant_id, app_id, app_secret)

        # TODO: This assumes only a single VMSS in the resource group, this will not always be the
        # case and will never be the case if when there are multiple Agent Pools
        vmsslist = azurerm.list_vm_scale_sets(access_token, subscription_id, rgname)['value']
        # self.log.debug("List of VMSS: " + json.dumps(vmsslist, indent=True))
        vmssname = vmsslist[0]['name']
        self.log.debug("Looking up VMs in VMSS called " + vmssname + " (if this is wrong maybe it is because AgentPool.py currently only supports a single VMSS)")

        vms = azurerm.list_vmss_vms(access_token, subscription_id, rgname, vmssname)
        return vms['value']
示例#6
0
def main():
    '''main routine'''
    # Load Azure app defaults
    try:
        with open('azurermconfig.json') as config_file:
            config_data = json.load(config_file)
    except FileNotFoundError:
        sys.exit('Error: Expecting azurermconfig.json in current folder')

    tenant_id = config_data['tenantId']
    app_id = config_data['appId']
    app_secret = config_data['appSecret']
    subscription_id = config_data['subscriptionId']

    access_token = azurerm.get_access_token(tenant_id, app_id, app_secret)

    vmsslist = azurerm.list_vmss_sub(access_token, subscription_id)
    for vmss in vmsslist['value']:
        name = vmss['name']
        location = vmss['location']
        capacity = vmss['sku']['capacity']
        print(''.join(['Name: ', name, ', location: ',
                       location, ', Capacity: ', str(capacity)]))
        print('VMSS NICs...')
        rgname = get_rg_from_id(vmss['id'])
        vmss_nics = azurerm.get_vmss_nics(
            access_token, subscription_id, rgname, name)
        print(json.dumps(vmss_nics, sort_keys=False,
                         indent=2, separators=(',', ': ')))
        print('VMSS Virtual machines...')
        vms = azurerm.list_vmss_vms(
            access_token, subscription_id, rgname, name)
        #print(json.dumps(vms, sort_keys=False, indent=2, separators=(',', ': ')))
        for vmssvm in vms['value']:
            vm_id = vmssvm['instanceId']
            print(vm_id + ', ' + vmssvm['name'] + '\n')
            print('VMSS VM NICs...')
            vmnics = azurerm.get_vmss_vm_nics(access_token, subscription_id, rgname, name,
                                              vm_id)
            print(json.dumps(vmnics, sort_keys=False,
                             indent=2, separators=(',', ': ')))
示例#7
0
 def init_vm_model_view(self):
     '''get the VMSS instance view and set the class property'''
     # get a model view list in order to build a zones heatmap
     self.vm_model_view = \
         azurerm.list_vmss_vms(self.access_token, self.sub_id, self.rgname, self.name)
示例#8
0
def get_vmss_properties(access_token, run_event, window_information, panel_information, window_continents, panel_continents):
	global vmssProperties, vmssVmProperties, countery, capacity, region, tier, vmsku, vm_selected, window_vm, panel_vm, instances_deployed, vm_details, vm_nic, page;

	ROOM = 5; DEPLOYED = 0;

	#VM's destination...
	destx = 22; desty = 4; XS =50; YS = 4; init_coords = (XS, YS);
	window_dc = 0;

	#Our window_information arrays...
	panel_vm = []; window_vm = [];

	#Our thread loop...
	while run_event.is_set():
		try:
			#Timestamp...
			ourtime = time.strftime("%H:%M:%S");
			write_str(window_information['status'], 1, 13, ourtime);

			#Clean Forms...
			clean_forms(window_information);

			#Get VMSS details
			vmssget = azurerm.get_vmss(access_token, subscription_id, rgname, vmssname);

			# Get public ip address for RG (First IP) - modify this if your RG has multiple ips
			net = azurerm.list_public_ips(access_token, subscription_id, rgname);

			#Clean Info and Sys Windows...
			clean_infoandsys(window_information);

			#Fill the information...
			fill_vmss_info(window_information, vmssget, net);

			#Set VMSS variables...
			(name, capacity, location, offer, sku, provisioningState, dns, ipaddr) = set_vmss_variables(vmssget, net);

			#Set the current and old location...
			old_location = region;
			if (old_location != ""):
				continent_old_location = get_continent_dc(old_location);

			#New
			region = location;
			continent_location = get_continent_dc(location);

			#Quota...
			quota = azurerm.get_compute_usage(access_token, subscription_id, location);
			fill_quota_info(window_information, quota);

			#Mark Datacenter where VMSS is deployed...
			if (old_location != ""):
				if (old_location != location):
					#Now switch the datacenter mark on map...
					new_window_dc = mark_vmss_dc(continent_old_location, window_continents[continent_old_location], old_location, window_continents[continent_location], location, window_dc);
					window_dc = new_window_dc;
			else:
				new_window_dc = mark_vmss_dc(continent_location, window_continents[continent_location], location, window_continents[continent_location], location, window_dc);
				window_dc = new_window_dc;

			#Our arrays...
			vmssProperties = [name, capacity, location, rgname, offer, sku, provisioningState, dns, ipaddr];
			vmssvms = azurerm.list_vmss_vms(access_token, subscription_id, rgname, vmssname);
			vmssVmProperties = [];

			#All VMs are created in the following coordinates...
			qtd = vmssvms['value'].__len__();
			factor = (vmssvms['value'].__len__() / 100);

			write_str(window_information['system'], 3, 22, qtd);

			step = qtd / 10;
			if (step < 1): step = 1;	

			#We take more time on our VM effect depending on how many VMs we are talking about...
			if (qtd < 10): ts = 0.01;
			elif (qtd < 25): ts = 0.005;
			elif (qtd < 50): ts = 0.002;
			elif (qtd < 100): ts = 0.0005;
			else: ts = 0;

			counter = 1; counter_page = 0; nr_pages = 1;

			snap_page = page;
			page_top = (snap_page * 100);
			page_base = ((snap_page - 1) * 100);

			if (vm_selected[1] == 999998):
				#Clean VM Info...
				clean_vm(window_information);
			#Loop each VM...
			for vm in vmssvms['value']:
				instanceId = vm['instanceId'];
				write_str(window_information['monitor'], 1, 30, instanceId);
				wrefresh(window_information['monitor']);
				vmsel = 0;
				vmName = vm['name'];
				provisioningState = vm['properties']['provisioningState'];
				vmssVmProperties.append([instanceId, vmName, provisioningState]);
				if (counter > DEPLOYED):
					window_vm.append(DEPLOYED); panel_vm.append(DEPLOYED); instances_deployed.append(DEPLOYED);
					instances_deployed[DEPLOYED] = int(instanceId);
					#Prepare the place for the VM icon...
					if countery < 10:
						countery += 1;
					else:
						destx += 3; desty = 4; countery = 1;
					if (counter_page > 99):
						destx = 22; counter_page = 0; nr_pages += 1;
						cur_page = "%02d" % snap_page;
						tot_pages = "%02d" % nr_pages;
						update_vm_footer(window_information, cur_page, tot_pages);
					else:
						counter_page += 1;
					window_vm[DEPLOYED] = create_window(3, 5, init_coords[0], init_coords[1]);
					panel_vm[DEPLOYED] = new_panel(window_vm[DEPLOYED]);
					#Show only VM's that are on the visible window...
					if (page_top > DEPLOYED and DEPLOYED >= page_base):
						show_panel(panel_vm[DEPLOYED]);
					else:
						hide_panel(panel_vm[DEPLOYED]);
					box(window_vm[DEPLOYED]);
					#Creation of the VM icon, in this flow we never have a VM selected...
					draw_vm(int(instanceId), window_vm[DEPLOYED], provisioningState, vmsel);
					vm_animation(panel_vm[DEPLOYED], init_coords, destx, desty, 1, ts);
					desty += ROOM;
					DEPLOYED += 1;
				else:
					instances_deployed[counter - 1] = int(instanceId);
					#Remove the old mark...
					vmsel = deselect_vm(window_vm, panel_information, instanceId, counter);
					#Show only VM's that are on the visible window...
					if (page_top > (counter - 1) and (counter - 1) >= page_base):
						show_panel(panel_vm[counter -1]);
					else:
						hide_panel(panel_vm[counter -1]);
					#Creation of the VM icon...
					draw_vm(int(instanceId), window_vm[counter - 1], provisioningState, vmsel);
					#If a VM is selected, fill the details...
					if (vm_selected[0] == int(instanceId) and vm_selected[1] != 999998):
						vm_details = azurerm.get_vmss_vm_instance_view(access_token, subscription_id, rgname, vmssname, vm_selected[0]);
						vm_nic = azurerm.get_vmss_vm_nics(access_token, subscription_id, rgname, vmssname, vm_selected[0]);
						clean_vm(window_information);
						if (vm_details != "" and vm_nic != ""):
							fill_vm_details(window_information, instanceId, vmName, provisioningState);
				update_panels();
				doupdate();
				counter += 1;
				do_update_bar(window_information['status'], step, 0);
				step += step;
			#Last mile...
			write_str(window_information['monitor'], 1, 30, "Done.");
			do_update_bar(window_information['status'], step, 1);

			#Remove destroyed VMs...
			counter_page = 0;
			if (DEPLOYED >= counter):
				time.sleep(0.5);
				write_str_color(window_information['monitor'], 1, 30, "Removing VM's...", 7, 0);
				wrefresh(window_information['monitor']);
				time.sleep(1);
				clean_monitor_form(window_information);
	
			while (DEPLOYED >= counter):
				write_str(window_information['monitor'], 1, 30, DEPLOYED);
				lastvm = window_vm.__len__() - 1;	
				vm_coords = getbegyx(window_vm[lastvm]);
				vm_animation(panel_vm[lastvm], vm_coords, init_coords[0], init_coords[1], 0, ts);
				if (countery > 0):
					desty -= ROOM; countery -= 1;
				elif (destx > 22):
					destx -= 3; desty = 49; countery = 9;
				if (counter_page > 99):
					destx = 52;
					counter_page = 0;
					nr_pages -= 1;
					tot_pages = "%02d" % nr_pages;
					cur_page = "%02d" % page;
					update_vm_footer(window_information, cur_page, tot_pages);
				else:
					counter_page += 1;
				
				#Clean VM Info...
				if (vm_selected[0] == instances_deployed[lastvm]):
					clean_vm(window_information);
				#Free up some memory...
				del_panel(panel_vm[lastvm]); delwin(window_vm[lastvm]);
				wobj = panel_vm[lastvm]; panel_vm.remove(wobj);
				wobj = window_vm[lastvm]; window_vm.remove(wobj);
				wobj = instances_deployed[lastvm]; instances_deployed.remove(wobj);
				DEPLOYED -= 1;
				update_panels();
				doupdate();
			write_str(window_information['monitor'], 1, 30, "Done.");
			ourtime = time.strftime("%H:%M:%S");
			do_update_bar(window_information['status'], step, 1);
			write_str(window_information['status'], 1, 13, ourtime);
			write_str_color(window_information['status'], 1, 22, "     OK     ", 6, 0);
			update_panels();
			doupdate();
			# sleep before each loop to avoid throttling...
			time.sleep(interval);
		except:
			logging.exception("Getting VMSS Information...")
			write_str(window_information['error'], 1, 24, "Let's sleep for 30 seconds and try to refresh the dashboard again...");
			show_panel(panel_information['error']);
			update_panels();
			doupdate();
			## break out of loop when an error is encountered
			#break
			time.sleep(30);
			hide_panel(panel_information['error']);
示例#9
0
# loop through resource groups
resource_groups = azurerm.list_resource_groups(access_token, subscription_id)
for rg in resource_groups["value"]:
    rgname = rg["name"] 
    vmsslist = azurerm.list_vm_scale_sets(access_token, subscription_id, rgname)
    for vmss in vmsslist['value']:
        name = vmss['name']
        location = vmss['location']
        capacity = vmss['sku']['capacity']
        offer = vmss['properties']['virtualMachineProfile']['storageProfile']['imageReference']['offer']
        sku = vmss['properties']['virtualMachineProfile']['storageProfile']['imageReference']['sku']
        print(''.join(['Name: ', name,
                       ', RG: ', rgname,
                       ', location: ', location,
                       ', Capacity: ', str(capacity),
                       ', OS: ', offer, ' ', sku]))
        print('VMSS NICs...')
        vmssNics = azurerm.get_vmss_nics(access_token, subscription_id, rgname, name)
        print(json.dumps(vmssNics, sort_keys=False, indent=2, separators=(',', ': ')))
        print('VMSS Virtual machines...')
        vms = azurerm.list_vmss_vms(access_token, subscription_id, rgname, name)
        #print(json.dumps(vms, sort_keys=False, indent=2, separators=(',', ': ')))
        for vm in vms['value']:
            vmId = vm['instanceId']
            print(vmId + ', ' + vm['name'] + '\n')
            print('VMSS VM NICs...')
            vmnics = azurerm.get_vmss_vm_nics(access_token, subscription_id, rgname, name, vmId)
            print(json.dumps(vmnics, sort_keys=False, indent=2, separators=(',', ': ')))

示例#10
0
        sku = vmss['properties']['virtualMachineProfile']['storageProfile'][
            'imageReference']['sku']
        print(''.join([
            'Name: ', name, ', RG: ', rgname, ', location: ', location,
            ', Capacity: ',
            str(capacity), ', OS: ', offer, ' ', sku
        ]))
        print('VMSS NICs...')
        vmssNics = azurerm.get_vmss_nics(access_token, subscription_id, rgname,
                                         name)
        print(
            json.dumps(vmssNics,
                       sort_keys=False,
                       indent=2,
                       separators=(',', ': ')))
        print('VMSS Virtual machines...')
        vms = azurerm.list_vmss_vms(access_token, subscription_id, rgname,
                                    name)
        # print(json.dumps(vms, sort_keys=False, indent=2, separators=(',', ': ')))
        for vm in vms['value']:
            vmId = vm['instanceId']
            print(vmId + ', ' + vm['name'] + '\n')
            print('VMSS VM NICs...')
            vmnics = azurerm.get_vmss_vm_nics(access_token, subscription_id,
                                              rgname, name, vmId)
            print(
                json.dumps(vmnics,
                           sort_keys=False,
                           indent=2,
                           separators=(',', ': ')))
示例#11
0
def get_vmss_properties(access_token, run_event, window_information, panel_information, window_continents, panel_continents):
	global vmssProperties, vmssVmProperties, countery, capacity, region, tier, vmsku, vm_selected, window_vm, panel_vm, instances_deployed, vm_details, vm_nic, page;

	ROOM = 5; DEPLOYED = 0;

	#VM's destination...
	destx = 22; desty = 4; XS =50; YS = 4; init_coords = (XS, YS);
	window_dc = 0;

	#Our window_information arrays...
	panel_vm = []; window_vm = [];

	#Our thread loop...
	while run_event.is_set():
		try:
			#Timestamp...
			ourtime = time.strftime("%H:%M:%S");
			write_str(window_information['status'], 1, 13, ourtime);

			#Clean Forms...
			clean_forms(window_information);

			#Get VMSS details
			vmssget = azurerm.get_vmss(access_token, subscription_id, rgname, vmssname);

			# Get public ip address for RG (First IP) - modify this if your RG has multiple ips
			net = azurerm.list_public_ips(access_token, subscription_id, rgname);

			#Clean Info and Sys Windows...
			clean_infoandsys(window_information);

			#Fill the information...
			fill_vmss_info(window_information, vmssget, net);

			#Set VMSS variables...
			(name, capacity, location, offer, sku, provisioningState, dns, ipaddr) = set_vmss_variables(vmssget, net);

			#Set the current and old location...
			old_location = region;
			if (old_location != ""):
				continent_old_location = get_continent_dc(old_location);

			#New
			region = location;
			continent_location = get_continent_dc(location);

			#Quota...
			quota = azurerm.get_compute_usage(access_token, subscription_id, location);
			fill_quota_info(window_information, quota);

			#Mark Datacenter where VMSS is deployed...
			if (old_location != ""):
				if (old_location != location):
					#Now switch the datacenter mark on map...
					new_window_dc = mark_vmss_dc(continent_old_location, window_continents[continent_old_location], old_location, window_continents[continent_location], location, window_dc);
					window_dc = new_window_dc;
			else:
				new_window_dc = mark_vmss_dc(continent_location, window_continents[continent_location], location, window_continents[continent_location], location, window_dc);
				window_dc = new_window_dc;

			#Our arrays...
			vmssProperties = [name, capacity, location, rgname, offer, sku, provisioningState, dns, ipaddr];
			vmssvms = azurerm.list_vmss_vms(access_token, subscription_id, rgname, vmssname);
			vmssVmProperties = [];

			#All VMs are created in the following coordinates...
			qtd = vmssvms['value'].__len__();
			factor = (vmssvms['value'].__len__() / 100);

			write_str(window_information['system'], 3, 22, qtd);

			step = qtd / 10;
			if (step < 1): step = 1;	

			#We take more time on our VM effects depending on how many VMs we are talking about...
			if (qtd < 10): ts = 0.01;
			elif (qtd < 25): ts = 0.004;
			elif (qtd < 50): ts = 0.0008;
			elif (qtd < 100): ts = 0.0004;
			else: ts = 0;

			counter = 1; counter_page = 0; nr_pages = 1;

			snap_page = page;
			page_top = (snap_page * 100);
			page_base = ((snap_page - 1) * 100);

			if (vm_selected[1] == 999998):
				#Clean VM Info...
				clean_vm(window_information);
			#Loop each VM...
			for vm in vmssvms['value']:
				instanceId = vm['instanceId'];
				write_str(window_information['monitor'], 1, 30, instanceId);
				wrefresh(window_information['monitor']);
				vmsel = 0;
				vmName = vm['name'];
				provisioningState = vm['properties']['provisioningState'];
				vmssVmProperties.append([instanceId, vmName, provisioningState]);
				if (counter > DEPLOYED):
					window_vm.append(DEPLOYED); panel_vm.append(DEPLOYED); instances_deployed.append(DEPLOYED);
					instances_deployed[DEPLOYED] = int(instanceId);
					#Prepare the place for the VM icon...
					if countery < 10:
						countery += 1;
					else:
						destx += 3; desty = 4; countery = 1;
					if (counter_page > 99):
						destx = 22; counter_page = 0; nr_pages += 1;
						cur_page = "%02d" % snap_page;
						tot_pages = "%02d" % nr_pages;
						update_vm_footer(window_information, cur_page, tot_pages);
					else:
						counter_page += 1;
					window_vm[DEPLOYED] = create_window(3, 5, init_coords[0], init_coords[1]);
					panel_vm[DEPLOYED] = new_panel(window_vm[DEPLOYED]);
					#Show only VM's that are on the visible window...
					if (page_top > DEPLOYED and DEPLOYED >= page_base):
						show_panel(panel_vm[DEPLOYED]);
					else:
						hide_panel(panel_vm[DEPLOYED]);
					box(window_vm[DEPLOYED]);
					#Creation of the VM icon, in this flow we never have a VM selected...
					draw_vm(int(instanceId), window_vm[DEPLOYED], provisioningState, vmsel);
					vm_animation(panel_vm[DEPLOYED], init_coords, destx, desty, 1, ts);
					desty += ROOM;
					DEPLOYED += 1;
				else:
					instances_deployed[counter - 1] = int(instanceId);
					#Remove the old mark...
					vmsel = deselect_vm(window_vm, panel_information, instanceId, counter);
					#Show only VM's that are on the visible window...
					if (page_top > (counter - 1) and (counter - 1) >= page_base):
						show_panel(panel_vm[counter -1]);
					else:
						hide_panel(panel_vm[counter -1]);
					#Creation of the VM icon...
					draw_vm(int(instanceId), window_vm[counter - 1], provisioningState, vmsel);
					#If a VM is selected, fill the details...
					if (vm_selected[0] == int(instanceId) and vm_selected[1] != 999998):
						vm_details = azurerm.get_vmss_vm_instance_view(access_token, subscription_id, rgname, vmssname, vm_selected[0]);
						vm_nic = azurerm.get_vmss_vm_nics(access_token, subscription_id, rgname, vmssname, vm_selected[0]);
						clean_vm(window_information);
						if (vm_details != "" and vm_nic != ""):
							fill_vm_details(window_information, instanceId, vmName, provisioningState);
				update_panels();
				doupdate();
				counter += 1;
				do_update_bar(window_information['status'], step, 0);
				step += step;
			#Last mile...
			write_str(window_information['monitor'], 1, 30, "Done.");
			do_update_bar(window_information['status'], step, 1);

			#Remove destroyed VMs...
			counter_page = 0;
			if (DEPLOYED >= counter):
				time.sleep(0.5);
				write_str_color(window_information['monitor'], 1, 30, "Removing VM's...", 7, 0);
				wrefresh(window_information['monitor']);
				time.sleep(1);
				clean_monitor_form(window_information);
	
			while (DEPLOYED >= counter):
				write_str(window_information['monitor'], 1, 30, DEPLOYED);
				lastvm = window_vm.__len__() - 1;	
				vm_coords = getbegyx(window_vm[lastvm]);
				vm_animation(panel_vm[lastvm], vm_coords, init_coords[0], init_coords[1], 0, ts);
				if (countery > 0):
					desty -= ROOM; countery -= 1;
				elif (destx > 22):
					destx -= 3; desty = 49; countery = 9;
				if (counter_page > 99):
					destx = 52;
					counter_page = 0;
					nr_pages -= 1;
					tot_pages = "%02d" % nr_pages;
					cur_page = "%02d" % page;
					update_vm_footer(window_information, cur_page, tot_pages);
				else:
					counter_page += 1;
				
				#Clean VM Info...
				if (vm_selected[0] == instances_deployed[lastvm]):
					clean_vm(window_information);
				#Free up some memory...
				del_panel(panel_vm[lastvm]); delwin(window_vm[lastvm]);
				wobj = panel_vm[lastvm]; panel_vm.remove(wobj);
				wobj = window_vm[lastvm]; window_vm.remove(wobj);
				wobj = instances_deployed[lastvm]; instances_deployed.remove(wobj);
				DEPLOYED -= 1;
				update_panels();
				doupdate();
			write_str(window_information['monitor'], 1, 30, "Done.");
			ourtime = time.strftime("%H:%M:%S");
			do_update_bar(window_information['status'], step, 1);
			write_str(window_information['status'], 1, 13, ourtime);
			write_str_color(window_information['status'], 1, 22, "     OK     ", 6, 0);
			update_panels();
			doupdate();
			# sleep before each loop to avoid throttling...
			time.sleep(interval);
		except:
			logging.exception("Getting VMSS Information...")
			write_str(window_information['error'], 1, 24, "Let's sleep for 30 seconds and try to refresh the dashboard again...");
			show_panel(panel_information['error']);
			update_panels();
			doupdate();
			## break out of loop when an error is encountered
			#break
			time.sleep(30);
			hide_panel(panel_information['error']);