Class: Puppet::Provider::Trove

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.auth_endpointObject



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

def self.auth_endpoint
  @auth_endpoint ||= get_auth_endpoint
end

.conf_filenameObject



37
38
39
# File 'lib/puppet/provider/trove.rb', line 37

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

.get_auth_endpointObject



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

def self.get_auth_endpoint
  q = trove_credentials
  "#{q['auth_url']}"
end

.get_trove_credentialsObject



56
57
58
59
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
# File 'lib/puppet/provider/trove.rb', line 56

def self.get_trove_credentials
  #needed keys for authentication
  auth_keys = ['auth_url', 'project_name', 'username', 'password']
  conf = trove_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['keystone_authtoken']['region_name'].nil?
      creds['region_name'] = conf['keystone_authtoken']['region_name'].strip
    end

    if !conf['keystone_authtoken']['project_domain_name'].nil?
      creds['project_domain_name'] = conf['keystone_authtoken']['project_domain_name'].strip
    else
      creds['project_domain_name'] = 'Default'
    end

    if !conf['keystone_authtoken']['user_domain_name'].nil?
      creds['user_domain_name'] = conf['keystone_authtoken']['user_domain_name'].strip
    else
      creds['user_domain_name'] = 'Default'
    end

    return creds
  else
    raise(Puppet::Error, "File: #{conf_filename} does not contain all " +
          "required sections.  Trove types will not work if trove is not " +
          "correctly configured.")
  end
end

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



14
15
16
17
18
19
20
# File 'lib/puppet/provider/trove.rb', line 14

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

.resetObject



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

def self.reset
  @auth_endpoint = nil
  @trove_conf = nil
  @trove_credentials = nil
end

.trove_confObject



41
42
43
44
45
46
# File 'lib/puppet/provider/trove.rb', line 41

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

.trove_credentialsObject



48
49
50
# File 'lib/puppet/provider/trove.rb', line 48

def self.trove_credentials
  @trove_credentials ||= get_trove_credentials
end

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



22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/puppet/provider/trove.rb', line 22

def self.trove_request(service, action, error, properties=nil)
  properties ||= []
  @credentials.username = trove_credentials['username']
  @credentials.password = trove_credentials['password']
  @credentials.project_name = trove_credentials['project_name']
  @credentials.auth_url = auth_endpoint
  @credentials.user_domain_name = trove_credentials['user_domain_name']
  @credentials.project_domain_name = trove_credentials['project_domain_name']
  if trove_credentials['region_name']
    @credentials.region_name = trove_credentials['region_name']
  end
  raise error unless @credentials.set?
  Puppet::Provider::Openstack.request(service, action, properties, @credentials)
end

Instance Method Details

#trove_credentialsObject



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

def trove_credentials
  self.class.trove_credentials
end

#trove_manage(*args) ⇒ Object



107
108
109
110
111
# File 'lib/puppet/provider/trove.rb', line 107

def trove_manage(*args)
  cmd = args.join(" ")
  output = `#{cmd}`
  $?.exitstatus
end