Class: Puppet::Provider::MistralWorkflowRequester

Inherits:
Openstack
  • Object
show all
Defined in:
lib/puppet/provider/mistral_workflow_requester.rb

Direct Known Subclasses

Mistral

Class Method Summary collapse

Class Method Details

.request(service, action, properties, credentials = nil, options = {}) ⇒ Object

Returns an array of hashes, where the keys are the downcased CSV headers with underscores instead of spaces

Parameters:

  • options (Hash) (defaults to: {})

    Other options



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/puppet/provider/mistral_workflow_requester.rb', line 19

def self.request(service, action, properties, credentials=nil, options={})
  env = credentials ? credentials.to_env : {}

  # We only need to override the create action
  if action != 'create'
    return super
  end

  Puppet::Util.withenv(env) do
    rv = nil
    begin
      # shell output is:
      # ID,Name,Description,Enabled
      response = openstack(service, action, '--quiet', '--format', 'csv', properties)
      response = parse_csv(response)
      keys = response.delete_at(0)

      if response.collect.length > 1
        definition_file = properties[-1]
        Puppet.warning("#{definition_file} creates more than one workflow, only the first one will be returned after the request.")
      end
      rv = response.collect do |line|
        hash = {}
        keys.each_index do |index|
          key = keys[index].downcase.gsub(/ /, '_').to_sym
          hash[key] = line[index]
        end
        hash
      end
    rescue Puppet::ExecutionFailure => exception
      raise Puppet::Error::OpenstackUnauthorizedError, 'Could not authenticate' if exception.message =~ /HTTP 40[13]/
      raise
    end
  end
  return rv
end