mirror of
https://github.com/inspec/inspec
synced 2024-12-18 17:14:33 +00:00
93f5dcd072
Signed-off-by: Russell Seymour <russell.seymour@turtlesystems.co.uk>
30 lines
720 B
Ruby
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
|