+ def refresh_nets_status(self, net_list):
+ out_nets = {}
+ self._reload_connection()
+ for net_id in net_list:
+ try:
+ resGroup = self._get_resource_group_name_from_resource_id(net_id)
+ resName = self._get_resource_name_from_resource_id(net_id)
+
+ vnet = self.conn_vnet.virtual_networks.get(resGroup, resName)
+ out_nets[net_id] ={
+ "status": self.provision_state2osm[vnet.provisioning_state],
+ "vim_info": str(vnet)
+ }
+ except CloudError as e:
+ if e.error.error == "ResourceNotFound":
+ out_nets[net_id] = {
+ "status": "DELETED",
+ }
+ else:
+ raise
+ except Exception as e:
+ # TODO distinguish when it is deleted
+ out_nets[net_id] = {
+ "status": "VIM_ERROR",
+ "vim_info": str(vnet),
+ "error_msg": str(e)
+ }
+
+ return out_nets
+
+ def refresh_vms_status(self, vm_list):
+ out_vms = {}
+ self._reload_connection()
+ for vm_id in vm_list:
+ try:
+ resGroup = self._get_resource_group_name_from_resource_id(vm_id)
+ resName = self._get_resource_name_from_resource_id(vm_id)
+
+ vm = self.conn_compute.virtual_machines.get(resGroup, resName)
+ out_vms[vm_id] ={
+ "status": self.provision_state2osm[vm.provisioning_state],
+ "vim_info": str(vm)
+ }
+ except CloudError as e:
+ if e.error.error == "ResourceNotFound":
+ out_vms[vm_id] = {
+ "status": "DELETED",
+ }
+ else:
+ raise
+ except Exception as e:
+ # TODO distinguish when it is deleted
+ out_vms[vm_id] = {
+ "status": "VIM_ERROR",
+ "vim_info": str(vm),
+ "error_msg": str(e)
+ }
+
+ return out_vms