Class: VagrantPlugins::WinAzure::Action::VagrantAzureService

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-azure/action/vagrant_azure_service.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(azure) ⇒ VagrantAzureService

Returns a new instance of VagrantAzureService.



14
15
16
# File 'lib/vagrant-azure/action/vagrant_azure_service.rb', line 14

def initialize(azure)
  @azure = azure
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object



36
37
38
# File 'lib/vagrant-azure/action/vagrant_azure_service.rb', line 36

def method_missing(method, *args, &block)
  azure.send(method, *args, &block)
end

Instance Attribute Details

#azureObject (readonly)

Returns the value of attribute azure.



13
14
15
# File 'lib/vagrant-azure/action/vagrant_azure_service.rb', line 13

def azure
  @azure
end

Instance Method Details

#get_virtual_machine(*args) ⇒ Object

At times due to network latency the SDK raises SocketError, this can be rescued and re-try for three attempts.



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/vagrant-azure/action/vagrant_azure_service.rb', line 20

def get_virtual_machine(*args)
  vm = nil
  attempt = 0
  while true
    begin
      vm = azure.get_virtual_machine(*args)
    rescue SocketError
      attempt = attempt + 1
      sleep 5
      next if attempt < 3
    end
    break
  end
  vm
end