Class: Fog::Compute::AzureRM::Server
- Inherits:
-
Model
- Object
- Model
- Fog::Compute::AzureRM::Server
- Defined in:
- lib/fog/azurerm/models/compute/server.rb
Overview
This class is giving implementation of create/save and delete/destroy for Virtual Machine.
Class Method Summary collapse
Instance Method Summary collapse
- #deallocate ⇒ Object
- #destroy ⇒ Object
- #generalize ⇒ Object
- #list_available_sizes ⇒ Object
- #power_off ⇒ Object
- #redeploy ⇒ Object
- #restart ⇒ Object
- #save ⇒ Object
- #start ⇒ Object
Class Method Details
.parse(vm) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/fog/azurerm/models/compute/server.rb', line 27 def self.parse(vm) hash = {} hash['id'] = vm['id'] hash['name'] = vm['name'] hash['location'] = vm['location'] hash['resource_group'] = vm['id'].split('/')[4] hash['vm_size'] = vm['properties']['hardwareProfile']['vmSize'] hash['os_disk_name'] = vm['properties']['storageProfile']['osDisk']['name'] hash['vhd_uri'] = vm['properties']['storageProfile']['osDisk']['vhd']['uri'] hash['publisher'] = vm['properties']['storageProfile']['imageReference']['publisher'] hash['offer'] = vm['properties']['storageProfile']['imageReference']['offer'] hash['sku'] = vm['properties']['storageProfile']['imageReference']['sku'] hash['version'] = vm['properties']['storageProfile']['imageReference']['version'] hash['username'] = vm['properties']['osProfile']['adminUsername'] hash['disable_password_authentication'] = vm['properties']['osProfile']['linuxConfiguration']['disablePasswordAuthentication'] hash['network_interface_card_id'] = vm['properties']['networkProfile']['networkInterfaces'][0]['id'] hash['availability_set_id'] = vm['properties']['availabilitySet']['id'] unless vm['properties']['availabilitySet'].nil? hash end |
Instance Method Details
#deallocate ⇒ Object
80 81 82 |
# File 'lib/fog/azurerm/models/compute/server.rb', line 80 def deallocate service.deallocate_virtual_machine(resource_group, name) end |
#destroy ⇒ Object
60 61 62 |
# File 'lib/fog/azurerm/models/compute/server.rb', line 60 def destroy service.delete_virtual_machine(resource_group, name) end |
#generalize ⇒ Object
64 65 66 |
# File 'lib/fog/azurerm/models/compute/server.rb', line 64 def generalize service.generalize_virtual_machine(resource_group, name) end |
#list_available_sizes ⇒ Object
88 89 90 |
# File 'lib/fog/azurerm/models/compute/server.rb', line 88 def list_available_sizes service.list_available_sizes_for_virtual_machine(resource_group, name) end |
#power_off ⇒ Object
68 69 70 |
# File 'lib/fog/azurerm/models/compute/server.rb', line 68 def power_off service.power_off_virtual_machine(resource_group, name) end |
#redeploy ⇒ Object
84 85 86 |
# File 'lib/fog/azurerm/models/compute/server.rb', line 84 def redeploy service.redeploy_virtual_machine(resource_group, name) end |
#restart ⇒ Object
76 77 78 |
# File 'lib/fog/azurerm/models/compute/server.rb', line 76 def restart service.restart_virtual_machine(resource_group, name) end |
#save ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/fog/azurerm/models/compute/server.rb', line 47 def save requires :name, :location, :resource_group, :vm_size, :storage_account_name, :username, :password, :disable_password_authentication, :network_interface_card_id, :publisher, :offer, :sku, :version ssh_key_path = "/home/#{username}/.ssh/authorized_keys" unless ssh_key_data.nil? vm = service.create_virtual_machine(name, location, resource_group, vm_size, storage_account_name, username, password, disable_password_authentication, ssh_key_path, ssh_key_data, network_interface_card_id, availability_set_id, publisher, offer, sku, version) merge_attributes(Fog::Compute::AzureRM::Server.parse(vm)) end |
#start ⇒ Object
72 73 74 |
# File 'lib/fog/azurerm/models/compute/server.rb', line 72 def start service.start_virtual_machine(resource_group, name) end |