lita-pulp 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +18 -0
- data/Gemfile +3 -0
- data/README.md +35 -0
- data/Rakefile +8 -0
- data/lib/lita-pulp.rb +15 -0
- data/lib/lita/handlers/pulp.rb +369 -0
- data/lib/pulphelper/misc.rb +16 -0
- data/lib/pulphelper/repo.rb +356 -0
- data/lib/pulphelper/unit.rb +107 -0
- data/lita-pulp.gemspec +28 -0
- data/locales/en.yml +23 -0
- data/spec/fixtures/cassettes/Lita_Handlers_Pulp/_copy_puppet_between_repo/copy_puppet_module.yml +86 -0
- data/spec/fixtures/cassettes/Lita_Handlers_Pulp/_copy_puppet_between_repo/copy_puppet_module_delete_new_and_publish.yml +217 -0
- data/spec/fixtures/cassettes/Lita_Handlers_Pulp/_copy_rpm_between_repo/copy_rpm_package.yml +86 -0
- data/spec/fixtures/cassettes/Lita_Handlers_Pulp/_copy_rpm_between_repo/copy_rpm_package_delete_new_and_publish.yml +264 -0
- data/spec/fixtures/cassettes/Lita_Handlers_Pulp/_puppet_repos/list_puppet_repos.yml +88 -0
- data/spec/fixtures/cassettes/Lita_Handlers_Pulp/_puppet_search/search_puppet_with_repo.yml +134 -0
- data/spec/fixtures/cassettes/Lita_Handlers_Pulp/_puppet_search/search_puppet_without_author_name.yml +134 -0
- data/spec/fixtures/cassettes/Lita_Handlers_Pulp/_puppet_search/search_puppet_without_repo.yml +134 -0
- data/spec/fixtures/cassettes/Lita_Handlers_Pulp/_rpm_repos/list_rpm_repos.yml +593 -0
- data/spec/fixtures/cassettes/Lita_Handlers_Pulp/_rpm_search/search_rpm_with_repo.yml +152 -0
- data/spec/fixtures/cassettes/Lita_Handlers_Pulp/_rpm_search/search_rpm_without_repo.yml +152 -0
- data/spec/lita/handlers/pulp_repo_spec.rb +35 -0
- data/spec/lita/handlers/pulp_unit_spec.rb +79 -0
- data/spec/spec_helper.rb +28 -0
- data/templates/.gitkeep +0 -0
- metadata +226 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: df5d209cbd637fa2e641a80918bce7306fcd3b59
|
4
|
+
data.tar.gz: 4699d7f5ef9e5fffd707e4e430e0b8ebd291cabd
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 437604596ddb5d70685dde9956fa9ecd8a9e4697b870963c8897655ac54e0ebd86798c9665ff09c917b589d76ad35fa4c5df5f6d7abfd2c4daf20fcd97efad8c
|
7
|
+
data.tar.gz: bce0fb5b4e7b3108fae5fe0e7ce98ee1d834373a08540ac605a2a9ba50f7c5d30945e1cf9c23c1f7f515289b9a4877a9adc43679bd0d5656850b6f6513b075c1
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# lita-pulp
|
2
|
+
|
3
|
+
A lita handler plugin for pulp server operations.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add lita-pulp to your Lita instance's Gemfile:
|
8
|
+
|
9
|
+
``` ruby
|
10
|
+
gem "lita-pulp"
|
11
|
+
```
|
12
|
+
|
13
|
+
## Configuration
|
14
|
+
|
15
|
+
Configuration options
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
Lita.configure do |config|
|
19
|
+
config.handlers.pulp.url="https://pulp.co.epi.web"
|
20
|
+
config.handlers.pulp.api_path="/pulp/api/v2/"
|
21
|
+
config.handlers.pulp.username="admin"
|
22
|
+
config.handlers.pulp.password="admin"
|
23
|
+
config.handlers.pulp.verify_ssl=false #optional default to false
|
24
|
+
end
|
25
|
+
```
|
26
|
+
|
27
|
+
## Usage
|
28
|
+
|
29
|
+
It can do following:
|
30
|
+
- List all rpm repositories
|
31
|
+
- List all puppet repositories
|
32
|
+
- Search rpm package
|
33
|
+
- Search puppet module
|
34
|
+
- Copy rpm package from one repository to another
|
35
|
+
- Copy puppet module from one repository to another
|
data/Rakefile
ADDED
data/lib/lita-pulp.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require "lita"
|
2
|
+
|
3
|
+
Lita.load_locales Dir[File.expand_path(
|
4
|
+
File.join("..", "..", "locales", "*.yml"), __FILE__
|
5
|
+
)]
|
6
|
+
|
7
|
+
require 'pulphelper/misc'
|
8
|
+
require 'pulphelper/repo'
|
9
|
+
require 'pulphelper/unit'
|
10
|
+
require "lita/handlers/pulp"
|
11
|
+
|
12
|
+
Lita::Handlers::Pulp.template_root File.expand_path(
|
13
|
+
File.join("..", "..", "templates"),
|
14
|
+
__FILE__
|
15
|
+
)
|
@@ -0,0 +1,369 @@
|
|
1
|
+
require 'lita-keyword-arguments'
|
2
|
+
#require 'table_print'
|
3
|
+
|
4
|
+
module Lita
|
5
|
+
module Handlers
|
6
|
+
class Pulp < Handler
|
7
|
+
# insert handler code here
|
8
|
+
namespace 'Pulp'
|
9
|
+
config :username, required: true, type: String
|
10
|
+
config :password, required: true, type: String
|
11
|
+
config :url, required: true, type: String
|
12
|
+
config :api_path, required: true, type: String
|
13
|
+
config :verify_ssl, required:true, types: [TrueClass, FalseClass], default: false
|
14
|
+
|
15
|
+
include ::PulpHelper::Misc
|
16
|
+
include ::PulpHelper::Repo
|
17
|
+
include ::PulpHelper::Unit
|
18
|
+
|
19
|
+
route(
|
20
|
+
/^pulp\srpm\srepos$/,
|
21
|
+
:rpm_repos,
|
22
|
+
command: true,
|
23
|
+
help: {
|
24
|
+
t('help.rpm_repos_key') => t('help.rpm_repos_value')
|
25
|
+
}
|
26
|
+
)
|
27
|
+
|
28
|
+
route(
|
29
|
+
/^pulp\spuppet\srepos$/,
|
30
|
+
:puppet_repos,
|
31
|
+
command: true,
|
32
|
+
help: {
|
33
|
+
t('help.puppet_repos_key') => t('help.puppet_repos_value')
|
34
|
+
}
|
35
|
+
)
|
36
|
+
|
37
|
+
route(
|
38
|
+
/^pulp\spubish\s(\S+)$/,
|
39
|
+
:publish_repo,
|
40
|
+
command: true,
|
41
|
+
help: {
|
42
|
+
t('help.publish_key') => t('help.publish_value')
|
43
|
+
}
|
44
|
+
)
|
45
|
+
|
46
|
+
route(
|
47
|
+
/^pulp\srpm\ssearch\s(\S+)(?>\sin\s)?(\S+)?$/,
|
48
|
+
:rpm_search,
|
49
|
+
command: true,
|
50
|
+
help: {
|
51
|
+
t('help.rpm_search_key') => t('help.rpm_search_value')
|
52
|
+
}
|
53
|
+
)
|
54
|
+
|
55
|
+
route(
|
56
|
+
/^pulp\s+puppet\s+search\s+(?>[a_zA-Z0-9]+\/)?(\S+)(?>\s+in\s+)?(\S+)?$/,
|
57
|
+
:puppet_search,
|
58
|
+
command: true,
|
59
|
+
help: {
|
60
|
+
t('help.puppet_search_key') => t('help.puppet_search_value')
|
61
|
+
}
|
62
|
+
)
|
63
|
+
|
64
|
+
route(
|
65
|
+
/^pulp\s+rpm\s+copy/i,
|
66
|
+
:copy_rpm,
|
67
|
+
command: true,
|
68
|
+
kwargs: {
|
69
|
+
from: {
|
70
|
+
short: "s",
|
71
|
+
},
|
72
|
+
to: {
|
73
|
+
short: "t"
|
74
|
+
},
|
75
|
+
name: {
|
76
|
+
short: "n"
|
77
|
+
},
|
78
|
+
version: {
|
79
|
+
short: "v"
|
80
|
+
},
|
81
|
+
release: {
|
82
|
+
short: "r"
|
83
|
+
},
|
84
|
+
arch: {
|
85
|
+
short: "a"
|
86
|
+
},
|
87
|
+
delete_newer: {
|
88
|
+
short: "d",
|
89
|
+
boolean: true
|
90
|
+
},
|
91
|
+
publish: {
|
92
|
+
short: "p",
|
93
|
+
boolean: true
|
94
|
+
}
|
95
|
+
},
|
96
|
+
help: {
|
97
|
+
t("help.copy_rpm_key") => t("help.copy_rpm_value")
|
98
|
+
}
|
99
|
+
)
|
100
|
+
|
101
|
+
|
102
|
+
route(
|
103
|
+
/^pulp\s+puppet\s+copy/i,
|
104
|
+
:copy_puppet,
|
105
|
+
command: true,
|
106
|
+
kwargs: {
|
107
|
+
from: {
|
108
|
+
short: "s",
|
109
|
+
},
|
110
|
+
to: {
|
111
|
+
short: "t"
|
112
|
+
},
|
113
|
+
author: {
|
114
|
+
short: "a"
|
115
|
+
},
|
116
|
+
name: {
|
117
|
+
short: "n"
|
118
|
+
},
|
119
|
+
version: {
|
120
|
+
short: "v"
|
121
|
+
},
|
122
|
+
delete_newer: {
|
123
|
+
short: "d",
|
124
|
+
boolean: true
|
125
|
+
},
|
126
|
+
publish: {
|
127
|
+
short: "p",
|
128
|
+
boolean: true
|
129
|
+
}
|
130
|
+
},
|
131
|
+
help: {
|
132
|
+
t("help.copy_puppet_key") => t("help.copy_puppet_value")
|
133
|
+
}
|
134
|
+
)
|
135
|
+
|
136
|
+
route(
|
137
|
+
/^pulp\s+rpm\s+delete\s+newer/i,
|
138
|
+
:delete_newer_rpm,
|
139
|
+
command: true,
|
140
|
+
kwargs: {
|
141
|
+
from: {
|
142
|
+
short: "s",
|
143
|
+
},
|
144
|
+
name: {
|
145
|
+
short: "n"
|
146
|
+
},
|
147
|
+
version: {
|
148
|
+
short: "v"
|
149
|
+
},
|
150
|
+
release: {
|
151
|
+
short: "r"
|
152
|
+
},
|
153
|
+
arch: {
|
154
|
+
short: "a"
|
155
|
+
},
|
156
|
+
publish: {
|
157
|
+
short: "p",
|
158
|
+
boolean: true
|
159
|
+
}
|
160
|
+
},
|
161
|
+
help: {
|
162
|
+
t("help.delete_newer_rpm_key") => t("help.delete_newer_rpm_value")
|
163
|
+
}
|
164
|
+
)
|
165
|
+
|
166
|
+
route(
|
167
|
+
/^pulp\s+puppet\s+delete\s+newer/i,
|
168
|
+
:delete_newer_puppet,
|
169
|
+
command: true,
|
170
|
+
kwargs: {
|
171
|
+
from: {
|
172
|
+
short: "s",
|
173
|
+
},
|
174
|
+
author: {
|
175
|
+
short: "a"
|
176
|
+
},
|
177
|
+
name: {
|
178
|
+
short: "n"
|
179
|
+
},
|
180
|
+
version: {
|
181
|
+
short: "v"
|
182
|
+
},
|
183
|
+
publish: {
|
184
|
+
short: "p",
|
185
|
+
boolean: true
|
186
|
+
}
|
187
|
+
},
|
188
|
+
help: {
|
189
|
+
t("help.delete_newer_puppet_key") => t("help.delete_newer_puppet_value")
|
190
|
+
}
|
191
|
+
)
|
192
|
+
|
193
|
+
def rpm_repos(response)
|
194
|
+
begin
|
195
|
+
result=list_repo(REPO_TYPE_RPM)
|
196
|
+
#puts "********result"
|
197
|
+
s = StringIO.new
|
198
|
+
result.each do |r|
|
199
|
+
s << "["<< r[:id] << "] : " << r[:name] << "," << r[:description] << "\n"
|
200
|
+
end
|
201
|
+
response.reply s.string
|
202
|
+
rescue Exception => e
|
203
|
+
response.reply e.message
|
204
|
+
end
|
205
|
+
end
|
206
|
+
|
207
|
+
def puppet_repos(response)
|
208
|
+
begin
|
209
|
+
result=list_repo(REPO_TYPE_PUPPET)
|
210
|
+
#response.reply result.to_json
|
211
|
+
s = StringIO.new
|
212
|
+
result.each do |r|
|
213
|
+
s << "["<< r[:id] << "] : " << r[:name] << "," << r[:description] << "\n"
|
214
|
+
end
|
215
|
+
response.reply s.string
|
216
|
+
rescue Exception => e
|
217
|
+
response.reply e.message
|
218
|
+
end
|
219
|
+
end
|
220
|
+
|
221
|
+
def publish_repo(response)
|
222
|
+
repo_id = response.matchs[0][0]
|
223
|
+
if repo_id
|
224
|
+
begin
|
225
|
+
publish_repo(repo_id)
|
226
|
+
response.reply "Command executed successfully"
|
227
|
+
rescue Exception => e
|
228
|
+
response.reply e.message
|
229
|
+
end
|
230
|
+
else
|
231
|
+
response.reply "No repoistory id specified"
|
232
|
+
end
|
233
|
+
end
|
234
|
+
|
235
|
+
def rpm_search(response)
|
236
|
+
name = response.matches[0][0]
|
237
|
+
repo = response.matches[0][1]
|
238
|
+
puts "searching for rpm #{name} in repo #{repo}"
|
239
|
+
begin
|
240
|
+
# result array of
|
241
|
+
# result = {
|
242
|
+
# :name => unit["name"],
|
243
|
+
# :epoch => unit["epoch"],
|
244
|
+
# :version => unit["version"],
|
245
|
+
# :release => unit["release"],
|
246
|
+
# :checksum => unit["checksum"],
|
247
|
+
# :repos => unit["repository_memberships"]
|
248
|
+
# }
|
249
|
+
result=search_rpm(name, repo)
|
250
|
+
s = StringIO.new
|
251
|
+
result.each do |r|
|
252
|
+
s << "["<< r[:name] << "] : " << r[:version] << "," << r[:release] << "," << r[:repos] <<"\n"
|
253
|
+
end
|
254
|
+
response.reply s.string
|
255
|
+
rescue StandardError => e
|
256
|
+
response.reply e.message
|
257
|
+
end
|
258
|
+
|
259
|
+
end
|
260
|
+
|
261
|
+
def puppet_search(response)
|
262
|
+
full_name = response.matches[0][0]
|
263
|
+
repo = response.matches[0][1]
|
264
|
+
name_spec = full_name.split('/')
|
265
|
+
puts "name_spec:#{name_spec}"
|
266
|
+
if name_spec.length >1
|
267
|
+
author = name_spec[0]
|
268
|
+
name = name_spec[1]
|
269
|
+
else
|
270
|
+
name = full_name
|
271
|
+
author = nil
|
272
|
+
end
|
273
|
+
puts "searching for puppet module #{name} with author: #{author} in repo #{repo}, full_name = #{full_name}"
|
274
|
+
begin
|
275
|
+
result=search_puppet(author, name, repo)
|
276
|
+
s = StringIO.new
|
277
|
+
result.each do |r|
|
278
|
+
s << "["<< r[:author] << "/" << r[:name]<< "] :" <<r[:version] << "," << r[:repos] <<"\n"
|
279
|
+
end
|
280
|
+
response.reply s.string
|
281
|
+
rescue StandardError => e
|
282
|
+
response.reply e.message
|
283
|
+
end
|
284
|
+
end
|
285
|
+
|
286
|
+
def copy_rpm(response)
|
287
|
+
args = response.extensions[:kwargs]
|
288
|
+
from = args[:from]
|
289
|
+
to = args[:to]
|
290
|
+
release = args[:release]
|
291
|
+
name = args[:name]
|
292
|
+
version = args[:version]
|
293
|
+
arch = args[:arch]
|
294
|
+
delete_newer=args[:delete_newer]||false
|
295
|
+
publish=args[:publish]||false
|
296
|
+
begin
|
297
|
+
if from.nil? || to.nil? || release.nil? ||name.nil? || version.nil? || arch.nil?
|
298
|
+
raise "Exception: Missing required paramenter"
|
299
|
+
end
|
300
|
+
copy_rpm_between_repo!(from, to, name, version, release, arch, delete_newer, publish)
|
301
|
+
response.reply "Command executed successfully"
|
302
|
+
rescue StandardError => e
|
303
|
+
response.reply e.message
|
304
|
+
end
|
305
|
+
end
|
306
|
+
|
307
|
+
def copy_puppet(response)
|
308
|
+
args = response.extensions[:kwargs]
|
309
|
+
from = args[:from]
|
310
|
+
to = args[:to]
|
311
|
+
author = args[:author]
|
312
|
+
name = args[:name]
|
313
|
+
version = args[:version]
|
314
|
+
delete_newer=args[:delete_newer]||false
|
315
|
+
publish=args[:publish]||false
|
316
|
+
begin
|
317
|
+
if from.nil? || to.nil? || author.nil? || name.nil? || version.nil?
|
318
|
+
raise "Exception: missing required parameters"
|
319
|
+
end
|
320
|
+
copy_puppet_between_repo!(from, to, author, name, version, delete_newer, publish)
|
321
|
+
response.reply "Command executed successfully"
|
322
|
+
rescue StandardError => e
|
323
|
+
response.reply e.message
|
324
|
+
end
|
325
|
+
end
|
326
|
+
|
327
|
+
def delete_newer_rpm(response)
|
328
|
+
args = response.extensions[:kwargs]
|
329
|
+
from = args[:from]
|
330
|
+
release = args[:release]
|
331
|
+
name = args[:name]
|
332
|
+
version = args[:version]
|
333
|
+
arch = args[:arch]
|
334
|
+
publish=args[:publish]||false
|
335
|
+
begin
|
336
|
+
if from.nil? || author.nil? || name.nil? || version.nil?
|
337
|
+
raise "Exception: missing required parameters"
|
338
|
+
end
|
339
|
+
delete_rpm_newer!(from, name, version, relase, arch, publish)
|
340
|
+
response.reply "Command executed successfully"
|
341
|
+
rescue StandardError => e
|
342
|
+
response.reply e.message
|
343
|
+
end
|
344
|
+
end
|
345
|
+
|
346
|
+
def delete_newer_puppet(response)
|
347
|
+
args = response.extensions[:kwargs]
|
348
|
+
from = args[:from]
|
349
|
+
author = args[:author]
|
350
|
+
name = args[:name]
|
351
|
+
version = args[:version]
|
352
|
+
publish=args[:publish]||false
|
353
|
+
begin
|
354
|
+
if from.nil? || author.nil? || name.nil? || version.nil?
|
355
|
+
raise "Exception: missing required parameters"
|
356
|
+
end
|
357
|
+
delete_puppet_newer!(from, author, name, version, publish)
|
358
|
+
response.reply "Command executed successfully"
|
359
|
+
rescue StandardError => e
|
360
|
+
response.reply e.message
|
361
|
+
end
|
362
|
+
end
|
363
|
+
|
364
|
+
|
365
|
+
Lita.register_handler(self)
|
366
|
+
#Lita.register_hook(:trigger_route, Lita::Extensions::KeywordArguments)
|
367
|
+
end
|
368
|
+
end
|
369
|
+
end
|