diff --git a/lib/xclarity_client/configuration.rb b/lib/xclarity_client/configuration.rb index 2b6c63dd3b..e740e295f4 100644 --- a/lib/xclarity_client/configuration.rb +++ b/lib/xclarity_client/configuration.rb @@ -10,6 +10,7 @@ def initialize(args) args.each { |key, value| send("#{key}=", value) } if [username, password, host, verify_ssl].any? { |item| item.nil? } + $lxca_log.error "XClarityClient::Configuration initialize","username, password, host, and verify_ssl must all be specified" raise ArgumentError, "username, password, host, and verify_ssl must all be specified" end @@ -18,6 +19,8 @@ def initialize(args) @auth_type = 'basic_auth' end + $lxca_log.info "XClarityClient::Configuration initialize","Configuration built successfuly" + @csrf_token ||= SecureRandom.base64(120) if @auth_type == 'token' end diff --git a/lib/xclarity_client/node_management.rb b/lib/xclarity_client/node_management.rb index 1824c4788f..6194bc4ead 100644 --- a/lib/xclarity_client/node_management.rb +++ b/lib/xclarity_client/node_management.rb @@ -22,12 +22,16 @@ def set_node_power_state(uuid, powerState = OFF) else JSON.generate(powerState: 'powerOn') end + $lxca_log.info "XclarityClient::ManagementMixin set_node_power_state", "Power state action has been sent" do_put(Node::BASE_URI + '/' + uuid, power_request) end def set_loc_led_state(uuid, state, name = 'Identify') request = JSON.generate(leds: [{ name: name, state: state }]) + + $lxca_log.info "XclarityClient::ManagementMixin set_loc_led_state", "Loc led state action has been sent" + do_put("#{Node::BASE_URI}/#{uuid}", request) end end diff --git a/lib/xclarity_client/virtual_appliance_management.rb b/lib/xclarity_client/virtual_appliance_management.rb index ac166174f2..a7c426058b 100644 --- a/lib/xclarity_client/virtual_appliance_management.rb +++ b/lib/xclarity_client/virtual_appliance_management.rb @@ -23,6 +23,7 @@ def configuration_settings=() def ip_enablement_state uri = BASE_URI+NETWORK_URI+IPDISABLE_URI + $lxca_log.info "XclarityClient::VirtualApplianceManagement ip_enablement_state", "Action has been sent to #{uri}" response = connection(uri) response end @@ -33,6 +34,7 @@ def ip_enablement_state=() def host_settings uri = BASE_URI+NETWORK_URI+IPDISABLE_URI + $lxca_log.info "XclarityClient::VirtualApplianceManagement host_settings", "Action has been sent to #{uri}" response = connection(uri) response end @@ -43,6 +45,7 @@ def host_settings=() def network_interface_settings(interface) uri = BASE_URI+NETWORK_URI+INTERFACES_URI+"/#{interface}" + $lxca_log.info "XclarityClient::VirtualApplianceManagement network_interface_settings", "Action has been sent to #{uri}" response = connection(uri) response end @@ -53,6 +56,7 @@ def host_settings=() def route_settings uri = BASE_URI+NETWORK_URI+ROUTES_URI + $lxca_log.info "XclarityClient::VirtualApplianceManagement route_settings", "Action has been sent to #{uri}" response = connection(uri) response end @@ -63,6 +67,7 @@ def route_settings=() def subscriptions uri = BASE_URI+SUBSCRIPTIONS_URI + $lxca_log.info "XclarityClient::VirtualApplianceManagement subscriptions", "Action has been sent to #{uri}" response = connection(uri) response end diff --git a/lib/xclarity_client/xclarity_management_mixin.rb b/lib/xclarity_client/xclarity_management_mixin.rb index 24ac0670c5..b9cfd8111e 100644 --- a/lib/xclarity_client/xclarity_management_mixin.rb +++ b/lib/xclarity_client/xclarity_management_mixin.rb @@ -1,8 +1,12 @@ module XClarityClient module ManagementMixin def get_all_resources (resource, opts = {}) + $lxca_log.info "XclarityClient::ManagementMixin get_all_resources", "Sending request to #{resource} resource" + response = connection(resource::BASE_URI, opts) + $lxca_log.info "XclarityClient::ManagementMixin get_all_resources", "Response received from #{resource::BASE_URI}" + return [] unless response.success? body = JSON.parse(response.body) @@ -15,6 +19,8 @@ def get_all_resources (resource, opts = {}) def get_object(uuids, includeAttributes, excludeAttributes, resource) + $lxca_log.info "XclarityClient::ManagementMixin get_object", "Sending request to #{resource} resource" + uuids.reject! { |uuid| UUID.validate(uuid).nil? } unless uuids.nil? response = if not includeAttributes.nil? @@ -39,6 +45,8 @@ def get_object(uuids, includeAttributes, excludeAttributes, resource) def get_object_with_include_attributes(uuids, attributes, resource) + $lxca_log.info "XclarityClient::ManagementMixin get_object_with_include", "Sending request to #{resource} resource including the following attributes: #{attributes.join(",")}" + uuids.reject! { |uuid| UUID.validate(uuid).nil? } unless uuids.nil? response = if not uuids.nil? @@ -51,6 +59,8 @@ def get_object_with_include_attributes(uuids, attributes, resource) def get_object_with_exclude_attributes(uuids, attributes, resource) + $lxca_log.info "XclarityClient::ManagementMixin get_object_with_include", "Sending request to #{resource} resource excluding the following attributes: #{attributes.join(",")}" + uuids.reject! { |uuid| UUID.validate(uuid).nil? } unless uuids.nil? response = if not uuids.nil? @@ -78,7 +88,8 @@ def get_object_with_opts(opts, resource) else filter += "?type=#{opts["type"]}" end - connection(resource::BASE_URI + filter) + $lxca_log.info "XclarityClient::ManagementMixin get_object_with_include", "Sending request to #{resource} resource using the following filter: #{filter}" + connection(resource::BASE_URI + filter) end return [] unless response.success?