Class: Puppet::Provider::Mistral

Inherits:
MistralWorkflowRequester
  • Object
show all
Extended by:
Openstack::Auth
Defined in:
lib/puppet/provider/mistral.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.auth_endpointObject



97
98
99
# File 'lib/puppet/provider/mistral.rb', line 97

def self.auth_endpoint
  @auth_endpoint ||= get_auth_endpoint
end

.conf_filenameObject



41
42
43
# File 'lib/puppet/provider/mistral.rb', line 41

def self.conf_filename
  '/etc/mistral/mistral.conf'
end

.get_auth_endpointObject



92
93
94
95
# File 'lib/puppet/provider/mistral.rb', line 92

def self.get_auth_endpoint
  m = mistral_credentials
  "#{m['auth_url']}"
end

.get_mistral_credentialsObject



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/puppet/provider/mistral.rb', line 60

def self.get_mistral_credentials
  auth_keys = ['auth_url', 'project_name', 'username', 'password']
  conf = mistral_conf
  if conf and conf['keystone_authtoken'] and
      auth_keys.all?{|k| !conf['keystone_authtoken'][k].nil?}
    creds = Hash[ auth_keys.map \
                 { |k| [k, conf['keystone_authtoken'][k].strip] } ]

    if conf['project_domain_name']
      creds['project_domain_name'] = conf['project_domain_name']
    else
      creds['project_domain_name'] = 'Default'
    end

    if conf['user_domain_name']
      creds['user_domain_name'] = conf['user_domain_name']
    else
      creds['user_domain_name'] = 'Default'
    end

    if conf['region_name']
      creds['region_name'] = conf['region_name']
    end
    return creds
  else
    raise(Puppet::Error, "File: #{conf_filename} does not contain all " +
          "required authentication options. Mistral types will not work " +
          "if mistral is not correctly configured to use Keystone " +
          "authentication.")
  end
end

.mistral_confObject



45
46
47
48
49
50
# File 'lib/puppet/provider/mistral.rb', line 45

def self.mistral_conf
  return @mistral_conf if @mistral_conf
  @mistral_conf = Puppet::Util::IniConfig::File.new
  @mistral_conf.read(conf_filename)
  @mistral_conf
end

.mistral_credentialsObject



52
53
54
# File 'lib/puppet/provider/mistral.rb', line 52

def self.mistral_credentials
  @mistral_credentials ||= get_mistral_credentials
end

.mistral_request(service, action, error, properties = nil) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/puppet/provider/mistral.rb', line 18

def self.mistral_request(service, action, error, properties=nil)
  warning('Usage of keystone_authtoken parameters is deprecated.')
  properties ||= []
  @credentials.username = mistral_credentials['username']
  @credentials.password = mistral_credentials['password']
  @credentials.project_name = mistral_credentials['project_name']
  @credentials.auth_url = auth_endpoint
  if mistral_credentials['region_name']
    @credentials.region_name = mistral_credentials['region_name']
  end
  if @credentials.version == '3'
    @credentials.user_domain_name = mistral_credentials['user_domain_name']
    @credentials.project_domain_name = mistral_credentials['project_domain_name']
  end
  raise error unless @credentials.set?

  if action == 'create'
    mistral_create_request(action, properties)
  else
    Puppet::Provider::Openstack.request(service, action, properties, @credentials)
  end
end

.request(service, action, properties = nil) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/puppet/provider/mistral.rb', line 10

def self.request(service, action, properties=nil)
  begin
    super
  rescue Puppet::Error::OpenstackAuthInputError, Puppet::Error::OpenstackUnauthorizedError => error
    mistral_request(service, action, error, properties)
  end
end

.resetObject



101
102
103
104
105
# File 'lib/puppet/provider/mistral.rb', line 101

def self.reset
  @mistral_conf = nil
  @mistral_credentials = nil
  @auth_endpoint = nil
end

Instance Method Details

#mistral_credentialsObject



56
57
58
# File 'lib/puppet/provider/mistral.rb', line 56

def mistral_credentials
  self.class.mistral_credentials
end