Sha256: af2c284fb2bf9d8f9a66e1e66fe8b6d8710344f913fc4496a9302afe53cd62df
Contents?: true
Size: 1.3 KB
Versions: 34
Compression:
Stored size: 1.3 KB
Contents
module Fog module Compute class AzureRM # This class provides the actual implementation for service calls. class Real def check_vm_status(resource_group, name, async) msg = "Checking Virtual Machine #{name} status" Fog::Logger.debug msg begin virtual_machine = @compute_mgmt_client.virtual_machines.get(resource_group, name, 'instanceView') rescue MsRestAzure::AzureOperationError => e raise_azure_exception(e, msg) end Fog::Logger.debug "Successfully returned status of Virtual Machine #{name} in Resource Group #{resource_group}" get_status(virtual_machine) end def get_status(virtual_machine) vm_statuses = virtual_machine.instance_view.statuses vm_status = nil vm_statuses.each do |status| if status.code.include? 'PowerState' Fog::Logger.debug status.display_status.to_s vm_status = status.code.split('/')[1] end end vm_status end end # This class provides the mock implementation for unit tests. class Mock def check_vm_status(_resource_group, _name) 'running' end end end end end
Version data entries
34 entries across 34 versions & 3 rubygems