Class: ForemanAzure::Azure
- Inherits:
-
ComputeResource
- Object
- ComputeResource
- ForemanAzure::Azure
- Defined in:
- app/models/foreman_azure/azure.rb
Class Method Summary collapse
Instance Method Summary collapse
- #available_images ⇒ Object
- #capabilities ⇒ Object
- #create_vm(args = {}) ⇒ Object
-
#find_vm_by_uuid(uuid) ⇒ Object
Azure does not have an UUID for each vm.
- #image_locations(image_id) ⇒ Object
- #provided_attributes ⇒ Object
- #provider_friendly_name ⇒ Object
- #test_connection(options = {}) ⇒ Object
- #to_label ⇒ Object
Class Method Details
.model_name ⇒ Object
22 23 24 |
# File 'app/models/foreman_azure/azure.rb', line 22 def self.model_name ComputeResource.model_name end |
Instance Method Details
#available_images ⇒ Object
35 36 37 |
# File 'app/models/foreman_azure/azure.rb', line 35 def available_images client.images end |
#capabilities ⇒ Object
18 19 20 |
# File 'app/models/foreman_azure/azure.rb', line 18 def capabilities [:build, :image] end |
#create_vm(args = {}) ⇒ Object
47 48 49 50 51 52 53 54 55 56 |
# File 'app/models/foreman_azure/azure.rb', line 47 def create_vm(args = {}) args.delete_if { |_key, value| value.blank? } args[:hostname] = args[:name] args[:vm_name] = args[:name].split('.').first args[:cloud_service_name] ||= args[:vm_name] args[:image] = args[:image_id] args[:vm_user] = Image.unscoped.find_by_uuid(args[:image_id]).username args[:private_key_file] = url super(args) end |
#find_vm_by_uuid(uuid) ⇒ Object
Azure does not have an UUID for each vm. It has a unique pair ‘cloud_service_name’ and ‘vm_name’. We will need to override all destroy_vm, start_vm, stop_vm… to accept two parameters.
fog-azure should probably build this UUID concept instead, but until then, we can just do our best to match it
65 66 67 |
# File 'app/models/foreman_azure/azure.rb', line 65 def find_vm_by_uuid(uuid) client.servers.find { |vm| vm.vm_name == uuid } end |
#image_locations(image_id) ⇒ Object
43 44 45 |
# File 'app/models/foreman_azure/azure.rb', line 43 def image_locations(image_id) client.images.get(image_id).locations.split(';') end |
#provided_attributes ⇒ Object
39 40 41 |
# File 'app/models/foreman_azure/azure.rb', line 39 def provided_attributes super.merge(:ip => :public_ip_address) end |
#provider_friendly_name ⇒ Object
26 27 28 |
# File 'app/models/foreman_azure/azure.rb', line 26 def provider_friendly_name 'Azure' end |
#test_connection(options = {}) ⇒ Object
30 31 32 33 |
# File 'app/models/foreman_azure/azure.rb', line 30 def test_connection( = {}) client.storage_accounts # Make a simple 'ping' request super() end |
#to_label ⇒ Object
14 15 16 |
# File 'app/models/foreman_azure/azure.rb', line 14 def to_label "#{name} (#{provider_friendly_name})" end |