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
- #provider_friendly_name ⇒ Object
- #test_connection(options = {}) ⇒ Object
- #to_label ⇒ Object
Class Method Details
.model_name ⇒ Object
18 19 20 |
# File 'app/models/foreman_azure/azure.rb', line 18 def self.model_name ComputeResource.model_name end |
Instance Method Details
#available_images ⇒ Object
31 32 33 |
# File 'app/models/foreman_azure/azure.rb', line 31 def available_images client.images end |
#capabilities ⇒ Object
14 15 16 |
# File 'app/models/foreman_azure/azure.rb', line 14 def capabilities [:image] end |
#create_vm(args = {}) ⇒ Object
39 40 41 42 43 44 45 46 |
# File 'app/models/foreman_azure/azure.rb', line 39 def create_vm(args = {}) args[:hostname] = args[:name] args[:vm_name] = args[:name].split('.').first args[:cloud_service_name] ||= args[:vm_name] args[:vm_user] = Image.find_by_uuid(args[:image]).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
55 56 57 |
# File 'app/models/foreman_azure/azure.rb', line 55 def find_vm_by_uuid(uuid) client.servers.find { |vm| vm.vm_name == uuid } end |
#image_locations(image_id) ⇒ Object
35 36 37 |
# File 'app/models/foreman_azure/azure.rb', line 35 def image_locations(image_id) client.images.get(image_id).locations.split(';') end |
#provider_friendly_name ⇒ Object
22 23 24 |
# File 'app/models/foreman_azure/azure.rb', line 22 def provider_friendly_name 'Azure' end |
#test_connection(options = {}) ⇒ Object
26 27 28 29 |
# File 'app/models/foreman_azure/azure.rb', line 26 def test_connection( = {}) client.storage_accounts # Make a simple 'ping' request super() end |
#to_label ⇒ Object
10 11 12 |
# File 'app/models/foreman_azure/azure.rb', line 10 def to_label "#{name} (#{provider_friendly_name})" end |