Class: Chef::Provider::OneFlowService

Inherits:
LWRPBase
  • Object
show all
Defined in:
lib/chef/provider/one_flow_service.rb

Overview

Implementation of Provider class.

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ OneFlowService

Returns a new instance of OneFlowService.



34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/chef/provider/one_flow_service.rb', line 34

def initialize(*args)
  super
  if !@new_resource.flow_url.nil?
    flow_url = @new_resource.flow_url
  elsif !run_context.chef_provisioning.flow_url.nil?
    flow_url = run_context.chef_provisioning.flow_url
  elsif !ENV['ONE_FLOW_URL'].nil?
    flow_url = ENV['ONE_FLOW_URL']
  else
    fail 'OneFlow API URL must be specified.'
  end
  @flow_lib = Chef::Provisioning::OpenNebulaDriver::FlowLib.new(flow_url, driver.one.client.one_auth)
end

Instance Method Details

#load_current_resourceObject



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/chef/provider/one_flow_service.rb', line 52

def load_current_resource
  @current_resource = Chef::Resource::OneFlowService.new(@new_resource.name, run_context)
  service_id = @flow_lib.get_unique_service_id(@new_resource.name, true)

  @current_resource.exists = !service_id.nil?
  return unless @current_resource.exists

  if @new_resource.template.nil?
    @current_resource.template_equal = true
  else
    one_tpl_id = @new_resource.template.is_a?(Fixnum) ? @new_resource.template : @flow_lib.get_unique_template_id(@new_resource.template)
    new_service_template = @flow_lib.get_template(one_tpl_id)
    new_service_template = @flow_lib.normalize_template(@new_resource.name, driver, @flow_lib.merge_template(new_service_template, @new_resource.template_options, true))
    new_service_template.delete(:name)
    new_service_template[:roles].each { |role| [:cardinality, :vm_template_contents].each { |key| role.delete(key) } }
    current_service_template = @flow_lib.get_reduced_service_template(service_id)
    @current_resource.template_equal = @flow_lib.hash_eq?(new_service_template, current_service_template)
  end

  @current_resource.mode(@flow_lib.get_service_permissions(service_id))
  @current_resource.mode_equal = @new_resource.mode == @current_resource.mode

  @current_resource.in_running_state = @flow_lib.get_service_state(service_id) == @flow_lib.class::SERVICE_RUNNING

  @current_resource.equal = @current_resource.template_equal && @current_resource.mode_equal && @current_resource.in_running_state
end

#whyrun_supported?Boolean

Returns:

  • (Boolean)


48
49
50
# File 'lib/chef/provider/one_flow_service.rb', line 48

def whyrun_supported?
  true
end