Skip to content

Commit

Permalink
Change the log name and improve logs
Browse files Browse the repository at this point in the history
  • Loading branch information
walteraa committed Jun 5, 2017
1 parent 0c2066d commit 5d4bef8
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 17 deletions.
4 changes: 2 additions & 2 deletions lib/xclarity_client/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def initialize(args)
args.each { |key, value| send("#{key}=", value) }

if [username, password, host, verify_ssl].any? { |item| item.nil? }
$log.error "XClarityClient::Configuration initialize","username, password, host, and verify_ssl must all be specified"
$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

Expand All @@ -19,7 +19,7 @@ def initialize(args)
@auth_type = 'basic_auth'
end

$log.info "XClarityClient::Configuration initialize","Configuration built successfuly"
$lxca_log.info "XClarityClient::Configuration initialize","Configuration built successfuly"

@csrf_token ||= SecureRandom.base64(120) if @auth_type == 'token'
end
Expand Down
4 changes: 2 additions & 2 deletions lib/xclarity_client/node_management.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ def set_node_power_state(uuid, powerState = OFF)
else
JSON.generate(powerState: 'powerOn')
end
$log.info "XclarityClient::ManagementMixin set_node_power_state", "Power state action has been sent"
$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 }])

$log.info "XclarityClient::ManagementMixin set_loc_led_state", "Loc led state action has been sent"
$lxca_log.info "XclarityClient::ManagementMixin set_loc_led_state", "Loc led state action has been sent"

do_put("#{Node::BASE_URI}/#{uuid}", request)
end
Expand Down
10 changes: 5 additions & 5 deletions lib/xclarity_client/virtual_appliance_management.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def configuration_settings=()

def ip_enablement_state
uri = BASE_URI+NETWORK_URI+IPDISABLE_URI
$log.info "XclarityClient::VirtualApplianceManagement ip_enablement_state", "Action has been sent to #{uri}"
$lxca_log.info "XclarityClient::VirtualApplianceManagement ip_enablement_state", "Action has been sent to #{uri}"
response = connection(uri)
response
end
Expand All @@ -34,7 +34,7 @@ def ip_enablement_state=()

def host_settings
uri = BASE_URI+NETWORK_URI+IPDISABLE_URI
$log.info "XclarityClient::VirtualApplianceManagement host_settings", "Action has been sent to #{uri}"
$lxca_log.info "XclarityClient::VirtualApplianceManagement host_settings", "Action has been sent to #{uri}"
response = connection(uri)
response
end
Expand All @@ -45,7 +45,7 @@ def host_settings=()

def network_interface_settings(interface)
uri = BASE_URI+NETWORK_URI+INTERFACES_URI+"/#{interface}"
$log.info "XclarityClient::VirtualApplianceManagement network_interface_settings", "Action has been sent to #{uri}"
$lxca_log.info "XclarityClient::VirtualApplianceManagement network_interface_settings", "Action has been sent to #{uri}"
response = connection(uri)
response
end
Expand All @@ -56,7 +56,7 @@ def host_settings=()

def route_settings
uri = BASE_URI+NETWORK_URI+ROUTES_URI
$log.info "XclarityClient::VirtualApplianceManagement route_settings", "Action has been sent to #{uri}"
$lxca_log.info "XclarityClient::VirtualApplianceManagement route_settings", "Action has been sent to #{uri}"
response = connection(uri)
response
end
Expand All @@ -67,7 +67,7 @@ def route_settings=()

def subscriptions
uri = BASE_URI+SUBSCRIPTIONS_URI
$log.info "XclarityClient::VirtualApplianceManagement subscriptions", "Action has been sent to #{uri}"
$lxca_log.info "XclarityClient::VirtualApplianceManagement subscriptions", "Action has been sent to #{uri}"
response = connection(uri)
response
end
Expand Down
15 changes: 7 additions & 8 deletions lib/xclarity_client/xclarity_management_mixin.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
module XClarityClient
module ManagementMixin
def get_all_resources (resource, opts = {})

$log.info "XclarityClient::ManagementMixin get_all_resources", "Sending request to #{resource} resource"
$lxca_log.info "XclarityClient::ManagementMixin get_all_resources", "Sending request to #{resource} resource"

response = connection(resource::BASE_URI, opts)

$log.info "XclarityClient::ManagementMixin get_all_resources", "Response received from #{resource::BASE_URI}"
$lxca_log.info "XclarityClient::ManagementMixin get_all_resources", "Response received from #{resource::BASE_URI}"

return [] unless response.success?

Expand All @@ -20,7 +19,7 @@ def get_all_resources (resource, opts = {})

def get_object(uuids, includeAttributes, excludeAttributes, resource)

$log.info "XclarityClient::ManagementMixin get_object", "Sending request to #{resource} resource"
$lxca_log.info "XclarityClient::ManagementMixin get_object", "Sending request to #{resource} resource"

uuids.reject! { |uuid| UUID.validate(uuid).nil? } unless uuids.nil?

Expand All @@ -46,7 +45,7 @@ def get_object(uuids, includeAttributes, excludeAttributes, resource)

def get_object_with_include_attributes(uuids, attributes, resource)

$log.info "XclarityClient::ManagementMixin get_object_with_include", "Sending request to #{resource} resource including the following attributes: #{attributes.join(",")}"
$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?

Expand All @@ -60,7 +59,7 @@ def get_object_with_include_attributes(uuids, attributes, resource)

def get_object_with_exclude_attributes(uuids, attributes, resource)

$log.info "XclarityClient::ManagementMixin get_object_with_include", "Sending request to #{resource} resource excluding the following attributes: #{attributes.join(",")}"
$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?

Expand Down Expand Up @@ -89,8 +88,8 @@ def get_object_with_opts(opts, resource)
else
filter += "?type=#{opts["type"]}"
end
$log.info "XclarityClient::ManagementMixin get_object_with_include", "Sending request to #{resource} resource using the following filter: #{filter}"
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?
Expand Down

0 comments on commit 5d4bef8

Please sign in to comment.