xclarity_client 0.5.9 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/docs/apib/persisted_result.apib +196 -0
- data/docs/apib/unmanage_request.apib +163 -0
- data/docs/apib/users.apib +26 -0
- data/lib/utils/logger.rb +1 -0
- data/lib/xclarity_client/client.rb +95 -43
- data/lib/xclarity_client/connection/connection.rb +118 -0
- data/lib/xclarity_client/discover.rb +1 -1
- data/lib/xclarity_client/{aicc.rb → endpoints/aicc.rb} +1 -8
- data/lib/xclarity_client/endpoints/buildable_resource_mixin.rb +61 -0
- data/lib/xclarity_client/{cabinet.rb → endpoints/cabinet.rb} +1 -7
- data/lib/xclarity_client/{canister.rb → endpoints/canister.rb} +1 -7
- data/lib/xclarity_client/{chassi.rb → endpoints/chassi.rb} +1 -8
- data/lib/xclarity_client/{cmm.rb → endpoints/cmm.rb} +1 -7
- data/lib/xclarity_client/{config_pattern.rb → endpoints/config_pattern.rb} +2 -9
- data/lib/xclarity_client/{config_profile.rb → endpoints/config_profile.rb} +1 -8
- data/lib/xclarity_client/{config_target.rb → endpoints/config_target.rb} +1 -8
- data/lib/xclarity_client/{discover_request.rb → endpoints/discover_request.rb} +1 -8
- data/lib/xclarity_client/{discovery.rb → endpoints/discovery.rb} +1 -8
- data/lib/xclarity_client/endpoints/endpoints.rb +34 -0
- data/lib/xclarity_client/{event.rb → endpoints/event.rb} +1 -7
- data/lib/xclarity_client/{fan.rb → endpoints/fan.rb} +1 -9
- data/lib/xclarity_client/{fan_mux.rb → endpoints/fan_mux.rb} +2 -10
- data/lib/xclarity_client/{ffdc.rb → endpoints/ffdc.rb} +1 -8
- data/lib/xclarity_client/endpoints/globalsettings.rb +12 -0
- data/lib/xclarity_client/endpoints/hostplatform.rb +17 -0
- data/lib/xclarity_client/{job.rb → endpoints/job.rb} +1 -8
- data/lib/xclarity_client/{node.rb → endpoints/node.rb} +1 -8
- data/lib/xclarity_client/endpoints/osimage.rb +14 -0
- data/lib/xclarity_client/endpoints/persisted_result.rb +8 -0
- data/lib/xclarity_client/{power_supply.rb → endpoints/power_supply.rb} +2 -8
- data/lib/xclarity_client/endpoints/remote_access.rb +8 -0
- data/lib/xclarity_client/endpoints/remotefileserver.rb +15 -0
- data/lib/xclarity_client/{scalable_complex.rb → endpoints/scalable_complex.rb} +1 -8
- data/lib/xclarity_client/{switch.rb → endpoints/switch.rb} +1 -8
- data/lib/xclarity_client/endpoints/unmanage_request.rb +8 -0
- data/lib/xclarity_client/{update_repo.rb → endpoints/update_repo.rb} +1 -8
- data/lib/xclarity_client/{user.rb → endpoints/user.rb} +5 -9
- data/lib/xclarity_client/endpoints/xclarity_endpoint.rb +13 -0
- data/lib/xclarity_client/errors/errors.rb +10 -0
- data/lib/xclarity_client/schemas.rb +199 -0
- data/lib/xclarity_client/services/aicc_management.rb +9 -0
- data/lib/xclarity_client/services/cabinet_management.rb +9 -0
- data/lib/xclarity_client/services/canister_management.rb +9 -0
- data/lib/xclarity_client/services/chassi_management.rb +9 -0
- data/lib/xclarity_client/services/cmm_management.rb +9 -0
- data/lib/xclarity_client/services/config_pattern_management.rb +41 -0
- data/lib/xclarity_client/{config_profile_management.rb → services/config_profile_management.rb} +8 -14
- data/lib/xclarity_client/services/config_target_management.rb +9 -0
- data/lib/xclarity_client/services/discover_request_management.rb +30 -0
- data/lib/xclarity_client/services/discovery_management.rb +9 -0
- data/lib/xclarity_client/services/event_management.rb +9 -0
- data/lib/xclarity_client/services/fan_management.rb +9 -0
- data/lib/xclarity_client/services/fan_mux_management.rb +9 -0
- data/lib/xclarity_client/services/ffdc_management.rb +9 -0
- data/lib/xclarity_client/services/globalsettings_management.rb +26 -0
- data/lib/xclarity_client/services/hostplatform_management.rb +32 -0
- data/lib/xclarity_client/services/job_management.rb +27 -0
- data/lib/xclarity_client/services/mixins/endpoint_manager_mixin.rb +30 -0
- data/lib/xclarity_client/services/mixins/list_name_interpreter_mixin.rb +61 -0
- data/lib/xclarity_client/services/mixins/response_builder_mixin.rb +38 -0
- data/lib/xclarity_client/{node_management.rb → services/node_management.rb} +7 -11
- data/lib/xclarity_client/services/osimage_management.rb +47 -0
- data/lib/xclarity_client/services/persisted_result_management.rb +11 -0
- data/lib/xclarity_client/services/power_supply_management.rb +9 -0
- data/lib/xclarity_client/services/remote_access_management.rb +57 -0
- data/lib/xclarity_client/services/remotefileserver_management.rb +41 -0
- data/lib/xclarity_client/services/scalable_complex_management.rb +9 -0
- data/lib/xclarity_client/services/services.rb +37 -0
- data/lib/xclarity_client/services/switch_management.rb +9 -0
- data/lib/xclarity_client/services/unmanage_request_management.rb +38 -0
- data/lib/xclarity_client/{update_repo_management.rb → services/update_repo_management.rb} +4 -12
- data/lib/xclarity_client/services/user_management.rb +42 -0
- data/lib/xclarity_client/services/xclarity_service.rb +139 -0
- data/lib/xclarity_client/version.rb +1 -1
- data/lib/xclarity_client/xclarity_base.rb +2 -2
- data/lib/xclarity_client.rb +6 -50
- data/xclarity_client.gemspec +1 -0
- metadata +93 -53
- data/lib/xclarity_client/aicc_management.rb +0 -16
- data/lib/xclarity_client/cabinet_management.rb +0 -17
- data/lib/xclarity_client/canister_management.rb +0 -17
- data/lib/xclarity_client/chassi_management.rb +0 -17
- data/lib/xclarity_client/cmm_management.rb +0 -17
- data/lib/xclarity_client/config_pattern_management.rb +0 -48
- data/lib/xclarity_client/config_target_management.rb +0 -14
- data/lib/xclarity_client/discover_request_management.rb +0 -32
- data/lib/xclarity_client/discovery_management.rb +0 -17
- data/lib/xclarity_client/event_management.rb +0 -17
- data/lib/xclarity_client/fan_management.rb +0 -17
- data/lib/xclarity_client/fan_mux_management.rb +0 -17
- data/lib/xclarity_client/ffdc_management.rb +0 -13
- data/lib/xclarity_client/job_management.rb +0 -28
- data/lib/xclarity_client/power_supply_management.rb +0 -17
- data/lib/xclarity_client/scalable_complex_management.rb +0 -17
- data/lib/xclarity_client/switch_management.rb +0 -16
- data/lib/xclarity_client/user_management.rb +0 -17
- data/lib/xclarity_client/xclarity_resource.rb +0 -21
- /data/lib/xclarity_client/{error → errors}/authentication_error.rb +0 -0
- /data/lib/xclarity_client/{error → errors}/connection_failed.rb +0 -0
- /data/lib/xclarity_client/{error → errors}/connection_failed_unknown.rb +0 -0
- /data/lib/xclarity_client/{error → errors}/connection_refused.rb +0 -0
- /data/lib/xclarity_client/{error → errors}/hostname_unknown.rb +0 -0
- /data/lib/xclarity_client/{virtual_appliance_management.rb → services/virtual_appliance_management.rb} +0 -0
- /data/lib/xclarity_client/{xclarity_management_mixin.rb → services/xclarity_management_mixin.rb} +0 -0
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
module XClarityClient
|
4
|
+
class ConfigPatternManagement < Services::XClarityService
|
5
|
+
manages_endpoint ConfigPattern
|
6
|
+
|
7
|
+
def population(opts = {})
|
8
|
+
fetch_all(opts)
|
9
|
+
end
|
10
|
+
|
11
|
+
def export(id)
|
12
|
+
response = @connection.do_get(managed_resource::BASE_URI + "/" + id + "/includeSettings" )
|
13
|
+
return [] unless response.success?
|
14
|
+
|
15
|
+
body = JSON.parse(response.body)
|
16
|
+
|
17
|
+
body = {managed_resource::LIST_NAME => body} if body.is_a? Array
|
18
|
+
body = {managed_resource::LIST_NAME => [body]} unless body.has_key? managed_resource::LIST_NAME
|
19
|
+
body[managed_resource::LIST_NAME].map do |resource_params|
|
20
|
+
managed_resource.new resource_params
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def deploy_config_pattern(id,endpoints,restart,etype)
|
25
|
+
if etype.eql? 'node'
|
26
|
+
deployHash = {:uuid => endpoints}
|
27
|
+
elsif etype.eql? 'rack' or etype.eql? 'tower'
|
28
|
+
deployHash = {:endpointIds => endpoints}
|
29
|
+
end
|
30
|
+
deployHash.merge!({:restart => restart})
|
31
|
+
response = @connection.do_post(managed_resource::BASE_URI + '/' +id, JSON.generate(deployHash))
|
32
|
+
response
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
def import_config_pattern(config_pattern)
|
37
|
+
response = @connection.do_post(managed_resource::BASE_URI, config_pattern)
|
38
|
+
response
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
data/lib/xclarity_client/{config_profile_management.rb → services/config_profile_management.rb}
RENAMED
@@ -1,41 +1,35 @@
|
|
1
1
|
require 'json'
|
2
2
|
|
3
3
|
module XClarityClient
|
4
|
-
class ConfigProfileManagement <
|
4
|
+
class ConfigProfileManagement < Services::XClarityService
|
5
|
+
manages_endpoint ConfigProfile
|
5
6
|
|
6
|
-
|
7
|
-
|
8
|
-
def initialize(conf)
|
9
|
-
super(conf, ConfigProfile::BASE_URI)
|
10
|
-
end
|
11
|
-
|
12
|
-
def population()
|
13
|
-
get_all_resources(ConfigProfile)
|
7
|
+
def population(opts = {})
|
8
|
+
fetch_all(opts)
|
14
9
|
end
|
15
10
|
|
16
11
|
def rename_config_profile(id='', name='')
|
17
12
|
renameReq = JSON.generate(profileName: name)
|
18
|
-
response = do_put(
|
13
|
+
response = @connection.do_put(managed_resource::BASE_URI + '/' +id, renameReq)
|
19
14
|
response
|
20
15
|
end
|
21
16
|
|
22
17
|
def activate_config_profile(id='', endpoint_uuid='', restart='')
|
23
18
|
postReq = JSON.generate(restart: restart, uuid: endpoint_uuid)
|
24
|
-
response = do_post(
|
19
|
+
response = @connection.do_post(managed_resource::BASE_URI + '/' +id, postReq)
|
25
20
|
response
|
26
21
|
end
|
27
22
|
|
28
23
|
def unassign_config_profile(id='', force='',powerDown='',resetImm='')
|
29
24
|
unassignReq = JSON.generate(force: force, powerDownITE: powerDown, resetIMM: resetImm)
|
30
|
-
response = do_post(
|
25
|
+
response = @connection.do_post(managed_resource::BASE_URI + '/unassign/' +id, unassignReq)
|
31
26
|
response
|
32
27
|
end
|
33
28
|
|
34
29
|
def delete_config_profile(id='')
|
35
|
-
response = do_delete(
|
30
|
+
response = @connection.do_delete(managed_resource::BASE_URI + '/' + id)
|
36
31
|
response
|
37
32
|
end
|
38
|
-
|
39
33
|
end
|
40
34
|
end
|
41
35
|
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
module XClarityClient
|
4
|
+
class DiscoverRequestManagement < Services::XClarityService
|
5
|
+
manages_endpoint DiscoverRequest
|
6
|
+
|
7
|
+
def population(opts = {})
|
8
|
+
fetch_all(opts)
|
9
|
+
end
|
10
|
+
|
11
|
+
def discover_manageable_devices(ip_addresses)
|
12
|
+
post_req = JSON.generate([ipAddresses: ip_addresses])
|
13
|
+
response = @connection.do_post(managed_resource::BASE_URI, post_req)
|
14
|
+
response
|
15
|
+
end
|
16
|
+
|
17
|
+
def monitor_discover_request(job_id)
|
18
|
+
response = @connection.do_get(managed_resource::BASE_URI + "/jobs/" + job_id)
|
19
|
+
return [] unless response.success?
|
20
|
+
|
21
|
+
body = JSON.parse(response.body)
|
22
|
+
|
23
|
+
body = {managed_resource::LIST_NAME => body} if body.is_a? Array
|
24
|
+
body = {managed_resource::LIST_NAME => [body]} unless body.has_key? managed_resource::LIST_NAME
|
25
|
+
body[managed_resource::LIST_NAME].map do |resource_params|
|
26
|
+
managed_resource.new resource_params
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'pathname'
|
3
|
+
|
4
|
+
module XClarityClient
|
5
|
+
class GlobalSettingManagement < XClarityBase
|
6
|
+
|
7
|
+
include XClarityClient::ManagementMixin
|
8
|
+
|
9
|
+
def initialize(conf)
|
10
|
+
super(conf, GlobalSetting::BASE_URI)
|
11
|
+
end
|
12
|
+
|
13
|
+
def population
|
14
|
+
response = connection("#{GlobalSetting::BASE_URI}")
|
15
|
+
response = JSON.parse(response.body)
|
16
|
+
end
|
17
|
+
|
18
|
+
def set_globalsettings(opts={})
|
19
|
+
request_body = JSON.generate(opts)
|
20
|
+
if Schemas.validate_input("set_globalsettings", request_body)
|
21
|
+
response = do_put("#{GlobalSetting::BASE_URI}", request_body)
|
22
|
+
response = JSON.parse(response.body)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'pathname'
|
3
|
+
|
4
|
+
module XClarityClient
|
5
|
+
class HostPlatformManagement < XClarityBase
|
6
|
+
|
7
|
+
include XClarityClient::ManagementMixin
|
8
|
+
|
9
|
+
def initialize(conf)
|
10
|
+
super(conf, HostPlatform::BASE_URI)
|
11
|
+
end
|
12
|
+
|
13
|
+
def population
|
14
|
+
get_all_resources(HostPlatform)
|
15
|
+
end
|
16
|
+
|
17
|
+
def get_osimage_deployment_status(uuid)
|
18
|
+
if Schemas.validate_input_parameter("uuid", uuid, String)
|
19
|
+
response = connection("#{HostPlatform::BASE_URI}/#{uuid}")
|
20
|
+
response = JSON.parse(response.body)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def deploy_osimage(opts=[])
|
25
|
+
request_body = JSON.generate(opts)
|
26
|
+
if Schemas.validate_input("deploy_osimage", request_body)
|
27
|
+
response = do_put("#{HostPlatform::BASE_URI}", request_body)
|
28
|
+
response = JSON.parse(response.body)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
module XClarityClient
|
4
|
+
class JobManagement < Services::XClarityService
|
5
|
+
manages_endpoint Job
|
6
|
+
|
7
|
+
def population(opts = {})
|
8
|
+
fetch_all(opts)
|
9
|
+
end
|
10
|
+
|
11
|
+
def cancel_job(uuid='')
|
12
|
+
cancelReq = JSON.generate(cancelRequest: 'true')
|
13
|
+
response = @connection.do_put(managed_resource::BASE_URI + '/' + uuid, cancelReq)
|
14
|
+
response
|
15
|
+
end
|
16
|
+
|
17
|
+
def delete_job(uuid='')
|
18
|
+
response = @connection.do_delete(managed_resource::BASE_URI + '/' + uuid)
|
19
|
+
response
|
20
|
+
end
|
21
|
+
|
22
|
+
def get_job(job_id = "")
|
23
|
+
response = connection(Job::BASE_URI + '/' + job_id)
|
24
|
+
response = JSON.parse(response.body)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'xclarity_client/endpoints/xclarity_endpoint'
|
2
|
+
|
3
|
+
module XClarityClient
|
4
|
+
module Services
|
5
|
+
#
|
6
|
+
# An Endpoint Manager must regist what endpoint it is managing
|
7
|
+
# to do that, just need to call #manages_endpoint method and
|
8
|
+
# pass as param the class that represents the endpoint (must be
|
9
|
+
# a subclass of XClarityEndpoint).
|
10
|
+
#
|
11
|
+
# @see XClarityClient::Endpoints::XClarityEndpoint
|
12
|
+
#
|
13
|
+
module EndpointManagerMixin
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
#
|
18
|
+
# Sets which endpoint is managed by the service
|
19
|
+
#
|
20
|
+
# @param [Class] - Class that represents some endpoind
|
21
|
+
# @see XClarityClient::Endpoints::XClarityEndpoint
|
22
|
+
#
|
23
|
+
def manages_endpoint(endpoint_class)
|
24
|
+
raise ArgumentError, "The class #{endpoint_class.name} isn't a subclass of XClarityEndpoint" unless endpoint_class < Endpoints::XclarityEndpoint
|
25
|
+
|
26
|
+
define_method(:managed_resource) { endpoint_class }
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
module XClarityClient
|
2
|
+
module Services
|
3
|
+
#
|
4
|
+
# A list name interpreter knows how to get the correct
|
5
|
+
# list name present on endpoint response, and, if the list
|
6
|
+
# doesn't exist, add the list property to the reponse with
|
7
|
+
# the right name.
|
8
|
+
#
|
9
|
+
module ListNameInterpreterMixin
|
10
|
+
#
|
11
|
+
# Process the response body to make sure that its contains the list name defined on resource
|
12
|
+
#
|
13
|
+
# @return the list name present on body and the body itself
|
14
|
+
#
|
15
|
+
def add_listname_on_body(endpoint_class, body)
|
16
|
+
body.kind_of?(Array) ? process_body_as_array(endpoint_class, body) : process_body_as_hash(endpoint_class, body)
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
#
|
22
|
+
# @return any listname described on resource
|
23
|
+
#
|
24
|
+
def any_listname_of(endpoint_class)
|
25
|
+
if endpoint_class::LIST_NAME.kind_of?(Array)
|
26
|
+
endpoint_class::LIST_NAME.first # If is an array, any listname can be use
|
27
|
+
else
|
28
|
+
endpoint_class::LIST_NAME # If is not an array, just return the listname of resource
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
#
|
33
|
+
# @return the body value assigned to the list name defined on resource
|
34
|
+
#
|
35
|
+
def process_body_as_array(endpoint_class, body)
|
36
|
+
list_name = any_listname_of(endpoint_class)
|
37
|
+
|
38
|
+
return list_name, { list_name => body } # assign the list name to the body
|
39
|
+
end
|
40
|
+
|
41
|
+
#
|
42
|
+
# Discover what list name defined on resource is present on body
|
43
|
+
# If none of then is find assume that the body is a single resource
|
44
|
+
# and add it value into array and assing to any list name
|
45
|
+
#
|
46
|
+
# @return the list name present on body and the body itself
|
47
|
+
#
|
48
|
+
def process_body_as_hash(endpoint_class, body)
|
49
|
+
result = body
|
50
|
+
|
51
|
+
if endpoint_class::LIST_NAME.kind_of? Array # search which list name is present on body
|
52
|
+
list_name = endpoint_class::LIST_NAME.find { |name| body.keys.include?(name) && body[name].kind_of?(Array) }
|
53
|
+
else
|
54
|
+
list_name = any_listname_of(endpoint_class)
|
55
|
+
end
|
56
|
+
result = {list_name => [body]} unless body.has_key? list_name # for the cases where body represents a single resource
|
57
|
+
return list_name, result
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'xclarity_client/services/mixins/list_name_interpreter_mixin'
|
2
|
+
|
3
|
+
module XClarityClient
|
4
|
+
module Services
|
5
|
+
#
|
6
|
+
# A response builder knows how to treat a response from LXCA
|
7
|
+
# and create a ruby response
|
8
|
+
#
|
9
|
+
module ResponseBuilderMixin
|
10
|
+
include ListNameInterpreterMixin
|
11
|
+
|
12
|
+
#
|
13
|
+
# Builds an array from an LXCA response that contains
|
14
|
+
# a list of resources.
|
15
|
+
#
|
16
|
+
# @param response - the LXCA response
|
17
|
+
# @param endpoint_class - the class that represents the endpoint that generates the response
|
18
|
+
#
|
19
|
+
# @return [Array] containing the resources of the LXCA response
|
20
|
+
#
|
21
|
+
def build_response_with_resource_list(response, endpoint_class)
|
22
|
+
return [] unless response.success?
|
23
|
+
|
24
|
+
body = JSON.parse(response.body)
|
25
|
+
|
26
|
+
if endpoint_class == XClarityClient::User
|
27
|
+
body = body['response']
|
28
|
+
end
|
29
|
+
|
30
|
+
list_name, body = add_listname_on_body(endpoint_class, body)
|
31
|
+
|
32
|
+
body[list_name].map do |resource_params|
|
33
|
+
endpoint_class.new resource_params
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -4,15 +4,11 @@ require 'uuid'
|
|
4
4
|
# XClarityClient module/namespace
|
5
5
|
module XClarityClient
|
6
6
|
# Node Management class
|
7
|
-
class NodeManagement <
|
8
|
-
|
9
|
-
|
10
|
-
def initialize(conf)
|
11
|
-
super(conf, Node::BASE_URI)
|
12
|
-
end
|
7
|
+
class NodeManagement < Services::XClarityService
|
8
|
+
manages_endpoint Node
|
13
9
|
|
14
10
|
def population(opts = {})
|
15
|
-
|
11
|
+
fetch_all(opts)
|
16
12
|
end
|
17
13
|
|
18
14
|
def set_node_power_state(uuid, requested_state = nil)
|
@@ -23,7 +19,7 @@ module XClarityClient
|
|
23
19
|
raise ArgumentError, error
|
24
20
|
end
|
25
21
|
|
26
|
-
send_power_request(
|
22
|
+
send_power_request(managed_resource::BASE_URI + '/' + uuid, requested_state)
|
27
23
|
end
|
28
24
|
|
29
25
|
def set_bmc_power_state(uuid, requested_state = nil)
|
@@ -34,7 +30,7 @@ module XClarityClient
|
|
34
30
|
raise ArgumentError, error
|
35
31
|
end
|
36
32
|
|
37
|
-
send_power_request(
|
33
|
+
send_power_request(managed_resource::BASE_URI + '/' + uuid + '/bmc', requested_state)
|
38
34
|
end
|
39
35
|
|
40
36
|
def set_loc_led_state(uuid, state, name = 'Identify')
|
@@ -42,14 +38,14 @@ module XClarityClient
|
|
42
38
|
|
43
39
|
$lxca_log.info "XclarityClient::ManagementMixin set_loc_led_state", "Loc led state action has been sent"
|
44
40
|
|
45
|
-
do_put("#{
|
41
|
+
@connection.do_put("#{managed_resource::BASE_URI}/#{uuid}", request)
|
46
42
|
end
|
47
43
|
|
48
44
|
private
|
49
45
|
|
50
46
|
def send_power_request(uri, requested_state = nil)
|
51
47
|
power_request = JSON.generate(powerState: requested_state)
|
52
|
-
response = do_put(uri, power_request)
|
48
|
+
response = @connection.do_put(uri, power_request)
|
53
49
|
msg = "Power state action has been sent with request #{power_request}"
|
54
50
|
|
55
51
|
$lxca_log.info 'XclarityClient::NodeManagement set_node_power_state', msg
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'pathname'
|
3
|
+
|
4
|
+
module XClarityClient
|
5
|
+
class OsImageManagement < XClarityBase
|
6
|
+
|
7
|
+
include XClarityClient::ManagementMixin
|
8
|
+
|
9
|
+
def initialize(conf)
|
10
|
+
super(conf, OsImage::BASE_URI)
|
11
|
+
end
|
12
|
+
|
13
|
+
def population
|
14
|
+
get_all_resources(OsImage)
|
15
|
+
end
|
16
|
+
|
17
|
+
def import_osimage(serverId, path)
|
18
|
+
if not Schemas.validate_input_parameter("serverId", serverId, String)
|
19
|
+
return
|
20
|
+
end
|
21
|
+
|
22
|
+
if not Schemas.validate_input_parameter("path", path, String)
|
23
|
+
return
|
24
|
+
end
|
25
|
+
|
26
|
+
msg="inputs serverId=#{serverId},path=#{path}"
|
27
|
+
$lxca_log.info self.class.to_s+" "+__method__.to_s, msg
|
28
|
+
opts = { "Action": "Init" }
|
29
|
+
request_body = JSON.generate(opts)
|
30
|
+
response = do_post("#{OsImage::BASE_URI}?imageType=OS", request_body)
|
31
|
+
response = JSON.load(response.body).to_hash
|
32
|
+
jobId = response["jobId"]
|
33
|
+
puts jobId
|
34
|
+
opts = { "serverId": serverId, "path": path }
|
35
|
+
request_body = JSON.generate(opts)
|
36
|
+
imageName = path.split(File::SEPARATOR).last
|
37
|
+
begin
|
38
|
+
response = do_post("#{OsImage::BASE_URI}/?jobId=#{jobId}"\
|
39
|
+
"&imageType=OS&imageName=#{imageName}", request_body)
|
40
|
+
response = JSON.parse(response.body)
|
41
|
+
rescue Faraday::TimeoutError => e
|
42
|
+
result = JSON.generate({"result": " Job for importing image is in progress with jobId #{jobId}"})
|
43
|
+
response = JSON.parse(result)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
module XClarityClient
|
4
|
+
class RemoteAccessManagement < XClarityBase
|
5
|
+
|
6
|
+
def initialize(conf)
|
7
|
+
super(conf, RemoteAccess::BASE_URI)
|
8
|
+
end
|
9
|
+
|
10
|
+
def remote_control(uuid)
|
11
|
+
raise 'UUID must not be blank' if uuid.nil? || uuid.empty?
|
12
|
+
con = connection("#{RemoteAccess::BASE_URI}/remoteControl" , {:uuid => uuid})
|
13
|
+
|
14
|
+
unless con.success?
|
15
|
+
$lxca_log.error "XClarityClient::RemoteAccessManagement remote_control", "Request failed"
|
16
|
+
raise 'Request failed'
|
17
|
+
end
|
18
|
+
|
19
|
+
build_remote_access_object(con)
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
SUPPORTED_MIME_TYPES = ['application/*json', 'application/x-java-jnlp-file']
|
25
|
+
|
26
|
+
def build_remote_access_object(connection)
|
27
|
+
content_type = connection.headers['Content-Type']
|
28
|
+
case content_type
|
29
|
+
when /application\/.*json/
|
30
|
+
build_json_remote_access_object(connection.body)
|
31
|
+
when /application\/x-java-jnlp-file/
|
32
|
+
build_jnlp_remote_access_object(connection.body)
|
33
|
+
else
|
34
|
+
$lxca_log.error(
|
35
|
+
"XClarityClient::RemoteAccessManagement build_remote_access_object",
|
36
|
+
"Unexpected server response. Expected Content-Type header to be one of these: #{SUPPORTED_MIME_TYPES}."
|
37
|
+
)
|
38
|
+
raise 'Unexpected Content-Type header'
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def build_json_remote_access_object(resp_body)
|
43
|
+
parsed_response = JSON.parse(resp_body)
|
44
|
+
RemoteAccess.new({
|
45
|
+
:type => :url,
|
46
|
+
:resource => parsed_response['url']
|
47
|
+
})
|
48
|
+
end
|
49
|
+
|
50
|
+
def build_jnlp_remote_access_object(resp_body)
|
51
|
+
RemoteAccess.new({
|
52
|
+
:type => :java_jnlp_file,
|
53
|
+
:resource => resp_body
|
54
|
+
})
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
module XClarityClient
|
4
|
+
class RemoteFileServerManagement < XClarityBase
|
5
|
+
|
6
|
+
include XClarityClient::ManagementMixin
|
7
|
+
|
8
|
+
def initialize(conf)
|
9
|
+
super(conf, RemoteFileServer::BASE_URI)
|
10
|
+
end
|
11
|
+
|
12
|
+
def population
|
13
|
+
get_all_resources(RemoteFileServer)
|
14
|
+
end
|
15
|
+
|
16
|
+
def create_remotefileserver_profile(opts)
|
17
|
+
request_body = JSON.generate(opts)
|
18
|
+
if Schemas.validate_input("create_remotefileserver_profile", request_body)
|
19
|
+
response = do_post(RemoteFileServer::BASE_URI, request_body)
|
20
|
+
msg = "remote file server profile created #{response.body}"
|
21
|
+
$lxca_log.info self.class.to_s+" "+__method__.to_s, msg
|
22
|
+
response = JSON.parse(response.body)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def delete_remotefileserver_profile(serverId)
|
27
|
+
if not Schemas.validate_input_parameter("serverId", serverId, String)
|
28
|
+
return
|
29
|
+
end
|
30
|
+
response = do_delete("#{RemoteFileServer::BASE_URI}/#{serverId}")
|
31
|
+
response = JSON.parse(response.body)
|
32
|
+
end
|
33
|
+
|
34
|
+
def get_remotefileserver_profile(serverId)
|
35
|
+
if Schemas.validate_input_parameter("serverId", serverId, String)
|
36
|
+
response = connection("#{RemoteFileServer::BASE_URI}/#{serverId}")
|
37
|
+
response = JSON.parse(response.body)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|