Class: Puppet_X::EnterpriseModules::Oci::ResourceLister

Inherits:
Object
  • Object
show all
Includes:
Config, Settings
Defined in:
lib/puppet_x/enterprisemodules/oci/resource_lister.rb

Overview

Docs

Instance Method Summary collapse

Methods included from Settings

#configuration, included, #read_from_yaml, #setting_for, #settings, #settings_file

Methods included from Config

#client_for, #config_for_settings, #default_tenant, #determine_setting_for, #proxy_config, #retry_config, #settings_for, #tenant_config

Constructor Details

#initialize(tenant, object_class) ⇒ ResourceLister

Returns a new instance of ResourceLister.



10
11
12
13
14
15
16
17
# File 'lib/puppet_x/enterprisemodules/oci/resource_lister.rb', line 10

def initialize(tenant, object_class)
  @tenant        = tenant
  @object_class  = object_class
  @object_type   = @object_class.to_s.split('::').last.underscore
  @resource_type = @object_class.to_s.gsub('::Models', '').split('::').join('_').underscore.to_sym
  @tenant_id     = settings_for(@tenant)['tenancy_ocid'] || Facter.value(:oci_instance)['compartment_id']
  @resolver      = Puppet_X::EnterpriseModules::Oci::NameResolver.instance(tenant)
end

Instance Method Details

#resource_list(compartment_id = nil) ⇒ Object



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
# File 'lib/puppet_x/enterprisemodules/oci/resource_lister.rb', line 19

def resource_list(compartment_id = nil)
  case ServiceInfo.type_to_lookup_method(@resource_type)
  when :root
    resources_at_root
  when :db_systems
    resources_in_db_systems(compartment_id)
  when :systems
    resources_in_systems(compartment_id)
  when :protocol
    resources_in_protocol(compartment_id)
  when :availability_domains
    resources_in_availability_domains(compartment_id)
  when :compartment
    resources_in_compartments(compartment_id)
  when :compartment_detailed
    resources_in_compartments(compartment_id, true)
  when :vault
    resources_in_vaults(compartment_id)
  when :drg
    resources_in_drgs(compartment_id)
  when :instance_pool
    resources_in_instance_pools(compartment_id)
  when :namespace
    resources_in_namespace(compartment_id)
  when :tag_namespace
    resources_in_tag_namespace
  else
    fail "Internal error: invalid primary_key for #{@resource_type}"
  end
end