Module: Discover::Infrastructure

Extended by:
Util::Logging, Util::OCIClients
Included in:
InfraResources
Defined in:
lib/discover/infrastructure.rb

Constant Summary

Constants included from Util::Logging

Util::Logging::SEV_LABEL, Util::Logging::TRACE

Class Method Summary collapse

Methods included from Util::Logging

logger, logger=

Methods included from Util::OCIClients

create_clients, get_auth_config_object, get_clients, initialize_auth_config, initialize_ce_client, initialize_id_client, initialize_la_client, initialize_lb_client, initialize_rs_client, initialize_vnc_client, set_auth_config_object, set_clients

Class Method Details

.fetch_cluster_details(_auth_object, cluster_id) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/discover/infrastructure.rb', line 16

def fetch_cluster_details(_auth_object, cluster_id)
  client = nil
  begin
    client = Util::OCIClients.get_clients[:ce_client]
    response = client.get_cluster(cluster_id)

    @cluster_details = response.data
  rescue StandardError => e
    logger.error("Error while discovering cluster details: #{e}")
    raise StandardError, 'Error while discovering cluster details.'
    exit
  end
  @cluster_details
end

.fetch_compartment_list(_auth_object, compartment_id) ⇒ Object



46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/discover/infrastructure.rb', line 46

def fetch_compartment_list(_auth_object, compartment_id)
  client = nil
  opts = { compartment_id_in_subtree: true, access_level: 'ANY' }
  begin
    client = Util::OCIClients.get_clients[:id_client]
    response = client.list_compartments(compartment_id, opts)

    @id_response = response.data
  rescue StandardError => e
    logger.error("Error while fetching load balancer details: #{e}")
    raise StandardError, 'Error while fetching load balancer details.'
  end
  @id_response
end

.fetch_free_text_details(_auth_object, cluster_id) ⇒ Object



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/discover/infrastructure.rb', line 74

def fetch_free_text_details(_auth_object, cluster_id)
  client = nil
  begin
    client = Util::OCIClients.get_clients[:rs_client]
    response = client.search_resources(
      OCI::ResourceSearch::Models::FreeTextSearchDetails.new(
        type: 'FreeText',
        text: cluster_id,
        matchingContextType: 'HIGHLIGHTS'
      )
    )
    @free_text_response = response.data
  rescue StandardError => e
    logger.error("Error while fetching free text details: #{e}")
    raise StandardError, 'Error while fetching free text details.'
  end
  @free_text_response
end

.fetch_load_balancer_details(_auth_object, load_balancer_id) ⇒ Object



61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/discover/infrastructure.rb', line 61

def fetch_load_balancer_details(_auth_object, load_balancer_id)
  client = nil
  begin
    client = Util::OCIClients.get_clients[:lb_client]
    response = client.get_load_balancer(load_balancer_id)
    @lb_response = response.data
  rescue StandardError => e
    logger.error("Error while fetching load balancer details: #{e}")
    raise StandardError, 'Error while fetching load balancer details.'
  end
  @lb_response
end

.fetch_node_pool_lists(_auth_object, compartment_id, cluster_id) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/discover/infrastructure.rb', line 31

def fetch_node_pool_lists(_auth_object, compartment_id, cluster_id)
  opts = { cluster_id: cluster_id }
  begin
    client = Util::OCIClients.get_clients[:ce_client]
    response = client.list_node_pools(compartment_id, opts)

    @node_pool_list = response.data
  rescue StandardError => e
    logger.error("Error while discovering node pool list: #{e}")
    raise StandardError, 'Error while discovering node pool list.'
    exit
  end
  @node_pool_list
end

.fetch_subnet_list_response(_auth_object, compartment_id, vcn_id) ⇒ Object



107
108
109
110
111
112
113
114
115
116
117
118
119
120
# File 'lib/discover/infrastructure.rb', line 107

def fetch_subnet_list_response(_auth_object, compartment_id, vcn_id)
  client = nil
  begin
    opts = { vcn_id: vcn_id }
    client = Util::OCIClients.get_clients[:vnc_client]
    response = client.list_subnets(compartment_id, opts)

    @subnet_response = response.data
  rescue StandardError => e
    logger.error("Error while discovering subnet details: #{e}")
    raise StandardError, 'Error while discovering subnet details.'
  end
  @subnet_response
end

.fetch_vcn_response(_auth_object, vcn_id) ⇒ Object



93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/discover/infrastructure.rb', line 93

def fetch_vcn_response(_auth_object, vcn_id)
  client = nil
  begin
    client = Util::OCIClients.get_clients[:vnc_client]
    response = client.get_vcn(vcn_id)

    @vnc_response = response.data
  rescue StandardError => e
    logger.error("Error while discovering VNC details: #{e}")
    raise StandardError, 'Error while discovering VNC details.'
  end
  @vnc_response
end