Class: Fog::Compute::AzureRM::Mock
- Inherits:
-
Object
- Object
- Fog::Compute::AzureRM::Mock
- Defined in:
- lib/fog/azurerm/compute.rb,
lib/fog/azurerm/requests/compute/check_vm_status.rb,
lib/fog/azurerm/requests/compute/get_virtual_machine.rb,
lib/fog/azurerm/requests/compute/get_availability_set.rb,
lib/fog/azurerm/requests/compute/list_virtual_machines.rb,
lib/fog/azurerm/requests/compute/start_virtual_machine.rb,
lib/fog/azurerm/requests/compute/attach_data_disk_to_vm.rb,
lib/fog/azurerm/requests/compute/create_virtual_machine.rb,
lib/fog/azurerm/requests/compute/delete_virtual_machine.rb,
lib/fog/azurerm/requests/compute/list_availability_sets.rb,
lib/fog/azurerm/requests/compute/create_availability_set.rb,
lib/fog/azurerm/requests/compute/delete_availability_set.rb,
lib/fog/azurerm/requests/compute/restart_virtual_machine.rb,
lib/fog/azurerm/requests/compute/detach_data_disk_from_vm.rb,
lib/fog/azurerm/requests/compute/redeploy_virtual_machine.rb,
lib/fog/azurerm/requests/compute/power_off_virtual_machine.rb,
lib/fog/azurerm/requests/compute/deallocate_virtual_machine.rb,
lib/fog/azurerm/requests/compute/generalize_virtual_machine.rb,
lib/fog/azurerm/requests/compute/list_available_sizes_for_virtual_machine.rb
Overview
This class provides the mock implementation for unit tests.
Instance Method Summary collapse
- #attach_data_disk_to_vm ⇒ Object
- #check_vm_status(_resource_group, _name) ⇒ Object
- #create_availability_set(resource_group, name, location) ⇒ Object
- #create_virtual_machine ⇒ Object
- #deallocate_virtual_machine ⇒ Object
- #delete_availability_set(resource_group, name) ⇒ Object
- #delete_virtual_machine ⇒ Object
- #detach_data_disk_from_vm ⇒ Object
- #generalize_virtual_machine ⇒ Object
- #get_availability_set ⇒ Object
- #get_virtual_machine ⇒ Object
-
#initialize(_options = {}) ⇒ Mock
constructor
A new instance of Mock.
- #list_availability_sets(resource_group) ⇒ Object
- #list_available_sizes_for_virtual_machine ⇒ Object
- #list_virtual_machines ⇒ Object
- #power_off_virtual_machine ⇒ Object
- #redeploy_virtual_machine ⇒ Object
- #restart_virtual_machine ⇒ Object
- #start_virtual_machine ⇒ Object
Constructor Details
#initialize(_options = {}) ⇒ Mock
Returns a new instance of Mock.
38 39 40 41 42 43 44 45 |
# File 'lib/fog/azurerm/compute.rb', line 38 def initialize( = {}) begin require 'azure_mgmt_compute' rescue LoadError => e retry if require('rubygems') raise e. end end |
Instance Method Details
#attach_data_disk_to_vm ⇒ Object
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
# File 'lib/fog/azurerm/requests/compute/attach_data_disk_to_vm.rb', line 92 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_vm_status(_resource_group, _name) ⇒ Object
32 33 34 |
# File 'lib/fog/azurerm/requests/compute/check_vm_status.rb', line 32 def check_vm_status(_resource_group, _name) 'running' end |
#create_availability_set(resource_group, name, location) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/fog/azurerm/requests/compute/create_availability_set.rb', line 32 def create_availability_set(resource_group, name, location) { 'location' => location, 'id' => "/subscriptions/########-####-####-####-############/resourceGroups/#{resource_group}/providers/Microsoft.Compute/availabilitySets/#{name}", 'name' => name, 'type' => 'Microsoft.Compute/availabilitySets', 'properties' => { 'platformUpdateDomainCount' => FAULT_DOMAIN_COUNT, 'platformFaultDomainCount' => FAULT_DOMAIN_COUNT } } end |
#create_virtual_machine ⇒ Object
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 |
# File 'lib/fog/azurerm/requests/compute/create_virtual_machine.rb', line 130 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 ⇒ Object
20 21 22 23 |
# File 'lib/fog/azurerm/requests/compute/deallocate_virtual_machine.rb', line 20 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) ⇒ Object
20 21 22 23 |
# 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_virtual_machine ⇒ Object
20 21 22 23 |
# File 'lib/fog/azurerm/requests/compute/delete_virtual_machine.rb', line 20 def delete_virtual_machine(*) Fog::Logger.debug 'Virtual Machine fog-test-server from Resource group fog-test-rg deleted successfully.' true end |
#detach_data_disk_from_vm ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/fog/azurerm/requests/compute/detach_data_disk_from_vm.rb', line 27 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 ⇒ Object
20 21 22 23 |
# File 'lib/fog/azurerm/requests/compute/generalize_virtual_machine.rb', line 20 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 ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# 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_virtual_machine ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/fog/azurerm/requests/compute/get_virtual_machine.rb', line 20 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 |
#list_availability_sets(resource_group) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# 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 ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/fog/azurerm/requests/compute/list_available_sizes_for_virtual_machine.rb', line 20 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_virtual_machines ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# 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 ⇒ Object
20 21 22 23 |
# File 'lib/fog/azurerm/requests/compute/power_off_virtual_machine.rb', line 20 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 ⇒ Object
20 21 22 23 |
# File 'lib/fog/azurerm/requests/compute/redeploy_virtual_machine.rb', line 20 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 ⇒ Object
20 21 22 23 |
# File 'lib/fog/azurerm/requests/compute/restart_virtual_machine.rb', line 20 def restart_virtual_machine(*) Fog::Logger.debug 'Virtual Machine fog-test-server from Resource group fog-test-rg Restarted successfully.' true end |
#start_virtual_machine ⇒ Object
20 21 22 23 |
# File 'lib/fog/azurerm/requests/compute/start_virtual_machine.rb', line 20 def start_virtual_machine(*) Fog::Logger.debug 'Virtual Machine fog-test-server from Resource group fog-test-rg started successfully.' true end |