inspec/libraries/common/helpers.rb
Russell Seymour 93f5dcd072 Corrected rubocop offences
Signed-off-by: Russell Seymour <russell.seymour@turtlesystems.co.uk>
2017-02-17 17:25:30 +00:00

30 lines
720 B
Ruby

require_relative '../azure_conn'
require 'azure_mgmt_compute'
require_relative 'resource_groups'
class Helpers
# Retrieve the named virtual machine from Azure
def get_vm(name, rg_name)
# Azure connection
azure = AzureConnection.new
client = Azure::ARM::Compute::ComputeManagementClient.new(azure.connection)
client.subscription_id = azure.subscription_id
# Ensure that the resource group exists
rg = ResourceGroups.new(azure)
unless rg.exists(rg_name)
throw "The Resource group cannot be found: #{rg_name}"
end
# get a vm from the named resource group
begin
client.virtual_machines.get(rg_name, name)
rescue => e
e.error_message
end
end
end