xclarity_client 0.6.2 → 0.6.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/docs/apib/event.apib +11 -0
- data/docs/apib/update_repo.apib +56 -0
- data/lib/xclarity_client/configuration.rb +43 -19
- data/lib/xclarity_client/connection/connection.rb +45 -37
- data/lib/xclarity_client/endpoints/buildable_resource_mixin.rb +6 -1
- data/lib/xclarity_client/endpoints/globalsettings.rb +0 -5
- data/lib/xclarity_client/endpoints/hostplatform.rb +0 -4
- data/lib/xclarity_client/endpoints/osimage.rb +0 -4
- data/lib/xclarity_client/endpoints/remotefileserver.rb +0 -4
- data/lib/xclarity_client/mixins/event_mixin.rb +6 -0
- data/lib/xclarity_client/mixins/global_setting_mixin.rb +1 -1
- data/lib/xclarity_client/mixins/host_platform_mixin.rb +1 -1
- data/lib/xclarity_client/mixins/os_image_mixin.rb +1 -1
- data/lib/xclarity_client/mixins/remote_file_server_mixin.rb +1 -1
- data/lib/xclarity_client/mixins/update_repo_mixin.rb +23 -0
- data/lib/xclarity_client/schemas.rb +183 -194
- data/lib/xclarity_client/services/compliance_policy_management.rb +4 -6
- data/lib/xclarity_client/services/globalsettings_management.rb +8 -15
- data/lib/xclarity_client/services/hostplatform_management.rb +9 -18
- data/lib/xclarity_client/services/osimage_management.rb +12 -24
- data/lib/xclarity_client/services/remotefileserver_management.rb +13 -25
- data/lib/xclarity_client/services/update_repo_management.rb +58 -0
- data/lib/xclarity_client/services/xclarity_service.rb +27 -32
- data/lib/xclarity_client/version.rb +1 -1
- data/xclarity_client.gemspec +1 -0
- metadata +16 -2
@@ -1,194 +1,183 @@
|
|
1
|
-
require 'json-schema'
|
2
|
-
|
3
|
-
module XClarityClient
|
4
|
-
class Schemas
|
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
|
-
}
|
42
|
-
|
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" => "
|
103
|
-
},
|
104
|
-
"selectedMAC" => {
|
105
|
-
"type" => "string"
|
106
|
-
},
|
107
|
-
"vlanId" => {
|
108
|
-
"type" => "
|
109
|
-
}
|
110
|
-
}
|
111
|
-
}
|
112
|
-
}
|
113
|
-
}
|
114
|
-
}
|
115
|
-
|
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
|
-
}
|
163
|
-
|
164
|
-
REQ_SCHEMA = {
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
}.freeze
|
169
|
-
|
170
|
-
def self.validate_input(schema_name, data)
|
171
|
-
x = JSON::Validator.fully_validate(
|
172
|
-
|
173
|
-
errmsg = "input validation failed for data #{data}"
|
174
|
-
$lxca_log.error(
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
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
|
193
|
-
end
|
194
|
-
end
|
1
|
+
require 'json-schema'
|
2
|
+
|
3
|
+
module XClarityClient
|
4
|
+
class Schemas
|
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
|
+
}
|
42
|
+
|
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" => "integer"
|
103
|
+
},
|
104
|
+
"selectedMAC" => {
|
105
|
+
"type" => "string"
|
106
|
+
},
|
107
|
+
"vlanId" => {
|
108
|
+
"type" => "integer"
|
109
|
+
}
|
110
|
+
}
|
111
|
+
}
|
112
|
+
}
|
113
|
+
}
|
114
|
+
}
|
115
|
+
|
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
|
+
}
|
163
|
+
|
164
|
+
REQ_SCHEMA = {
|
165
|
+
:deploy_osimage => @hostplatforms,
|
166
|
+
:set_globalsettings => @globalsettings,
|
167
|
+
:create_remotefileserver_profile => @remotefs
|
168
|
+
}.freeze
|
169
|
+
|
170
|
+
def self.validate_input(schema_name, data)
|
171
|
+
x = JSON::Validator.fully_validate(self::REQ_SCHEMA[schema_name], data)
|
172
|
+
unless x.empty?
|
173
|
+
errmsg = "input validation failed for data #{data}"
|
174
|
+
$lxca_log.error('XClarityClient::Schemas validate_input', errmsg.to_s)
|
175
|
+
g = ''
|
176
|
+
x.each do |k|
|
177
|
+
$lxca_log.error('XClarityClient::Schemas validate_input', k)
|
178
|
+
g << "#{k}, "
|
179
|
+
end; return { :result => 'Input validation failed', :message => g }
|
180
|
+
end; return { :result => 'success' }
|
181
|
+
end
|
182
|
+
end
|
183
|
+
end
|
@@ -17,10 +17,8 @@ module XClarityClient
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def get_update_policy(uri, opts = {})
|
20
|
-
|
21
|
-
|
22
|
-
build_response_with_resource_list(response, managed_resource)
|
23
|
-
end
|
20
|
+
fetch_all(opts, uri)
|
21
|
+
end
|
24
22
|
|
25
23
|
def assign_compliance_policy(opts = {}, keep, auto_assign)
|
26
24
|
assign_hash = {:policyname => opts["policyname"], :type => opts["type"], :uuid => opts["uuid"]}
|
@@ -37,14 +35,14 @@ module XClarityClient
|
|
37
35
|
|
38
36
|
assign_hash_str = assign_hash.to_json
|
39
37
|
response = @connection.do_post(managed_resource::SUB_URIS[:compareResult], "{\"compliance\": [#{assign_hash_str}]}")
|
40
|
-
|
38
|
+
response.body
|
41
39
|
end
|
42
40
|
|
43
41
|
def delete_compliance_policy(policy_name,removePackage)
|
44
42
|
query = policy_name.nil? ? "" : "?policyName=" + policy_name
|
45
43
|
query = removePackage.nil? ? query : query + "&removePackage=" + removePackage
|
46
44
|
response = @connection.do_delete(managed_resource::BASE_URI + query)
|
47
|
-
|
45
|
+
response.body
|
48
46
|
end
|
49
47
|
|
50
48
|
end
|
@@ -2,24 +2,17 @@ require 'json'
|
|
2
2
|
require 'pathname'
|
3
3
|
|
4
4
|
module XClarityClient
|
5
|
-
class GlobalSettingManagement <
|
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
|
5
|
+
class GlobalSettingManagement < Services::XClarityService
|
6
|
+
manages_endpoint GlobalSetting
|
17
7
|
|
18
8
|
def set_globalsettings(opts={})
|
19
9
|
request_body = JSON.generate(opts)
|
20
|
-
|
21
|
-
|
22
|
-
response =
|
10
|
+
res = Schemas.validate_input(:set_globalsettings, request_body)
|
11
|
+
if res[:result] == 'success'
|
12
|
+
response = @connection.do_put("#{GlobalSetting::BASE_URI}",
|
13
|
+
request_body)
|
14
|
+
else
|
15
|
+
res
|
23
16
|
end
|
24
17
|
end
|
25
18
|
end
|
@@ -2,30 +2,21 @@ require 'json'
|
|
2
2
|
require 'pathname'
|
3
3
|
|
4
4
|
module XClarityClient
|
5
|
-
class HostPlatformManagement <
|
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
|
5
|
+
class HostPlatformManagement < Services::XClarityService
|
6
|
+
manages_endpoint HostPlatform
|
16
7
|
|
17
8
|
def get_osimage_deployment_status(uuid)
|
18
|
-
|
19
|
-
response = connection("#{HostPlatform::BASE_URI}/#{uuid}")
|
20
|
-
response = JSON.parse(response.body)
|
21
|
-
end
|
9
|
+
response = @connection.do_get("#{HostPlatform::BASE_URI}/#{uuid}")
|
22
10
|
end
|
23
11
|
|
24
12
|
def deploy_osimage(opts=[])
|
25
13
|
request_body = JSON.generate(opts)
|
26
|
-
|
27
|
-
|
28
|
-
|
14
|
+
res = Schemas.validate_input(:deploy_osimage, request_body)
|
15
|
+
if res[:result] == 'success'
|
16
|
+
response = @connection.do_put("#{HostPlatform::BASE_URI}",
|
17
|
+
request_body)
|
18
|
+
else
|
19
|
+
res
|
29
20
|
end
|
30
21
|
end
|
31
22
|
end
|
@@ -2,43 +2,31 @@ require 'json'
|
|
2
2
|
require 'pathname'
|
3
3
|
|
4
4
|
module XClarityClient
|
5
|
-
class OsImageManagement <
|
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
|
5
|
+
class OsImageManagement < Services::XClarityService
|
6
|
+
manages_endpoint OsImage
|
16
7
|
|
17
8
|
def import_osimage(server_id, path)
|
18
|
-
return unless Schemas.validate_input_parameter("serverId", server_id, String) ||
|
19
|
-
Schemas.validate_input_parameter("path", path, String)
|
20
|
-
|
21
9
|
msg="inputs serverId=#{server_id},path=#{path}"
|
22
10
|
$lxca_log.info self.class.to_s+" "+__method__.to_s, msg
|
23
11
|
opts = { :Action => "Init" }
|
24
12
|
request_body = JSON.generate(opts)
|
25
|
-
response = do_post("#{OsImage::BASE_URI}?imageType=OS",
|
13
|
+
response = @connection.do_post("#{OsImage::BASE_URI}?imageType=OS",
|
14
|
+
request_body)
|
26
15
|
response = JSON.load(response.body).to_hash
|
27
16
|
job_id = response["jobId"]
|
28
17
|
opts = { :serverId => server_id, :path => path }
|
29
18
|
request_body = JSON.generate(opts)
|
30
19
|
image_name = path.split(File::SEPARATOR).last
|
31
20
|
begin
|
32
|
-
response = do_post(
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
JSON.parse(response.body)
|
21
|
+
response = @connection.do_post("#{OsImage::BASE_URI}?jobId=#{job_id}"\
|
22
|
+
"&imageType=OS&imageName=#{image_name}",
|
23
|
+
request_body)
|
24
|
+
response
|
37
25
|
rescue Faraday::TimeoutError => e
|
38
|
-
result =
|
39
|
-
:result => "
|
40
|
-
|
41
|
-
|
26
|
+
result = {
|
27
|
+
:result => "importing image is in progress with jobId #{job_id}"
|
28
|
+
}
|
29
|
+
result
|
42
30
|
end
|
43
31
|
end
|
44
32
|
end
|
@@ -1,41 +1,29 @@
|
|
1
1
|
require 'json'
|
2
2
|
|
3
3
|
module XClarityClient
|
4
|
-
class RemoteFileServerManagement <
|
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
|
4
|
+
class RemoteFileServerManagement < Services::XClarityService
|
5
|
+
manages_endpoint RemoteFileServer
|
15
6
|
|
16
7
|
def create_remotefileserver_profile(opts)
|
17
8
|
request_body = JSON.generate(opts)
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
9
|
+
res = Schemas.validate_input(:create_remotefileserver_profile,
|
10
|
+
request_body)
|
11
|
+
if res[:result] == 'success'
|
12
|
+
response = @connection.do_post(RemoteFileServer::BASE_URI,
|
13
|
+
request_body)
|
14
|
+
else
|
15
|
+
res
|
23
16
|
end
|
24
17
|
end
|
25
18
|
|
26
19
|
def delete_remotefileserver_profile(serverId)
|
27
|
-
|
28
|
-
|
29
|
-
end
|
30
|
-
response = do_delete("#{RemoteFileServer::BASE_URI}/#{serverId}")
|
31
|
-
response = JSON.parse(response.body)
|
20
|
+
response = @connection.do_delete("#{RemoteFileServer::BASE_URI}/"\
|
21
|
+
"#{serverId}")
|
32
22
|
end
|
33
23
|
|
34
24
|
def get_remotefileserver_profile(serverId)
|
35
|
-
|
36
|
-
|
37
|
-
response = JSON.parse(response.body)
|
38
|
-
end
|
25
|
+
response = @connection.do_get("#{RemoteFileServer::BASE_URI}/"\
|
26
|
+
"#{serverId}")
|
39
27
|
end
|
40
28
|
end
|
41
29
|
end
|
@@ -33,5 +33,63 @@ module XClarityClient
|
|
33
33
|
updatesByMtByComp
|
34
34
|
)
|
35
35
|
end
|
36
|
+
|
37
|
+
public
|
38
|
+
|
39
|
+
def check_file_types(file_types)
|
40
|
+
x = 'Invalid value for argument file_types. Allowed values are'\
|
41
|
+
+ ' - all and payloads'
|
42
|
+
raise x unless file_types.casecmp('payloads').zero? ||
|
43
|
+
file_types.casecmp('all').zero?
|
44
|
+
end
|
45
|
+
|
46
|
+
def read_update_repo
|
47
|
+
response = @connection.do_put(UpdateRepo::BASE_URI + '?action=read')
|
48
|
+
response.body
|
49
|
+
end
|
50
|
+
|
51
|
+
def refresh_update_repo(scope, mt, os)
|
52
|
+
if scope.casecmp('all') != 0 && scope.casecmp('latest') != 0
|
53
|
+
raise 'Invalid argument combination of action and scope. Action'\
|
54
|
+
+ ' refresh can have scope as either all or latest'
|
55
|
+
end
|
56
|
+
refresh_req = JSON.generate(:mt => mt, :os => os, :type => 'catalog')
|
57
|
+
response = @connection.do_put(UpdateRepo::BASE_URI\
|
58
|
+
+ '?action=refresh&with='\
|
59
|
+
+ scope.downcase, refresh_req)
|
60
|
+
response.body
|
61
|
+
end
|
62
|
+
|
63
|
+
def acquire_firmware_updates(scope, fixids, mt)
|
64
|
+
if scope.casecmp('payloads') != 0
|
65
|
+
raise 'Invalid argument combination of action and scope. Action'\
|
66
|
+
+ ' acquire can have scope as payloads'
|
67
|
+
end
|
68
|
+
acquire_req = JSON.generate(:mt => mt, :fixids => fixids,
|
69
|
+
:type => 'latest')
|
70
|
+
response = @connection.do_put(UpdateRepo::BASE_URI\
|
71
|
+
+ '?action=acquire&with='\
|
72
|
+
+ scope.downcase, acquire_req)
|
73
|
+
response.body
|
74
|
+
end
|
75
|
+
|
76
|
+
def delete_firmware_updates(file_types, fixids)
|
77
|
+
check_file_types(file_types)
|
78
|
+
delete_req = JSON.generate(:fixids => fixids)
|
79
|
+
response = @connection.do_put(UpdateRepo::BASE_URI + '?action='\
|
80
|
+
+ 'delete&filetypes=' + file_types.downcase,
|
81
|
+
delete_req)
|
82
|
+
response.body
|
83
|
+
end
|
84
|
+
|
85
|
+
def export_firmware_updates(file_types, fixids)
|
86
|
+
check_file_types(file_types)
|
87
|
+
|
88
|
+
export_req = JSON.generate(:fixids => fixids)
|
89
|
+
response = @connection.do_put(UpdateRepo::BASE_URI\
|
90
|
+
+ '?action=export&filetypes='\
|
91
|
+
+ file_types.downcase, export_req)
|
92
|
+
response.body
|
93
|
+
end
|
36
94
|
end
|
37
95
|
end
|