Module: Aviator::Openstack::Provider

Defined in:
lib/puppet/feature/aviator/openstack/provider.rb

Defined Under Namespace

Classes: MultipleServiceApisError

Class Method Summary collapse

Class Method Details

.find_request(service, name, session_data, options) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
50
51
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
# File 'lib/puppet/feature/aviator/openstack/provider.rb', line 38

def find_request(service, name, session_data, options)
  service = service.to_s
  endpoint_type = options[:endpoint_type]
  endpoint_types = if endpoint_type
                     [endpoint_type.to_s.camelize]
                   else
                     ['Public', 'Admin']
                   end

  namespace = Aviator.const_get('Openstack') \
                     .const_get(service.camelize) \
                     .const_get('Requests')

  if options[:api_version]
    m = options[:api_version].to_s.match(/(v\d+)\.?\d*/)
    version = m[1].to_s.camelize unless m.nil?
  end

  version ||= infer_version(session_data, name, service)

  unless version.nil?
    version = version.to_s.camelize
  end

  return nil unless version && namespace.const_defined?(version)

  namespace = namespace.const_get(version, name)

  endpoint_types.each do |endpoint_type|
    name = name.to_s.camelize

    next unless namespace.const_defined?(endpoint_type)
    next unless namespace.const_get(endpoint_type).const_defined?(name)

    return namespace.const_get(endpoint_type).const_get(name)
  end

  nil
end

.request_file_paths(service) ⇒ Object



84
85
86
87
88
89
90
91
92
93
# File 'lib/puppet/feature/aviator/openstack/provider.rb', line 84

def request_file_paths(service)
    Dir.glob(Pathname.new(__FILE__).join(
      '..',
       service.to_s,
      'requests',
      '**',
      '*.rb'
      ).expand_path
    )
end

.root_dirObject



79
80
81
# File 'lib/puppet/feature/aviator/openstack/provider.rb', line 79

def root_dir
  Pathname.new(__FILE__).join('..').expand_path
end