Class: Fog::Compute::AzureRM::Servers

Inherits:
Fog::Collection
  • Object
show all
Defined in:
lib/fog/azurerm/models/compute/servers.rb

Overview

This class is giving implementation of all/list, and get for Server.

Instance Method Summary collapse

Instance Method Details

#allObject



10
11
12
13
14
15
16
17
# File 'lib/fog/azurerm/models/compute/servers.rb', line 10

def all
  requires :resource_group
  virtual_machines = []
  service.list_virtual_machines(resource_group).each do |vm|
    virtual_machines << Fog::Compute::AzureRM::Server.parse(vm)
  end
  load(virtual_machines)
end

#check_vm_exists(resource_group, name, async = false) ⇒ Object



35
36
37
38
39
40
41
42
43
# File 'lib/fog/azurerm/models/compute/servers.rb', line 35

def check_vm_exists(resource_group, name, async = false)
  response = service.check_vm_exists(resource_group, name, async)
  if async
    server = Fog::Compute::AzureRM::Server.new(service: service)
    Fog::AzureRM::AsyncResponse.new(server, response)
  else
    response
  end
end

#create_async(attributes = {}) ⇒ Object



19
20
21
22
23
# File 'lib/fog/azurerm/models/compute/servers.rb', line 19

def create_async(attributes = {})
  server = new(attributes)
  promise = server.save(true)
  Fog::AzureRM::AsyncResponse.new(server, promise, true, 'update_attributes')
end

#get(resource_group_name, virtual_machine_name, async = false) ⇒ Object



25
26
27
28
29
30
31
32
33
# File 'lib/fog/azurerm/models/compute/servers.rb', line 25

def get(resource_group_name, virtual_machine_name, async = false)
  response = service.get_virtual_machine(resource_group_name, virtual_machine_name, async)
  virtual_machine = Fog::Compute::AzureRM::Server.new(service: service)
  if async
    Fog::AzureRM::AsyncResponse.new(virtual_machine, response)
  else
    virtual_machine.merge_attributes(Fog::Compute::AzureRM::Server.parse(response))
  end
end