Module: FogExtensions::AzureRM::Server
- Extended by:
- ActiveSupport::Concern
- Defined in:
- app/models/concerns/fog_extensions/azurerm/server.rb
Instance Attribute Summary collapse
-
#data_disk_caching ⇒ Object
Returns the value of attribute data_disk_caching.
-
#image_id ⇒ Object
Returns the value of attribute image_id.
-
#os_disk_caching ⇒ Object
Returns the value of attribute os_disk_caching.
-
#os_disk_size ⇒ Object
Returns the value of attribute os_disk_size.
-
#premium_os_disk ⇒ Object
Returns the value of attribute premium_os_disk.
-
#puppet_master ⇒ Object
Returns the value of attribute puppet_master.
-
#script_command ⇒ Object
Returns the value of attribute script_command.
-
#script_uris ⇒ Object
Returns the value of attribute script_uris.
Class Method Summary collapse
Instance Method Summary collapse
- #interfaces ⇒ Object
- #interfaces_attributes=(attrs) ⇒ Object
- #provisioning_ip_address ⇒ Object
- #ready? ⇒ Boolean
- #state ⇒ Object
- #stop ⇒ Object
- #volumes ⇒ Object
- #volumes_attributes=(attrs) ⇒ Object
Instance Attribute Details
#data_disk_caching ⇒ Object
Returns the value of attribute data_disk_caching.
8 9 10 |
# File 'app/models/concerns/fog_extensions/azurerm/server.rb', line 8 def data_disk_caching @data_disk_caching end |
#image_id ⇒ Object
Returns the value of attribute image_id.
10 11 12 |
# File 'app/models/concerns/fog_extensions/azurerm/server.rb', line 10 def image_id @image_id end |
#os_disk_caching ⇒ Object
Returns the value of attribute os_disk_caching.
9 10 11 |
# File 'app/models/concerns/fog_extensions/azurerm/server.rb', line 9 def os_disk_caching @os_disk_caching end |
#os_disk_size ⇒ Object
Returns the value of attribute os_disk_size.
6 7 8 |
# File 'app/models/concerns/fog_extensions/azurerm/server.rb', line 6 def os_disk_size @os_disk_size end |
#premium_os_disk ⇒ Object
Returns the value of attribute premium_os_disk.
7 8 9 |
# File 'app/models/concerns/fog_extensions/azurerm/server.rb', line 7 def premium_os_disk @premium_os_disk end |
#puppet_master ⇒ Object
Returns the value of attribute puppet_master.
11 12 13 |
# File 'app/models/concerns/fog_extensions/azurerm/server.rb', line 11 def puppet_master @puppet_master end |
#script_command ⇒ Object
Returns the value of attribute script_command.
12 13 14 |
# File 'app/models/concerns/fog_extensions/azurerm/server.rb', line 12 def script_command @script_command end |
#script_uris ⇒ Object
Returns the value of attribute script_uris.
13 14 15 |
# File 'app/models/concerns/fog_extensions/azurerm/server.rb', line 13 def script_uris @script_uris end |
Class Method Details
.prepended(base) ⇒ Object
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 |
# File 'app/models/concerns/fog_extensions/azurerm/server.rb', line 23 def self.prepended base base.instance_eval do def parse(vm) hash = {} hash['id'] = vm.id hash['name'] = vm.name hash['location'] = vm.location hash['resource_group'] = get_resource_group_from_id(vm.id) hash['vm_size'] = vm.hardware_profile.vm_size unless vm.hardware_profile.vm_size.nil? unless vm.storage_profile.nil? hash['os_disk_name'] = vm.storage_profile.os_disk.name hash['os_disk_caching'] = vm.storage_profile.os_disk.caching unless vm.storage_profile.os_disk.vhd.nil? hash['os_disk_vhd_uri'] = vm.storage_profile.os_disk.vhd.uri hash['storage_account_name'] = hash['os_disk_vhd_uri'].split('/')[2].split('.')[0] end unless vm.storage_profile.image_reference.nil? unless vm.storage_profile.image_reference.publisher.nil? hash['publisher'] = vm.storage_profile.image_reference.publisher hash['offer'] = vm.storage_profile.image_reference.offer hash['sku'] = vm.storage_profile.image_reference.sku hash['version'] = vm.storage_profile.image_reference.version end end end hash['username'] = vm.os_profile.admin_username hash['custom_data'] = vm.os_profile.custom_data hash['data_disks'] = [] unless vm.storage_profile.data_disks.nil? vm.storage_profile.data_disks.each do |disk| data_disk = Fog::Storage::AzureRM::DataDisk.new hash['data_disks'] << data_disk.merge_attributes(Fog::Storage::AzureRM::DataDisk.parse(disk)) end end hash['disable_password_authentication'] = false hash['disable_password_authentication'] = vm.os_profile.linux_configuration.disable_password_authentication unless vm.os_profile.linux_configuration.nil? if vm.os_profile.windows_configuration hash['provision_vm_agent'] = vm.os_profile.windows_configuration.provision_vmagent hash['enable_automatic_updates'] = vm.os_profile.windows_configuration.enable_automatic_updates end hash['network_interface_card_ids'] = vm.network_profile.network_interfaces.map(&:id) hash['availability_set_id'] = vm.availability_set.id unless vm.availability_set.nil? hash end end end |
Instance Method Details
#interfaces ⇒ Object
92 93 94 95 96 97 98 99 100 101 102 |
# File 'app/models/concerns/fog_extensions/azurerm/server.rb', line 92 def interfaces interfaces = [] unless attributes[:network_interface_card_ids].nil? attributes[:network_interface_card_ids].each do |nic_id| nic_rg = nic_id.split('/')[4] nic_name = nic_id.split('/')[-1] interfaces << service.get_vm_nic(nic_rg, nic_name) end end interfaces end |
#interfaces_attributes=(attrs) ⇒ Object
73 |
# File 'app/models/concerns/fog_extensions/azurerm/server.rb', line 73 def interfaces_attributes=(attrs); end |
#provisioning_ip_address ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'app/models/concerns/fog_extensions/azurerm/server.rb', line 75 def provisioning_ip_address interfaces.each do |nic| nic.ip_configurations.each do |configuration| next unless configuration.primary if configuration.public_ipaddress.present? ip_id = configuration.public_ipaddress.id ip_rg = ip_id.split('/')[4] ip_name = ip_id.split('/')[-1] public_ip = service.get_public_ip(ip_rg, ip_name) return public_ip.ip_address else return configuration.private_ipaddress end end end end |
#ready? ⇒ Boolean
15 16 17 |
# File 'app/models/concerns/fog_extensions/azurerm/server.rb', line 15 def ready? vm_status == 'running' end |
#state ⇒ Object
19 20 21 |
# File 'app/models/concerns/fog_extensions/azurerm/server.rb', line 19 def state vm_status end |
#stop ⇒ Object
116 117 118 119 |
# File 'app/models/concerns/fog_extensions/azurerm/server.rb', line 116 def stop power_off deallocate end |
#volumes ⇒ Object
106 107 108 109 110 111 112 113 114 |
# File 'app/models/concerns/fog_extensions/azurerm/server.rb', line 106 def volumes volumes = [] unless attributes[:data_disks].nil? attributes[:data_disks].each do |disk| volumes << disk end end volumes end |
#volumes_attributes=(attrs) ⇒ Object
104 |
# File 'app/models/concerns/fog_extensions/azurerm/server.rb', line 104 def volumes_attributes=(attrs); end |