xclarity_client 0.6.0 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. checksums.yaml +4 -4
  2. data/.codeclimate.yml +41 -0
  3. data/.rubocop_base.yml +211 -0
  4. data/.rubocop_cc.yml +2 -0
  5. data/.travis.yml +1 -1
  6. data/docs/apib/compliance_policies.apib +214 -0
  7. data/docs/apib/squisher.rb +21 -13
  8. data/docs/apib/storages.apib +481 -0
  9. data/docs/apib/switches.apib +4 -0
  10. data/lib/xclarity_client.rb +3 -4
  11. data/lib/xclarity_client/client.rb +37 -343
  12. data/lib/xclarity_client/connection/connection.rb +3 -3
  13. data/lib/xclarity_client/endpoints/compliance_policy.rb +19 -0
  14. data/lib/xclarity_client/endpoints/endpoints.rb +2 -0
  15. data/lib/xclarity_client/endpoints/node.rb +8 -0
  16. data/lib/xclarity_client/endpoints/storage.rb +18 -0
  17. data/lib/xclarity_client/endpoints/switch.rb +3 -0
  18. data/lib/xclarity_client/mixins/aicc_mixin.rb +10 -0
  19. data/lib/xclarity_client/mixins/cabinet_mixin.rb +20 -0
  20. data/lib/xclarity_client/mixins/canister_mixin.rb +20 -0
  21. data/lib/xclarity_client/mixins/chassi_mixin.rb +20 -0
  22. data/lib/xclarity_client/mixins/cmm_mixin.rb +20 -0
  23. data/lib/xclarity_client/mixins/compliance_policy_mixin.rb +38 -0
  24. data/lib/xclarity_client/mixins/config_pattern_mixin.rb +40 -0
  25. data/lib/xclarity_client/mixins/config_profile_mixin.rb +51 -0
  26. data/lib/xclarity_client/mixins/config_target_mixin.rb +16 -0
  27. data/lib/xclarity_client/mixins/discover_request_mixin.rb +18 -0
  28. data/lib/xclarity_client/mixins/discovery_mixin.rb +10 -0
  29. data/lib/xclarity_client/mixins/event_mixin.rb +14 -0
  30. data/lib/xclarity_client/mixins/fan_mixin.rb +20 -0
  31. data/lib/xclarity_client/mixins/fan_mux_mixin.rb +20 -0
  32. data/lib/xclarity_client/mixins/ffdc_mixin.rb +16 -0
  33. data/lib/xclarity_client/mixins/global_setting_mixin.rb +14 -0
  34. data/lib/xclarity_client/mixins/host_platform_mixin.rb +18 -0
  35. data/lib/xclarity_client/mixins/job_mixin.rb +32 -0
  36. data/lib/xclarity_client/mixins/mixins.rb +38 -0
  37. data/lib/xclarity_client/mixins/node_mixin.rb +66 -0
  38. data/lib/xclarity_client/mixins/os_image_mixin.rb +14 -0
  39. data/lib/xclarity_client/mixins/persisted_result_mixin.rb +10 -0
  40. data/lib/xclarity_client/mixins/power_supply_mixin.rb +20 -0
  41. data/lib/xclarity_client/mixins/remote_access_mixin.rb +10 -0
  42. data/lib/xclarity_client/mixins/remote_file_server_mixin.rb +28 -0
  43. data/lib/xclarity_client/mixins/scalable_complex_mixin.rb +20 -0
  44. data/lib/xclarity_client/mixins/storage_mixin.rb +20 -0
  45. data/lib/xclarity_client/mixins/switch_mixin.rb +30 -0
  46. data/lib/xclarity_client/mixins/unmanage_request_mixin.rb +18 -0
  47. data/lib/xclarity_client/mixins/update_repo_mixin.rb +10 -0
  48. data/lib/xclarity_client/mixins/user_mixin.rb +26 -0
  49. data/lib/xclarity_client/schemas.rb +184 -189
  50. data/lib/xclarity_client/services/aicc_management.rb +0 -4
  51. data/lib/xclarity_client/services/cabinet_management.rb +0 -4
  52. data/lib/xclarity_client/services/canister_management.rb +0 -4
  53. data/lib/xclarity_client/services/chassi_management.rb +0 -4
  54. data/lib/xclarity_client/services/cmm_management.rb +0 -4
  55. data/lib/xclarity_client/services/compliance_policy_management.rb +52 -0
  56. data/lib/xclarity_client/services/config_pattern_management.rb +0 -4
  57. data/lib/xclarity_client/services/config_profile_management.rb +0 -4
  58. data/lib/xclarity_client/services/config_target_management.rb +0 -4
  59. data/lib/xclarity_client/services/discover_request_management.rb +0 -4
  60. data/lib/xclarity_client/services/discovery_management.rb +0 -4
  61. data/lib/xclarity_client/services/event_management.rb +0 -4
  62. data/lib/xclarity_client/services/fan_management.rb +0 -4
  63. data/lib/xclarity_client/services/fan_mux_management.rb +0 -4
  64. data/lib/xclarity_client/services/ffdc_management.rb +0 -4
  65. data/lib/xclarity_client/services/job_management.rb +0 -9
  66. data/lib/xclarity_client/services/mixins/power_action_sender_mixin.rb +59 -0
  67. data/lib/xclarity_client/services/node_management.rb +3 -26
  68. data/lib/xclarity_client/services/osimage_management.rb +25 -27
  69. data/lib/xclarity_client/services/persisted_result_management.rb +0 -6
  70. data/lib/xclarity_client/services/power_supply_management.rb +0 -4
  71. data/lib/xclarity_client/services/scalable_complex_management.rb +0 -4
  72. data/lib/xclarity_client/services/services.rb +6 -4
  73. data/lib/xclarity_client/services/storage_management.rb +8 -0
  74. data/lib/xclarity_client/services/switch_management.rb +4 -4
  75. data/lib/xclarity_client/services/unmanage_request_management.rb +0 -4
  76. data/lib/xclarity_client/services/update_repo_management.rb +30 -9
  77. data/lib/xclarity_client/services/user_management.rb +0 -4
  78. data/lib/xclarity_client/services/xclarity_service.rb +6 -5
  79. data/lib/xclarity_client/version.rb +1 -1
  80. data/xclarity_client.gemspec +1 -1
  81. metadata +45 -5
  82. data/lib/xclarity_client/xclarity_power_management_mixin.rb +0 -36
@@ -0,0 +1,32 @@
1
+ module XClarityClient
2
+ #
3
+ # Exposes JobManagement features
4
+ #
5
+ module Mixins::JobMixin
6
+ def discover_jobs(opts = {})
7
+ JobManagement.new(@config).fetch_all(opts)
8
+ end
9
+
10
+ def fetch_jobs(ids = nil,
11
+ include_attributes = nil,
12
+ exclude_attributes = nil)
13
+ JobManagement.new(@config).get_object_with_id(
14
+ ids,
15
+ include_attributes,
16
+ exclude_attributes
17
+ )
18
+ end
19
+
20
+ def cancel_job(id = '')
21
+ JobManagement.new(@config).cancel_job(id)
22
+ end
23
+
24
+ def delete_job(id = '')
25
+ JobManagement.new(@config).delete_job(id)
26
+ end
27
+
28
+ def get_job(job_id = '')
29
+ JobManagement.new(@config).get_job(job_id)
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,38 @@
1
+ module XClarityClient
2
+ #
3
+ # Contains mixins to provide XClarityClient::Client features
4
+ #
5
+ module Mixins
6
+ end
7
+ end
8
+
9
+ require 'xclarity_client/mixins/aicc_mixin'
10
+ require 'xclarity_client/mixins/cabinet_mixin'
11
+ require 'xclarity_client/mixins/canister_mixin'
12
+ require 'xclarity_client/mixins/chassi_mixin'
13
+ require 'xclarity_client/mixins/cmm_mixin'
14
+ require 'xclarity_client/mixins/compliance_policy_mixin'
15
+ require 'xclarity_client/mixins/config_pattern_mixin'
16
+ require 'xclarity_client/mixins/config_profile_mixin'
17
+ require 'xclarity_client/mixins/config_target_mixin'
18
+ require 'xclarity_client/mixins/discover_request_mixin'
19
+ require 'xclarity_client/mixins/discovery_mixin'
20
+ require 'xclarity_client/mixins/event_mixin'
21
+ require 'xclarity_client/mixins/fan_mixin'
22
+ require 'xclarity_client/mixins/fan_mux_mixin'
23
+ require 'xclarity_client/mixins/ffdc_mixin'
24
+ require 'xclarity_client/mixins/global_setting_mixin'
25
+ require 'xclarity_client/mixins/host_platform_mixin'
26
+ require 'xclarity_client/mixins/job_mixin'
27
+ require 'xclarity_client/mixins/node_mixin'
28
+ require 'xclarity_client/mixins/os_image_mixin'
29
+ require 'xclarity_client/mixins/persisted_result_mixin'
30
+ require 'xclarity_client/mixins/power_supply_mixin'
31
+ require 'xclarity_client/mixins/remote_access_mixin'
32
+ require 'xclarity_client/mixins/remote_file_server_mixin'
33
+ require 'xclarity_client/mixins/scalable_complex_mixin'
34
+ require 'xclarity_client/mixins/storage_mixin'
35
+ require 'xclarity_client/mixins/switch_mixin'
36
+ require 'xclarity_client/mixins/unmanage_request_mixin'
37
+ require 'xclarity_client/mixins/update_repo_mixin'
38
+ require 'xclarity_client/mixins/user_mixin'
@@ -0,0 +1,66 @@
1
+ module XClarityClient
2
+ #
3
+ # Exposes NodeManagement features
4
+ #
5
+ module Mixins::NodeMixin
6
+ def discover_nodes(opts = {})
7
+ node_management.fetch_all(opts)
8
+ end
9
+
10
+ def fetch_nodes(uuids = nil,
11
+ include_attributes = nil,
12
+ exclude_attributes = nil)
13
+ node_management.get_object(
14
+ uuids,
15
+ include_attributes,
16
+ exclude_attributes
17
+ )
18
+ end
19
+
20
+ def blink_loc_led(uuid = '')
21
+ node_management.set_loc_led_state(uuid, 'Blinking')
22
+ end
23
+
24
+ def turn_on_loc_led(uuid = '')
25
+ node_management.set_loc_led_state(uuid, 'On')
26
+ end
27
+
28
+ def turn_off_loc_led(uuid = '')
29
+ node_management.set_loc_led_state(uuid, 'Off')
30
+ end
31
+
32
+ def power_on_node(uuid = '')
33
+ node_management.set_power_state(uuid, :powerOn)
34
+ end
35
+
36
+ def power_off_node(uuid = '')
37
+ node_management.set_power_state(uuid, :powerOffSoftGraceful)
38
+ end
39
+
40
+ def power_off_node_now(uuid = '')
41
+ node_management.set_power_state(uuid, :powerOff)
42
+ end
43
+
44
+ def power_restart_node(uuid = '')
45
+ node_management.set_power_state(uuid, :powerCycleSoftGrace)
46
+ end
47
+
48
+ def power_restart_node_now(uuid = '')
49
+ node_management.set_power_state(uuid, :powerCycleSoft)
50
+ end
51
+
52
+ def power_restart_node_controller(uuid = '')
53
+ node_management.set_bmc_power_state(uuid, :restart)
54
+ end
55
+
56
+ def power_restart_node_to_setup(uuid = '')
57
+ node_management.set_power_state(uuid, :bootToF1)
58
+ end
59
+
60
+ private
61
+
62
+ def node_management
63
+ NodeManagement.new(@config)
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,14 @@
1
+ module XClarityClient
2
+ #
3
+ # Exposes OsImageManagement features
4
+ #
5
+ module Mixins::OsImageMixin
6
+ def import_osimage(server_id = '', path = '')
7
+ OsImageManagement.new(@config).import_osimage(server_id, path)
8
+ end
9
+
10
+ def get_osimages
11
+ OsImageManagement.new(@config).population
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,10 @@
1
+ module XClarityClient
2
+ #
3
+ # Exposes PersistedResultManagement features
4
+ #
5
+ module Mixins::PersistedResultMixin
6
+ def fetch_compliance_policies
7
+ PersistedResultManagement.new(@config).fetch_all
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,20 @@
1
+ module XClarityClient
2
+ #
3
+ # Exposes PowerSupplyManagement features
4
+ #
5
+ module Mixins::PowerSupplyMixin
6
+ def discover_power_supplies(opts = {})
7
+ PowerSupplyManagement.new(@config).fetch_all(opts)
8
+ end
9
+
10
+ def fetch_power_supplies(uuids = nil,
11
+ include_attributes = nil,
12
+ exclude_attributes = nil)
13
+ PowerSupplyManagement.new(@config).get_object(
14
+ uuids,
15
+ include_attributes,
16
+ exclude_attributes
17
+ )
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,10 @@
1
+ module XClarityClient
2
+ #
3
+ # Exposes RemoteAccessManagement features
4
+ #
5
+ module Mixins::RemoteAccessMixin
6
+ def remote_control(uuid)
7
+ RemoteAccessManagement.new(@config).remote_control(uuid)
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,28 @@
1
+ module XClarityClient
2
+ #
3
+ # Exposes RemoteFileServerManagement features
4
+ #
5
+ module Mixins::RemoteFileServerMixin
6
+ def get_remotefileserver_profiles
7
+ RemoteFileServerManagement.new(@config).population
8
+ end
9
+
10
+ def create_remotefileserver_profile(opts = {})
11
+ RemoteFileServerManagement.new(@config).create_remotefileserver_profile(
12
+ opts
13
+ )
14
+ end
15
+
16
+ def delete_remotefileserver_profile(server_id = '')
17
+ RemoteFileServerManagement.new(@config).delete_remotefileserver_profile(
18
+ server_id
19
+ )
20
+ end
21
+
22
+ def get_remotefileserver_profile(server_id = '')
23
+ RemoteFileServerManagement.new(@config).get_remotefileserver_profile(
24
+ server_id
25
+ )
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,20 @@
1
+ module XClarityClient
2
+ #
3
+ # Exposes ScalableComplexManagement features
4
+ #
5
+ module Mixins::ScalableComplexMixin
6
+ def discover_scalableComplexes(opts = {})
7
+ ScalableComplexManagement.new(@config).fetch_all(opts)
8
+ end
9
+
10
+ def fetch_scalableComplexes(uuids = nil,
11
+ include_attributes = nil,
12
+ exclude_attributes = nil)
13
+ ScalableComplexManagement.new(@config).get_object(
14
+ uuids,
15
+ include_attributes,
16
+ exclude_attributes
17
+ )
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,20 @@
1
+ module XClarityClient
2
+ #
3
+ # Exposes StorageManagement features
4
+ #
5
+ module Mixins::StorageMixin
6
+ def discover_storages(opts = {})
7
+ StorageManagement.new(@config).fetch_all(opts)
8
+ end
9
+
10
+ def fetch_storages(uuids = nil,
11
+ include_attributes = nil,
12
+ exclude_attributes = nil)
13
+ StorageManagement.new(@config).get_object(
14
+ uuids,
15
+ include_attributes,
16
+ exclude_attributes
17
+ )
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,30 @@
1
+ module XClarityClient
2
+ #
3
+ # Exposes SwitchManagement features
4
+ #
5
+ module Mixins::SwitchMixin
6
+ def discover_switches(opts = {})
7
+ switch_management.fetch_all(opts)
8
+ end
9
+
10
+ def fetch_switches(uuids = nil,
11
+ include_attributes = nil,
12
+ exclude_attributes = nil)
13
+ switch_management.get_object(
14
+ uuids,
15
+ include_attributes,
16
+ exclude_attributes
17
+ )
18
+ end
19
+
20
+ def power_cycle_soft_switch(uuid = '')
21
+ switch_management.set_power_state(uuid, :powerCycleSoft)
22
+ end
23
+
24
+ private
25
+
26
+ def switch_management
27
+ SwitchManagement.new(@config)
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,18 @@
1
+ module XClarityClient
2
+ #
3
+ # Exposes UnmanageRequestManagement features
4
+ #
5
+ module Mixins::UnmanageRequestMixin
6
+ def fetch_unmanage_request(job_id)
7
+ UnmanageRequestManagement.new(@config).fetch_unmanage_request(
8
+ job_id
9
+ )
10
+ end
11
+
12
+ def unmanage_discovered_devices(endpoints, force)
13
+ UnmanageRequestManagement.new(@config).unmanage_discovered_devices(
14
+ endpoints, force
15
+ )
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,10 @@
1
+ module XClarityClient
2
+ #
3
+ # Exposes UpdateRepoManagement features
4
+ #
5
+ module Mixins::UpdateRepoMixin
6
+ def discover_update_repo(opts = {})
7
+ UpdateRepoManagement.new(@config).fetch_all(opts)
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,26 @@
1
+ module XClarityClient
2
+ #
3
+ # Exposes UserManagement features
4
+ #
5
+ module Mixins::UserMixin
6
+ def discover_users(_opts = {})
7
+ UserManagement.new(@config).fetch_all
8
+ end
9
+
10
+ def fetch_users(ids = nil,
11
+ include_attributes = nil,
12
+ exclude_attributes = nil)
13
+ UserManagement.new(@config).get_object_with_id(
14
+ ids,
15
+ include_attributes,
16
+ exclude_attributes
17
+ )
18
+ end
19
+
20
+ def change_user_password(current_password, new_password)
21
+ UserManagement.new(@config).change_password(
22
+ current_password, new_password
23
+ )
24
+ end
25
+ end
26
+ end
@@ -2,198 +2,193 @@ require 'json-schema'
2
2
 
3
3
  module XClarityClient
4
4
  class Schemas
5
- @remotefs = {
6
- "id" => "create_remotefileserver_profile",
7
- "type" => "object",
8
- "required" => ["address", "displayName", "port", "protocol"],
9
- "properties" => {
10
- "address" => {
11
- "type" => "string"
12
- },
13
- "displayName" => {
14
- "type" => "string"
15
- },
16
- "keyComment" => {
17
- "type" => "string"
18
- },
19
- "keyPassphras" => {
20
- "type" => "string"
21
- },
22
- "keyType" => {
23
- "type" => "string"
24
- },
25
- "password" => {
26
- "type" => "string"
27
- },
28
- "port" => {
29
- "type" => "integer"
30
- },
31
- "protocol" => {
32
- "type" => "string"
33
- },
34
- "serverId" => {
35
- "type" => "string"
36
- },
37
- "username" => {
38
- "type" => "string"
39
- }
40
- }
41
- }
42
-
43
- @hostplatforms = {
44
- "id" => "deploy_osimage",
45
- "type" => "array",
46
- "items" => {
47
- "type" => "object",
48
- "required" => ["networkSettings", "selectedImage", "storageSettings", "uuid"],
49
- "properties" => {
50
- "adusername" => {
51
- "type" => "string"
52
- },
53
- "adpassword" => {
54
- "type" => "string"
55
- },
56
- "configFileId" => {
57
- "type" => "string"
58
- },
59
- "licenseKey" => {
60
- "type" => "string"
61
- },
62
- "selectedImage" => {
63
- "type" => "string"
64
- },
65
- "storageSettings" => {
66
- "type" => "object"
67
- },
68
- "unattendFileId" => {
69
- "type" => "string"
70
- },
71
- "uuid" => {
72
- "type" => "string"
73
- },
74
- "windowsDomain" => {
75
- "type" => "string"
76
- },
77
- "windowsDomainBlob" => {
78
- "type" => "string"
79
- },
80
- "networkSettings" => {
81
- "type" => "object",
82
- "properties" =>
83
- {
84
- "dns1" => {
85
- "type" => "string"
86
- },
87
- "dns2" => {
88
- "type" => "string"
89
- },
90
- "gateway" => {
91
- "type" => "string"
92
- },
93
- "hostname" => {
94
- "type" => "string"
95
- },
96
- "ipAddress" => {
97
- "type" => "string"
98
- },
99
- "mtu" => {
100
- "type" => "integer"
101
- },
102
- "prefixLength" => {
103
- "type" => "string"
104
- },
105
- "selectedMAC" => {
106
- "type" => "string"
107
- },
108
- "vlanId" => {
109
- "type" => "string"
110
- }
111
- }
112
- }
113
- }
114
- }
115
- }
5
+ @remotefs = {
6
+ "id" => "create_remotefileserver_profile",
7
+ "type" => "object",
8
+ "required" => %w(address displayName port protocol),
9
+ "properties" => {
10
+ "address" => {
11
+ "type" => "string"
12
+ },
13
+ "displayName" => {
14
+ "type" => "string"
15
+ },
16
+ "keyComment" => {
17
+ "type" => "string"
18
+ },
19
+ "keyPassphras" => {
20
+ "type" => "string"
21
+ },
22
+ "keyType" => {
23
+ "type" => "string"
24
+ },
25
+ "password" => {
26
+ "type" => "string"
27
+ },
28
+ "port" => {
29
+ "type" => "integer"
30
+ },
31
+ "protocol" => {
32
+ "type" => "string"
33
+ },
34
+ "serverId" => {
35
+ "type" => "string"
36
+ },
37
+ "username" => {
38
+ "type" => "string"
39
+ }
40
+ }
41
+ }
116
42
 
117
- @globalsettings = {
118
- "id" => "set_globalsettings",
119
- "type" => "object",
120
- "required" => ["activeDirectory", "ipAssignment", "isVLANMode", "licenseKeys", "credentials"],
121
- "properties" => {
122
- "activeDirectory": {
123
- "type" => "object"
124
- },
125
- "ipAssignment":{
126
- "type" => "string"
127
- },
128
- "isVLANMode": {
129
- "type" => "boolean"
130
- },
131
- "licenseKeys":{
132
- "type" => "object"
133
- },
134
- "deploySettings":{
135
- "type" => "string"
136
- },
137
- "credentials":{
138
- "type" => "array",
139
- "items" => {
140
- "type" => "object",
141
- "required" => ["type",
142
- "name",
143
- "password",
144
- "passwordChanged"],
145
- "properties" =>
146
- {
147
- "type":{
148
- "type"=> "string"
149
- },
150
- "name":{
151
- "type" => "string"
152
- },
153
- "password":{
154
- "type" => "string"
155
- },
156
- "passwordChanged":{
157
- "type" => "boolean"
158
- }
159
- }
160
- }
161
- }
162
- }
163
- }
43
+ @hostplatforms = {
44
+ "id" => "deploy_osimage",
45
+ "type" => "array",
46
+ "items" => {
47
+ "type" => "object",
48
+ "required" => %w(networkSettings selectedImage storageSettings uuid),
49
+ "properties" => {
50
+ "adusername" => {
51
+ "type" => "string"
52
+ },
53
+ "adpassword" => {
54
+ "type" => "string"
55
+ },
56
+ "configFileId" => {
57
+ "type" => "string"
58
+ },
59
+ "licenseKey" => {
60
+ "type" => "string"
61
+ },
62
+ "selectedImage" => {
63
+ "type" => "string"
64
+ },
65
+ "storageSettings" => {
66
+ "type" => "object"
67
+ },
68
+ "unattendFileId" => {
69
+ "type" => "string"
70
+ },
71
+ "uuid" => {
72
+ "type" => "string"
73
+ },
74
+ "windowsDomain" => {
75
+ "type" => "string"
76
+ },
77
+ "windowsDomainBlob" => {
78
+ "type" => "string"
79
+ },
80
+ "networkSettings" => {
81
+ "type" => "object",
82
+ "properties" => {
83
+ "dns1" => {
84
+ "type" => "string"
85
+ },
86
+ "dns2" => {
87
+ "type" => "string"
88
+ },
89
+ "gateway" => {
90
+ "type" => "string"
91
+ },
92
+ "hostname" => {
93
+ "type" => "string"
94
+ },
95
+ "ipAddress" => {
96
+ "type" => "string"
97
+ },
98
+ "mtu" => {
99
+ "type" => "integer"
100
+ },
101
+ "prefixLength" => {
102
+ "type" => "string"
103
+ },
104
+ "selectedMAC" => {
105
+ "type" => "string"
106
+ },
107
+ "vlanId" => {
108
+ "type" => "string"
109
+ }
110
+ }
111
+ }
112
+ }
113
+ }
114
+ }
164
115
 
165
- REQ_SCHEMA={
166
- "deploy_osimage" => @hostplatforms,
167
- "set_globalsettings" => @globalsettings,
168
- "create_remotefileserver_profile" => @remotefs
169
- }
116
+ @globalsettings = {
117
+ "id" => "set_globalsettings",
118
+ "type" => "object",
119
+ "required" => %w(activeDirectory
120
+ ipAssignment
121
+ isVLANMode
122
+ licenseKeys
123
+ credentials),
124
+ "properties" => {
125
+ "activeDirectory" => {
126
+ "type" => "object"
127
+ },
128
+ "ipAssignment" => {
129
+ "type" => "string"
130
+ },
131
+ "isVLANMode" => {
132
+ "type" => "boolean"
133
+ },
134
+ "licenseKeys" => {
135
+ "type" => "object"
136
+ },
137
+ "deploySettings" => {
138
+ "type" => "string"
139
+ },
140
+ "credentials" => {
141
+ "type" => "array",
142
+ "items" => {
143
+ "type" => "object",
144
+ "required" => %w(type name password passwordChanged),
145
+ "properties" => {
146
+ "type" => {
147
+ "type" => "string"
148
+ },
149
+ "name" => {
150
+ "type" => "string"
151
+ },
152
+ "password" => {
153
+ "type" => "string"
154
+ },
155
+ "passwordChanged" => {
156
+ "type" => "boolean"
157
+ }
158
+ }
159
+ }
160
+ }
161
+ }
162
+ }
170
163
 
171
- def Schemas.validate_input(schema_name, data)
172
- x=JSON::Validator.fully_validate(Schemas::REQ_SCHEMA[schema_name], data)
173
- if not x.empty?
174
- errmsg = "input validation failed for data #{data}"
175
- $lxca_log.error errmsg, ""
176
- puts errmsg
177
- for k in x
178
- $lxca_log.error k, ""
179
- puts k
180
- end
181
- return nil
182
- else
183
- return 1
184
- end
185
- end
164
+ REQ_SCHEMA = {
165
+ 'deploy_osimage' => @hostplatforms,
166
+ 'set_globalsettings' => @globalsettings,
167
+ 'create_remotefileserver_profile' => @remotefs
168
+ }.freeze
186
169
 
187
- #parameter name should be string
188
- def Schemas.validate_input_parameter(name, value, exp_type)
189
- if not value.kind_of?(exp_type)
190
- errmsg = "invalid #{name} #{value}, expected #{name} of type #{exp_type}"
191
- $lxca_log.error errmsg, ""
192
- puts errmsg
193
- return nil
194
- else
195
- return 1
196
- end
197
- end
170
+ def self.validate_input(schema_name, data)
171
+ x = JSON::Validator.fully_validate(Schemas::REQ_SCHEMA[schema_name], data)
172
+ if !x.empty?
173
+ errmsg = "input validation failed for data #{data}"
174
+ $lxca_log.error(errmsg, '')
175
+ x.each { |k| $lxca_log.error(k, '') }
176
+ return nil
177
+ else
178
+ return 1
179
+ end
180
+ end
181
+
182
+ # parameter name should be string
183
+ def self.validate_input_parameter(name, value, exp_type)
184
+ if !value.kind_of?(exp_type)
185
+ errmsg = "invalid #{name} #{value},"\
186
+ " expected #{name} of type #{exp_type}"
187
+ $lxca_log.error(errmsg, '')
188
+ return nil
189
+ else
190
+ return 1
191
+ end
192
+ end
198
193
  end
199
194
  end