class Fog::Compute::AzureRM::Mock

This class provides the mock implementation for unit tests.

This class provides the mock implementation for unit tests.

This class provides the mock implementation for unit tests.

Mock class for Compute Request

This class provides the mock implementation for unit tests.

This class provides the mock implementation for unit tests.

This class provides the mock implementation for unit tests.

This class provides the mock implementation for unit tests.

This class provides the mock implementation for unit tests.

Mock class for Compute Request

Mock class for Compute Request

This class provides the mock implementation for unit tests.

This class provides the mock implementation for unit tests.

This class provides the mock implementation for unit tests.

This class provides the mock implementation for unit tests.

Mock class for Compute Request

This class provides the mock implementation for unit tests.

Mock class for Compute Request

This class provides the mock implementation for unit tests.

This class provides the mock implementation for unit tests.

This class provides the mock implementation for unit tests.

Mock class for Compute Request

Mock class for Compute Request

This class provides the mock implementation for unit tests.

Mock class for Compute Request

Mock class for Compute Request

This class provides the mock implementation for unit tests.

This class provides the mock implementation for unit tests.

Mock class for Compute Request

Mock class for Compute Request

This class provides the mock implementation for unit tests.

This class provides the mock implementation for unit tests.

This class provides the mock implementation for unit tests.

This class provides the mock implementation for unit tests.

Mock class for Compute Request

This class provides the mock implementation for unit tests.

Public Class Methods

new(_options = {}) click to toggle source
# File lib/fog/azurerm/compute.rb, line 66
def initialize(_options = {})
  begin
    require 'azure_mgmt_compute'
  rescue LoadError => e
    retry if require('rubygems')
    raise e.message
  end
end

Public Instance Methods

add_or_update_vm_extension(*) click to toggle source
# File lib/fog/azurerm/requests/compute/create_or_update_vm_extension.rb, line 38
def add_or_update_vm_extension(*)
  body = {
    'id' => '/subscriptions/########-####-####-####-############/resourceGroups/TestRG/providers/Microsoft.Compute/virtualMachines/TestVM/extensions/IaaSAntimalware',
    'name' => 'IaasAntimalware',
    'resource_group' => 'fog-test-rg',
    'location' => 'West US',
    'properties' => {
      'publisher' => 'Microsoft.Azure.Security',
      'type' => 'IaaSAntimalware',
      'typeHandlerVersion' => '1.3',
      'autoUpgradeMinorVersion' => 'true',
      'forceUpdateTag' => 'RerunExtension',
      'settings' => {
        'AnitmalwareEnabled' => 'true',
        'RealtimeProtectionEnabled' => 'false'
      },
      'protected_settings' => {}
    }
  }
  extension_mapper = Azure::ARM::Compute::Models::VirtualMachineExtension.mapper
  @compute_mgmt_client.deserialize(extension_mapper, body, 'result.body')
end
attach_data_disk_to_vm(*) click to toggle source
# File lib/fog/azurerm/requests/compute/attach_data_disk_to_vm.rb, line 153
def attach_data_disk_to_vm(*)
  vm = {
    'location' => 'West US',
    'id' => '/subscriptions/########-####-####-####-############/resourceGroups/fog-test-rg/providers/Microsoft.Compute/virtualMachines/fog-test-server',
    'name' => 'fog-test-server',
    'type' => 'Microsoft.Compute/virtualMachines',
    'properties' =>
      {
        'hardwareProfile' =>
          {
            'vmSize' => 'Basic_A0'
          },
        'storageProfile' =>
          {
            'imageReference' =>
              {
                'publisher' => 'Canonical',
                'offer' => 'UbuntuServer',
                'sku' => '14.04.2-LTS',
                'version' => 'latest'
              },
            'osDisk' =>
              {
                'name' => 'fog-test-server_os_disk',
                'vhd' =>
                  {
                    'uri' => 'http://mystorage1.blob.core.windows.net/vhds/fog-test-server_os_disk.vhd'
                  },
                'createOption' => 'FromImage',
                'osType' => 'Linux',
                'caching' => 'ReadWrite'
              },
            'dataDisks' => [{
              'lun' => 0,
              'name' => 'fog-test-server_data_disk',
              'vhd_uri' => 'https://confizrg7443.blob.core.windows.net/vhds/fog-test-server_data_disk.vhd',
              'create_option' => 'empty',
              'disk_size_gb' => 1
            }]
          },
        'osProfile' =>
          {
            'computerName' => 'fog',
            'adminUsername' => 'Fog=123',
            'linuxConfiguration' =>
                {
                  'disablePasswordAuthentication' => true
                },
            'secrets' => []
          },
        'networkProfile' =>
          {
            'networkInterfaces' =>
              [
                {
                  'id' => '/subscriptions/########-####-####-####-############/resourceGroups/fog-test-rg/providers/Microsoft.Network/networkInterfaces/fog-test-vnet'
                }
              ]
          },
        'provisioningState' => 'Succeeded'
      }
  }
  vm_mapper = Azure::ARM::Compute::Models::VirtualMachine.mapper
  @compute_mgmt_client.deserialize(vm_mapper, vm, 'result.body')
end
check_availability_set_exists(_resource_group, _name) click to toggle source
# File lib/fog/azurerm/requests/compute/check_availability_set_exists.rb, line 25
def check_availability_set_exists(_resource_group, _name)
  true
end
check_managed_disk_exists(*) click to toggle source
# File lib/fog/azurerm/requests/compute/check_managed_disk_exists.rb, line 26
def check_managed_disk_exists(*)
  Fog::Logger.debug 'Managed Disk test-disk from Resource group fog-rg is available.'
  true
end
check_vm_exists(_resource_group, _name) click to toggle source
# File lib/fog/azurerm/requests/compute/check_vm_exists.rb, line 33
def check_vm_exists(_resource_group, _name)
  true
end
check_vm_extension_exists(*) click to toggle source
# File lib/fog/azurerm/requests/compute/check_vm_extension_exists.rb, line 25
def check_vm_extension_exists(*)
  true
end
check_vm_status(_resource_group, _name) click to toggle source
# File lib/fog/azurerm/requests/compute/check_vm_status.rb, line 32
def check_vm_status(_resource_group, _name)
  'running'
end
create_availability_set(availability_set_params) click to toggle source
# File lib/fog/azurerm/requests/compute/create_availability_set.rb, line 48
def create_availability_set(availability_set_params)
  {
    'location' => availability_set_params[:location],
    'id' => "/subscriptions/########-####-####-####-############/resourceGroups/#{availability_set_params[:resource_group]}/providers/Microsoft.Compute/availabilitySets/#{availability_set_params[:name]}",
    'name' => availability_set_params[:name],
    'type' => 'Microsoft.Compute/availabilitySets',
    'properties' =>
    {
      'platformUpdateDomainCount' => FAULT_DOMAIN_COUNT,
      'platformFaultDomainCount' => FAULT_DOMAIN_COUNT
    }
  }
end
create_image(*) click to toggle source
# File lib/fog/azurerm/requests/compute/create_image.rb, line 43
def create_image(*)
  image_obj = {
    'location' => 'West US',
    'tags' => {
      'key' => 'value'
    },
    'properties' => {
      'storageProfile' => {
        'osDisk' => {
          'osType' => 'Linux',
          'blobUri' => 'https://mystorageaccount.blob.core.windows.net/osimages/osimage.vhd',
          'osState' => 'generalized',
          'hostCaching' => 'readwrite',
          'storageAccountType' => 'Standard_LRS'
        },
        'provisioningState' => 'Succeeded'
      }
    }
  }
  image_mapper = Azure::ARM::Compute::Models::Image.mapper
  @compute_mgmt_client.deserialize(image_mapper, image_obj, 'result.body')
end
create_or_update_managed_disk(*) click to toggle source
# File lib/fog/azurerm/requests/compute/create_or_update_managed_disk.rb, line 78
def create_or_update_managed_disk(*)
  disk = {
    'accountType' => 'Standard_LRS',
    'properties' => {
      'osType' => 'Windows',
      'creationData' => {
        'createOption' => 'Empty'
      },
      'diskSizeGB' => 10,
      'encryptionSettings' => {
        'enabled' => true,
        'diskEncryptionKey' => {
          'sourceVault' => {
            'id' => '/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.KeyVault/vaults/myVMVault'
          },
          'secretUrl' => 'https://myvmvault.vault-int.azure-int.net/secrets/{secret}'
        },
        'keyEncryptionKey' => {
          'sourceVault' => {
            'id' => '/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.KeyVault/vaults/myVMVault'
          },
          'keyUrl' => 'https://myvmvault.vault-int.azure-int.net/keys/{key}'
        }
      },
      'timeCreated' => '2016-12-28T02:46:21.3322041+00:00',
      'provisioningState' => 'Succeeded',
      'diskState' => 'Unattached'
    },
    'type' => 'Microsoft.Compute/disks',
    'location' => 'westus',
    'tags' => {
      'department' => 'Development',
      'project' => 'ManagedDisks'
    },
    'id' => '/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myManagedDisk1',
    'name' => 'myManagedDisk1'
  }
  disk_mapper = Azure::ARM::Compute::Models::Disk.mapper
  @compute_mgmt_client.deserialize(disk_mapper, disk, 'result.body')
end
create_virtual_machine(*) click to toggle source
# File lib/fog/azurerm/requests/compute/create_virtual_machine.rb, line 367
def create_virtual_machine(*)
  vm = {
    'location' => 'westus',
    'id' => '/subscriptions/########-####-####-####-############/resourceGroups/fog-test-rg/providers/Microsoft.Compute/virtualMachines/fog-test-server',
    'name' => 'fog-test-server',
    'type' => 'Microsoft.Compute/virtualMachines',
    'properties' =>
    {
      'hardwareProfile' =>
        {
          'vmSize' => 'Standard_A0'
        },
      'storageProfile' =>
        {
          'imageReference' =>
            {
              'publisher' => 'MicrosoftWindowsServerEssentials',
              'offer' => 'WindowsServerEssentials',
              'sku' => 'WindowsServerEssentials',
              'version' => 'latest'
            },
          'osDisk' =>
            {
              'name' => 'fog-test-server_os_disk',
              'vhd' =>
                {
                  'uri' => 'http://mystorage1.blob.core.windows.net/vhds/fog-test-server_os_disk.vhd'
                },
              'createOption' => 'FromImage',
              'osType' => 'Linux',
              'caching' => 'ReadWrite'
            },
          'dataDisks' => []
        },
      'osProfile' =>
        {
          'computerName' => 'fog-test-server',
          'adminUsername' => 'fog',
          'linuxConfiguration' =>
            {
              'disablePasswordAuthentication' => true
            },
          'secrets' => [],
          'customData' => 'ZWNobyBjdXN0b21EYXRh'
        },
      'networkProfile' =>
        {
          'networkInterfaces' =>
            [
              {
                'id' => '/subscriptions/########-####-####-####-############/resourceGroups/fog-test-rg/providers/Microsoft.Network/networkInterfaces/fog-test-vnet'
              }
            ]
        },
      'provisioningState' => 'Succeeded'
    }
  }

  vm_mapper = Azure::ARM::Compute::Models::VirtualMachine.mapper
  @compute_mgmt_client.deserialize(vm_mapper, vm, 'result.body')
end
deallocate_virtual_machine(*) click to toggle source
# File lib/fog/azurerm/requests/compute/deallocate_virtual_machine.rb, line 28
def deallocate_virtual_machine(*)
  Fog::Logger.debug 'Virtual Machine fog-test-server from Resource group fog-test-rg Deallocated successfully.'
  true
end
delete_availability_set(resource_group, name) click to toggle source
# File lib/fog/azurerm/requests/compute/delete_availability_set.rb, line 20
def delete_availability_set(resource_group, name)
  Fog::Logger.debug "Availability Set #{name} from Resource group #{resource_group} deleted successfully."
  true
end
delete_image(*) click to toggle source
# File lib/fog/azurerm/requests/compute/delete_image.rb, line 22
def delete_image(*)
  Fog::Logger.debug 'Image fog-test-server-osImage from Resource group fog-test-rg deleted successfully.'
  true
end
delete_managed_disk(*) click to toggle source
# File lib/fog/azurerm/requests/compute/delete_managed_disk.rb, line 30
def delete_managed_disk(*)
  Fog::Logger.debug 'Managed Disk test-disk from Resource group fog-test-rg deleted successfully.'
  true
end
delete_virtual_machine(*) click to toggle source
# File lib/fog/azurerm/requests/compute/delete_virtual_machine.rb, line 28
def delete_virtual_machine(*)
  Fog::Logger.debug 'Virtual Machine fog-test-server from Resource group fog-test-rg deleted successfully.'
  true
end
delete_vm_extension(*) click to toggle source
# File lib/fog/azurerm/requests/compute/delete_vm_extension.rb, line 21
def delete_vm_extension(*)
  Fog::Logger.debug 'Extension extension_name of Virtual Machine vm_name in Resource Group resource_group deleted successfully'
  true
end
detach_data_disk_from_vm(*) click to toggle source
# File lib/fog/azurerm/requests/compute/detach_data_disk_from_vm.rb, line 34
def detach_data_disk_from_vm(*)
  vm = {
    'location' => 'West US',
    'id' => '/subscriptions/########-####-####-####-############/resourceGroups/fog-test-rg/providers/Microsoft.Compute/virtualMachines/fog-test-server',
    'name' => 'fog-test-server',
    'type' => 'Microsoft.Compute/virtualMachines',
    'properties' =>
      {
        'hardwareProfile' =>
          {
            'vmSize' => 'Basic_A0'
          },
        'storageProfile' =>
          {
            'imageReference' =>
              {
                'publisher' => 'Canonical',
                'offer' => 'UbuntuServer',
                'sku' => '14.04.2-LTS',
                'version' => 'latest'
              },
            'osDisk' =>
              {
                'name' => 'fog-test-server_os_disk',
                'vhd' =>
                  {
                    'uri' => 'http://mystorage1.blob.core.windows.net/vhds/fog-test-server_os_disk.vhd'
                  },
                'createOption' => 'FromImage',
                'osType' => 'Linux',
                'caching' => 'ReadWrite'
              },
            'dataDisks' => [{
              'lun' => 0,
              'name' => 'fog-test-server_data_disk',
              'vhd_uri' => 'https://confizrg7443.blob.core.windows.net/vhds/fog-test-server_data_disk.vhd',
              'create_option' => 'empty',
              'disk_size_gb' => 1
            }]
          },
        'osProfile' =>
          {
            'computerName' => 'fog',
            'adminUsername' => 'Fog=123',
            'linuxConfiguration' =>
              {
                'disablePasswordAuthentication' => true
              },
            'secrets' => []
          },
        'networkProfile' =>
          {
            'networkInterfaces' =>
              [
                {
                  'id' => '/subscriptions/########-####-####-####-############/resourceGroups/fog-test-rg/providers/Microsoft.Network/networkInterfaces/fog-test-vnet'
                }
              ]
          },
        'provisioningState' => 'Succeeded'
      }
  }
  vm_mapper = Azure::ARM::Compute::Models::VirtualMachine.mapper
  @compute_mgmt_client.deserialize(vm_mapper, vm, 'result.body')
end
generalize_virtual_machine(*) click to toggle source
# File lib/fog/azurerm/requests/compute/generalize_virtual_machine.rb, line 28
def generalize_virtual_machine(*)
  Fog::Logger.debug 'Virtual Machine fog-test-server from Resource group fog-test-rg Generalized successfully.'
  true
end
get_availability_set(*) click to toggle source
# File lib/fog/azurerm/requests/compute/get_availability_set.rb, line 18
def get_availability_set(*)
  {
    'id' => "/subscriptions/########-####-####-####-############/resourceGroups/'resource_group'/providers/Microsoft.Compute/virtualMachines/'name'",
    'name' => 'name',
    'type' => 'Microsoft.Compute/virtualMachines',
    'location' => 'westus',
    '@platform_update_domain_count' => UPDATE_DOMAIN_COUNT,
    '@platform_fault_domain_count' => FAULT_DOMAIN_COUNT,
    '@virtual_machines' => []
  }
end
get_image(*) click to toggle source
# File lib/fog/azurerm/requests/compute/get_image.rb, line 21
def get_image(*)
  body = {
    'id' => '/subscriptions/########-####-####-####-############/resourceGroups/TestRG/providers/Microsoft.Compute/images/TestImage',
    'name' => 'TestImage',
    'resource_group' => 'TestRG',
    'location' => 'West US',
    'storage_profile' => {
      'os_disk' => {
        'os_type' => 'Linux',
        'os_state' => 'Generalized',
        'blob_uri' => 'https://myblob.blob.core.windows.net/images/testimage.vhd',
        'caching' => 'ReadWrite',
        'disk_size_gb' => '5'
      },
      'data_disks' => []
    },
    'provisioning_state' => 'Succeeded'
  }
  image_mapper = Azure::ARM::Compute::Models::Image.mapper
  @compute_mgmt_client.deserialize(image_mapper, body, 'result.body')
end
get_managed_disk(*) click to toggle source
# File lib/fog/azurerm/requests/compute/get_managed_disk.rb, line 21
def get_managed_disk(*)
  disk = {
    'accountType' => 'Standard_LRS',
    'properties' => {
      'osType' => 'Windows',
      'creationData' => {
        'createOption' => 'Empty'
      },
      'diskSizeGB' => 10,
      'encryptionSettings' => {
        'enabled' => true,
        'diskEncryptionKey' => {
          'sourceVault' => {
            'id' => '/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.KeyVault/vaults/myVMVault'
          },
          'secretUrl' => 'https://myvmvault.vault-int.azure-int.net/secrets/{secret}'
        },
        'keyEncryptionKey' => {
          'sourceVault' => {
            'id' => '/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.KeyVault/vaults/myVMVault'
          },
          'keyUrl' => 'https://myvmvault.vault-int.azure-int.net/keys/{key}'
        }
      },
      'timeCreated' => '2016-12-28T02:46:21.3322041+00:00',
      'provisioningState' => 'Succeeded',
      'diskState' => 'Unattached'
    },
    'type' => 'Microsoft.Compute/disks',
    'location' => 'westus',
    'tags' => {
      'department' => 'Development',
      'project' => 'ManagedDisks'
    },
    'id' => '/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myManagedDisk1',
    'name' => 'myManagedDisk1'
  }
  disk_mapper = Azure::ARM::Compute::Models::Disk.mapper
  @compute_mgmt_client.deserialize(disk_mapper, disk, 'result.body')
end
get_virtual_machine(*) click to toggle source
# File lib/fog/azurerm/requests/compute/get_virtual_machine.rb, line 26
def get_virtual_machine(*)
  vm = {
    'location' => 'westus',
    'id' => '/subscriptions/########-####-####-####-############/resourceGroups/fog-test-rg/providers/Microsoft.Compute/virtualMachines/fog-test-server',
    'name' => 'fog-test-server',
    'type' => 'Microsoft.Compute/virtualMachines',
    'properties' =>
    {
      'hardwareProfile' =>
        {
          'vmSize' => 'Basic_A0'
        },
      'storageProfile' =>
        {
          'imageReference' =>
            {
              'publisher' => 'Canonical',
              'offer' => 'UbuntuServer',
              'sku' => '14.04.2-LTS',
              'version' => 'latest'
            },
          'osDisk' =>
            {
              'name' => 'fog-test-server_os_disk',
              'vhd' =>
                {
                  'uri' => 'http://fogtestsafirst.blob.core.windows.net/vhds/fog-test-server_os_disk.vhd'
                },
              'createOption' => 'FromImage',
              'osType' => 'Linux',
              'caching' => 'ReadWrite'
            },
          'dataDisks' => []
        },
      'osProfile' =>
        {
          'computerName' => 'fog',
          'adminUsername' => 'testfog',
          'linuxConfiguration' =>
            {
              'disablePasswordAuthentication' => false
            },
          'secrets' => []
        },
      'networkProfile' =>
        {
          'networkInterfaces' =>
            [
              {
                'id' => '/subscriptions/########-####-####-####-############/resourceGroups/fog-test-rg/providers/Microsoft.Network/networkInterfaces/fog-test-vnet'
              }
            ]
        },
      'provisioningState' => 'Succeeded'
    }
  }
  vm_mapper = Azure::ARM::Compute::Models::VirtualMachine.mapper
  @compute_mgmt_client.deserialize(vm_mapper, vm, 'result.body')
end
get_vm_extension(*) click to toggle source
# File lib/fog/azurerm/requests/compute/get_vm_extension.rb, line 21
def get_vm_extension(*)
  body = {
    'id' => '/subscriptions/########-####-####-####-############/resourceGroups/TestRG/providers/Microsoft.Compute/virtualMachines/TestVM/extensions/IaaSAntimalware',
    'name' => 'IaasAntimalware',
    'resource_group' => 'fog-test-rg',
    'location' => 'West US',
    'properties' => {
      'publisher' => 'Microsoft.Azure.Security',
      'type' => 'IaaSAntimalware',
      'typeHandlerVersion' => '1.3',
      'autoUpgradeMinorVersion' => 'true',
      'forceUpdateTag' => 'RerunExtension',
      'settings' => {
        'AnitmalwareEnabled' => 'true',
        'RealtimeProtectionEnabled' => 'false'
      },
      'protected_settings' => {}
    }
  }
  extension_mapper = Azure::ARM::Compute::Models::VirtualMachineExtension.mapper
  @compute_mgmt_client.deserialize(extension_mapper, body, 'result.body')
end
grant_access_to_managed_disk(*) click to toggle source
# File lib/fog/azurerm/requests/compute/grant_access_to_managed_disk.rb, line 24
def grant_access_to_managed_disk(*)
  'ACCESS URI'
end
list_availability_sets(resource_group) click to toggle source
# File lib/fog/azurerm/requests/compute/list_availability_sets.rb, line 20
def list_availability_sets(resource_group)
  [
    {
      'id' => "/subscriptions/{subscription-id}/resourceGroups/#{resource_group}/providers/Microsoft.Compute/availabilitySets/test_availability_set",
      'name' => 'test_availability_set',
      'type' => 'Microsoft.Compute/availabilitySets',
      'location' => 'westus',
      'tags' =>  {},
      'properties' =>
      {
        'platformUpdateDomainCount' => 5,
        'platformFaultDomainCount' => 3,
        'virtualMachines' => []
      }
    }
  ]
end
list_available_sizes_for_virtual_machine(*) click to toggle source
# File lib/fog/azurerm/requests/compute/list_available_sizes_for_virtual_machine.rb, line 28
def list_available_sizes_for_virtual_machine(*)
  vm_sizes =
    {
      'value' => [
        {
          'name' => 'Standard_A0',
          'numberOfCores' => 1,
          'osDiskSizeInMB' => 1_047_552,
          'resourceDiskSizeInMB' => 20_480,
          'memoryInMB' => 768,
          'maxDataDiskCount' => 1
        },
        {
          'name' => 'Standard_A1',
          'numberOfCores' => 1,
          'osDiskSizeInMB' => 1_047_552,
          'resourceDiskSizeInMB' => 71_680,
          'memoryInMB' => 1792,
          'maxDataDiskCount' => 2
        },
        {
          'name' => 'Standard_A2',
          'numberOfCores' => 2,
          'osDiskSizeInMB' => 1_047_552,
          'resourceDiskSizeInMB' => 138_240,
          'memoryInMB' => 3584,
          'maxDataDiskCount' => 4
        }
      ]
    }
  vm_mapper = Azure::ARM::Compute::Models::VirtualMachineSizeListResult.mapper
  @compute_mgmt_client.deserialize(vm_mapper, vm_sizes, 'result.body').value
end
list_managed_disks_by_rg(*) click to toggle source
# File lib/fog/azurerm/requests/compute/list_managed_disks_by_rg.rb, line 21
def list_managed_disks_by_rg(*)
  disks = [
    {
      'accountType' => 'Standard_LRS',
      'properties' => {
        'osType' => 'Windows',
        'creationData' => {
          'createOption' => 'Empty'
        },
        'diskSizeGB' => 10,
        'encryptionSettings' => {
          'enabled' => true,
          'diskEncryptionKey' => {
            'sourceVault' => {
              'id' => '/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.KeyVault/vaults/myVMVault'
            },
            'secretUrl' => 'https://myvmvault.vault-int.azure-int.net/secrets/{secret}'
          },
          'keyEncryptionKey' => {
            'sourceVault' => {
              'id' => '/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.KeyVault/vaults/myVMVault'
            },
            'keyUrl' => 'https://myvmvault.vault-int.azure-int.net/keys/{key}'
          }
        },
        'timeCreated' => '2016-12-28T02:46:21.3322041+00:00',
        'provisioningState' => 'Succeeded',
        'diskState' => 'Unattached'
      },
      'type' => 'Microsoft.Compute/disks',
      'location' => 'westus',
      'tags' => {
        'department' => 'Development',
        'project' => 'ManagedDisks'
      },
      'id' => '/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myManagedDisk1',
      'name' => 'myManagedDisk1'
    }
  ]
  disk_mapper = Azure::ARM::Compute::Models::DiskList.mapper
  @compute_mgmt_client.deserialize(disk_mapper, disks, 'result.body').value
end
list_managed_disks_in_subscription() click to toggle source
# File lib/fog/azurerm/requests/compute/list_managed_disks_in_subscription.rb, line 21
def list_managed_disks_in_subscription
  disks = [
    {
      'accountType' => 'Standard_LRS',
      'properties' => {
        'osType' => 'Windows',
        'creationData' => {
          'createOption' => 'Empty'
        },
        'diskSizeGB' => 10,
        'encryptionSettings' => {
          'enabled' => true,
          'diskEncryptionKey' => {
            'sourceVault' => {
              'id' => '/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.KeyVault/vaults/myVMVault'
            },
            'secretUrl' => 'https://myvmvault.vault-int.azure-int.net/secrets/{secret}'
          },
          'keyEncryptionKey' => {
            'sourceVault' => {
              'id' => '/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.KeyVault/vaults/myVMVault'
            },
            'keyUrl' => 'https://myvmvault.vault-int.azure-int.net/keys/{key}'
          }
        },
        'timeCreated' => '2016-12-28T02:46:21.3322041+00:00',
        'provisioningState' => 'Succeeded',
        'diskState' => 'Unattached'
      },
      'type' => 'Microsoft.Compute/disks',
      'location' => 'westus',
      'tags' => {
        'department' => 'Development',
        'project' => 'ManagedDisks'
      },
      'id' => '/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myManagedDisk1',
      'name' => 'myManagedDisk1'
    }
  ]
  disk_mapper = Azure::ARM::Compute::Models::DiskList.mapper
  @compute_mgmt_client.deserialize(disk_mapper, disks, 'result.body').value
end
list_virtual_machines(*) click to toggle source
# File lib/fog/azurerm/requests/compute/list_virtual_machines.rb, line 20
def list_virtual_machines(*)
  vms = {
    'value' => [
      {
        'id' => '/subscriptions/########-####-####-####-############/resourceGroups/fog-test-rg/providers/Microsoft.Compute/virtualMachines/fog-test-server',
        'name' => 'fog-test-server',
        'location' => 'West US',
        'properties' => {
          'hardwareProfile' => {
            'vmSize' => 'Basic_A0'
          },
          'storageProfile' => {
            'imageReference' => {
              'publisher' => 'Canonical',
              'offer' => 'UbuntuServer',
              'sku' => '14.04.2-LTS',
              'version' => 'latest'
            },
            'osDisk' => {
              'name' => 'fog-test-server_os_disk',
              'vhd' => {
                'uri' => 'http://storageAccount.blob.core.windows.net/vhds/fog-test-server_os_disk.vhd'
              }
            }
          },
          'osProfile' => {
            'computerName' => 'fog-test-server',
            'adminUsername' => 'shaffan',
            'linuxConfiguration' => {
              'disablePasswordAuthentication' => false
            }
          },
          'networkProfile' => {
            'networkInterfaces' => [
              {
                'id' => '/subscriptions/########-####-####-####-############/resourceGroups/fog-test-rg/providers/Microsoft.Network/networkInterfaces/fog-test-vnet'
              }
            ]
          }
        }
      }
    ]
  }
  vm_mapper = Azure::ARM::Compute::Models::VirtualMachineListResult.mapper
  @compute_mgmt_client.deserialize(vm_mapper, vms, 'result.body').value
end
power_off_virtual_machine(*) click to toggle source
# File lib/fog/azurerm/requests/compute/power_off_virtual_machine.rb, line 28
def power_off_virtual_machine(*)
  Fog::Logger.debug 'Virtual Machine fog-test-server from Resource group fog-test-rg Powered off successfully.'
  true
end
redeploy_virtual_machine(*) click to toggle source
# File lib/fog/azurerm/requests/compute/redeploy_virtual_machine.rb, line 28
def redeploy_virtual_machine(*)
  Fog::Logger.debug 'Virtual Machine fog-test-server from Resource group fog-test-rg Redeployed successfully.'
  true
end
restart_virtual_machine(*) click to toggle source
# File lib/fog/azurerm/requests/compute/restart_virtual_machine.rb, line 28
def restart_virtual_machine(*)
  Fog::Logger.debug 'Virtual Machine fog-test-server from Resource group fog-test-rg Restarted successfully.'
  true
end
revoke_access_to_managed_disk(*) click to toggle source
# File lib/fog/azurerm/requests/compute/revoke_access_to_managed_disk.rb, line 21
def revoke_access_to_managed_disk(*)
  response = {
    'name' => 'revoke',
    'status' => 200,
    'error' => 'Error Details'
  }
  response_mapper = Azure::ARM::Compute::Models::OperationStatusResponse.mapper
  @compute_mgmt_client.deserialize(response_mapper, response, 'result.body')
end
start_virtual_machine(*) click to toggle source
# File lib/fog/azurerm/requests/compute/start_virtual_machine.rb, line 28
def start_virtual_machine(*)
  Fog::Logger.debug 'Virtual Machine fog-test-server from Resource group fog-test-rg started successfully.'
  true
end