Class: VagrantPlugins::Cloudstack::Service::CloudstackResourceService

Inherits:
Object
  • Object
show all
Includes:
Exceptions
Defined in:
lib/vagrant-cloudstack/service/cloudstack_resource_service.rb

Instance Method Summary collapse

Constructor Details

#initialize(cloudstack_compute, ui) ⇒ CloudstackResourceService

Returns a new instance of CloudstackResourceService.



9
10
11
12
# File 'lib/vagrant-cloudstack/service/cloudstack_resource_service.rb', line 9

def initialize(cloudstack_compute, ui)
  @cloudstack_compute = cloudstack_compute
  @ui                 = ui
end

Instance Method Details

#sync_resource(resource, api_parameters = {}) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/vagrant-cloudstack/service/cloudstack_resource_service.rb', line 14

def sync_resource(resource, api_parameters = {})
  @resource_details = nil
  if resource.id.nil? and !(resource.name.nil? || resource.name.empty? )
    resource.id = name_to_id(resource.name, resource.kind, api_parameters)
  elsif resource.id
    resource.name = id_to_name(resource.id, resource.kind, api_parameters)
  end

  unless resource.is_id_undefined? || resource.is_name_undefined?
    resource.details = @resource_details
    @ui.detail("Syncronized resource: #{resource}")
  end
end