Class: Jellyfish::Fog::Azure::Infrastructure
- Inherits:
-
Provisioner
- Object
- Provisioner
- Jellyfish::Fog::Azure::Infrastructure
- Defined in:
- lib/jellyfish_fog/infrastructure.rb
Instance Attribute Summary
Attributes inherited from Provisioner
Instance Method Summary collapse
Methods inherited from Provisioner
critical_error, #details, #initialize, #payload_response_template, perform, provision, retire, warning_retirement_error
Constructor Details
This class inherits a constructor from Jellyfish::Provisioner
Instance Method Details
#provision ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/jellyfish_fog/infrastructure.rb', line 69 def provision server = nil current_vm = nil handle_errors do # CREATE THE AZURE VM CLONE server = connection.servers.create(details) # LOOK UP VMS ASSOCIATED WITH AZURE SUBSCRIPTION azure_vmms = ::Azure::VirtualMachineManagementService.new vms = azure_vmms.list_virtual_machines # LOCATE THE VM JUST CREATED # vms.each { |vm| current_vm = vm if vm.vm_name == details['vm_name'] } vms.each do |vm| current_vm = vm if vm.vm_name == details[:vm_name] end end # POPULATE PAYLOAD RESPONSE TEMPLATE payload_response = payload_response_template payload_response[:raw] = server.attributes # INCLUDE IPADDRESS AND HOSTANME IF THEY EXIST payload_response[:defaults][:ip_address] = current_vm.ipaddress unless current_vm.ipaddress.nil? payload_response[:defaults][:hostname] = current_vm.hostname unless current_vm.hostname.nil? # UPDATE ORDER ITEM - SET STATUS TO CRITICAL IF CANNOT LOCATE IPADDRESS @order_item.provision_status = current_vm.ipaddress.nil? ? :warning : :ok @order_item.payload_response = payload_response end |
#retire ⇒ Object
101 102 103 104 105 106 |
# File 'lib/jellyfish_fog/infrastructure.rb', line 101 def retire handle_errors do connection.delete_virtual_machine(server_attributes['vm_name'], server_attributes['cloud_service_name']) end @order_item.provision_status = :retired end |