Sha256: ef394d6c8f08afd8d259e76d0183c9714556d3980c96b4a6e937dc614a4e18f1
Contents?: true
Size: 1.98 KB
Versions: 1
Compression:
Stored size: 1.98 KB
Contents
module ForemanAzureRM class AzureRMCompute attr_accessor :sdk attr_accessor :azure_vm delegate :name, to: :azure_vm, allow_nil: true def initialize(azure_vm: ComputeModels::VirtualMachine.new, sdk: sdk) @azure_vm = azure_vm @sdk = sdk end def id @azure_vm.id end def persisted? !!identity && !!id end def vm_size @azure_vm.hardware_profile.vm_size end def wait_for(_timeout = 0, _interval = 0, &block) instance_eval(&block) return true end def ready? vm_status == 'running' end def state vm_status end def vm_status sdk.check_vm_status(@azure_vm.resource_group, name) end def network_interface_card_ids nics = @azure_vm.network_profile.network_interfaces nics.map(&:id) end 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 = sdk.public_ip(ip_rg, ip_name) return public_ip.ip_address else return configuration.private_ipaddress end end end end def interfaces interfaces = [] unless network_interface_card_ids.nil? network_interface_card_ids.each do |nic_id| nic_rg = nic_id.split('/')[4] nic_name = nic_id.split('/')[-1] interfaces << sdk.vm_nic(nic_rg, nic_name) end end interfaces end def interfaces=(setifaces) @azure_vm.network_profile.network_interfaces = setifaces end def ip_addresses [] end def identity @azure_vm.name end def identity=(setuuid) @azure_vm.name = setuuid end def image_id end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
foreman_azure_rm-2.0.0.pre1 | app/models/foreman_azure_rm/azure_rm_compute.rb |