Class: XClarityClient::UpdateCompManagement
Overview
update component management class
Instance Method Summary
collapse
-
#add_uri(force_update_mode, onerror_mode, uri) ⇒ Object
splitted create_uri just to fix codeclimate error.
-
#apply_firmware_update(opts, activation_mode, force_update_mode, onerror_mode) ⇒ Object
-
#cancel_firmware_update(server, switch, storage, cmm) ⇒ Object
-
#create_req_json(server, switch, storage, cmm) ⇒ Object
-
#create_uri(activation_mode, force_update_mode, onerror_mode) ⇒ Object
-
#modify_power_state(server, switch, storage, cmm) ⇒ Object
-
#updatable_device_comp ⇒ Object
-
#validate_activation_mode(activation_mode) ⇒ Object
-
#validate_arguments(activation_mode, forceupdate_mode, onerror_mode) ⇒ Object
-
#validate_forceupdate_mode(forceupdate_mode) ⇒ Object
-
#validate_onerror_mode(onerror_mode) ⇒ Object
#fetch_all, #get_headers_with_opts, #get_object, #get_object_with_id, #get_object_with_opts, #initialize
#build_response_with_resource_list
#add_listname_on_body
Instance Method Details
#add_uri(force_update_mode, onerror_mode, uri) ⇒ Object
splitted create_uri just to fix codeclimate error
86
87
88
89
90
91
|
# File 'lib/xclarity_client/services/update_comp_management.rb', line 86
def add_uri(force_update_mode, onerror_mode, uri)
fmode = force_update_mode.nil?
uri += '&forceUpdateMode=' + force_update_mode unless fmode
uri += '&onErrorMode=' + onerror_mode unless onerror_mode.nil?
uri
end
|
#apply_firmware_update(opts, activation_mode, force_update_mode, onerror_mode) ⇒ Object
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/xclarity_client/services/update_comp_management.rb', line 21
def apply_firmware_update(opts, activation_mode, force_update_mode,
onerror_mode)
validate_arguments(activation_mode, force_update_mode, onerror_mode)
uri = create_uri(activation_mode, force_update_mode, onerror_mode)
apply_req = create_req_json(opts['server'], opts['switch'],
opts['storage'], opts['cmm'])
response = @connection.do_put(UpdateComp::BASE_URI + '?action=apply'\
+ uri, apply_req)
response.body
end
|
#cancel_firmware_update(server, switch, storage, cmm) ⇒ Object
34
35
36
37
38
39
40
|
# File 'lib/xclarity_client/services/update_comp_management.rb', line 34
def cancel_firmware_update(server, switch, storage, cmm)
cancel_req = create_req_json(server, switch, storage, cmm)
response = @connection.do_put(UpdateComp::BASE_URI\
+ '?action=cancelApply',
cancel_req)
response.body
end
|
#create_req_json(server, switch, storage, cmm) ⇒ Object
100
101
102
103
104
105
106
107
108
109
|
# File 'lib/xclarity_client/services/update_comp_management.rb', line 100
def create_req_json(server, switch, storage, cmm)
server_json = JSON.generate(:ServerList => server)
switch_json = JSON.generate(:SwitchList => switch)
storage_json = JSON.generate(:StorageList => storage)
cmm_json = JSON.generate(:CMMList => cmm)
req_json = "{\"DeviceList\": [#{server_json},#{switch_json},"\
+ "#{storage_json},#{cmm_json}]}"
req_json
end
|
#create_uri(activation_mode, force_update_mode, onerror_mode) ⇒ Object
93
94
95
96
97
98
|
# File 'lib/xclarity_client/services/update_comp_management.rb', line 93
def create_uri(activation_mode, force_update_mode, onerror_mode)
uri = ''
amode = activation_mode.nil?
uri += '&activationMode=' + activation_mode unless amode
add_uri(force_update_mode, onerror_mode, uri)
end
|
#modify_power_state(server, switch, storage, cmm) ⇒ Object
42
43
44
45
46
47
|
# File 'lib/xclarity_client/services/update_comp_management.rb', line 42
def modify_power_state(server, switch, storage, cmm)
power_state_req = create_req_json(server, switch, storage, cmm)
response = @connection.do_put(UpdateComp::BASE_URI + '?action=powerState',
power_state_req)
response.body
end
|
#updatable_device_comp ⇒ Object
#validate_activation_mode(activation_mode) ⇒ Object
49
50
51
52
53
54
55
56
|
# File 'lib/xclarity_client/services/update_comp_management.rb', line 49
def validate_activation_mode(activation_mode)
if !activation_mode.nil? && !activation_mode.casecmp('immediate').zero? &&
!activation_mode.casecmp('delayed').zero?
raise 'Invalid argument specified. Operation apply_firmware_update'\
+ ' can have activationMode as either immediare or delayed.'
end
end
|
#validate_arguments(activation_mode, forceupdate_mode, onerror_mode) ⇒ Object
79
80
81
82
83
|
# File 'lib/xclarity_client/services/update_comp_management.rb', line 79
def validate_arguments(activation_mode, forceupdate_mode, onerror_mode)
validate_activation_mode(activation_mode)
validate_forceupdate_mode(forceupdate_mode)
validate_onerror_mode(onerror_mode)
end
|
#validate_forceupdate_mode(forceupdate_mode) ⇒ Object
58
59
60
61
62
63
64
65
66
|
# File 'lib/xclarity_client/services/update_comp_management.rb', line 58
def validate_forceupdate_mode(forceupdate_mode)
if !forceupdate_mode.nil? && !forceupdate_mode.casecmp('true').zero? &&
!forceupdate_mode.casecmp('false').zero?
raise 'Invalid argument specified. Value for forceUpdateMode on'\
+ ' operation apply_firmware_update should have a value'\
+ ' of either true or false'
end
end
|
#validate_onerror_mode(onerror_mode) ⇒ Object
68
69
70
71
72
73
74
75
76
77
|
# File 'lib/xclarity_client/services/update_comp_management.rb', line 68
def validate_onerror_mode(onerror_mode)
if !onerror_mode.nil? && !onerror_mode.eql?('stopOnError') &&
!onerror_mode.eql?('stopdeviceOnError') &&
!onerror_mode.eql?('continueOnError')
raise 'Invalid argument specified. Operation apply_firmware_update'\
+ " should have onErrorMode as : 'stopOnError' or"\
+ " 'stopdeviceOnError' or 'continueOnError'"
end
end
|