lita-pulp 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 53bb22e0cf58e3709b3db64aebde429b738468ec
4
- data.tar.gz: 8c3052b58f6c0a5e2cf5f91698c7b4cd6e359427
3
+ metadata.gz: 416aacd0fb3aaabb6b65bea319aaabf2be13a661
4
+ data.tar.gz: fd19b59ede4cc87d3c9a235e54ac1b5aa79c4b18
5
5
  SHA512:
6
- metadata.gz: a28398bfcdda019c4f473a537403fc87065afa566d9923172c58bbd60185ed7d5b87dae925728c92e695a4606d25f5e3bf76eeff6eb88504062e44a9310e1640
7
- data.tar.gz: 0d781e000638c3595c8e4a37ff20d0f33662f0ef7df00b04d51fbcf7b9a196a362be4453aa31a26371c0f936852271f73c0175bc69eb549170ee8a1577b7d8e3
6
+ metadata.gz: 7944048feedc01e4538293f039b84545b7c33838514b76ca5075c110e4c41b12ae43cecccc39fdce32ec7462e14a076f1f1f43c9a4305dd1fafd1940f6eddc92
7
+ data.tar.gz: 0dff1314caf747d268801c93560533aa567beb63ce74658c2a94d3576fb8136ce6928e7ca4c6d9cb5e302f79d3e366c100741a3da5f950dab8322bc7561a2b78
@@ -35,8 +35,8 @@ module Lita
35
35
  )
36
36
 
37
37
  route(
38
- /^pulp\spubish\s(\S+)$/,
39
- :publish_repo,
38
+ /^pulp\spublish\s(\S+)$/,
39
+ :repo_publish,
40
40
  command: true,
41
41
  help: {
42
42
  t('help.publish_key') => t('help.publish_value')
@@ -199,6 +199,24 @@ module Lita
199
199
  }
200
200
  )
201
201
 
202
+ route(
203
+ /^pulp\s+sync\s+(\S+)$/,
204
+ :repo_sync,
205
+ command: true,
206
+ help: {
207
+ t('help.sync_repo_key') => t('help.sync_repo_value')
208
+ }
209
+ )
210
+
211
+ # route(
212
+ # /^pulp\s+sync_status\s+(\S+)$/,
213
+ # :check_sync_status,
214
+ # command: true,
215
+ # help: {
216
+ # t('help.sync_status_key') => t('help.sync_status_value')
217
+ # }
218
+ # )
219
+
202
220
  def rpm_repos(response)
203
221
  begin
204
222
  result=list_repo(REPO_TYPE_RPM)
@@ -236,12 +254,15 @@ module Lita
236
254
  response.reply e.message
237
255
  end
238
256
  end
239
- def publish_repo(response)
240
- repo_id = response.matchs[0][0]
257
+ def repo_publish(response)
258
+ repo_id = response.matches[0][0]
241
259
  if repo_id
260
+ unless repo_id
261
+ response.reply "Invalid repository id"
262
+ end
242
263
  begin
243
- publish_repo(repo_id)
244
- response.reply "Command executed successfully"
264
+ result = publish_repo!(repo_id)
265
+ response.reply JSON.pretty_generate(result)
245
266
  rescue Exception => e
246
267
  response.reply e.message
247
268
  end
@@ -250,6 +271,44 @@ module Lita
250
271
  end
251
272
  end
252
273
 
274
+ def repo_sync(response)
275
+ #puts "response.matches[0]=#{response.matches[0][0]}"
276
+ repo_id = response.matches[0][0]
277
+ if repo_id
278
+ unless repo_id
279
+ response.reply "Invalid repository id"
280
+ end
281
+ begin
282
+ result=sync_repo!(repo_id)
283
+ response.reply JSON.pretty_generate(result)
284
+ rescue Exception => e
285
+ response.reply e.message
286
+ end
287
+ else
288
+ response.reply "No repoistory id specified"
289
+ end
290
+ end
291
+
292
+ #it returns all history with runcible api, which is not an idea behavior
293
+ #though pulp can puerge the task status according to configuration
294
+ def check_sync_status(response)
295
+ puts "response.matches[0]=#{response.matches[0][0]}"
296
+ repo_id = response.matches[0][0]
297
+ if repo_id
298
+ unless repo_id
299
+ response.reply "Invalid repository id"
300
+ end
301
+ begin
302
+ result = sync_status(repo_id)
303
+ response.reply JSON.pretty_generate(result)
304
+ rescue Exception => e
305
+ response.reply e.message
306
+ end
307
+ else
308
+ response.reply "No repoistory id specified"
309
+ end
310
+ end
311
+
253
312
  def rpm_search(response)
254
313
  name = response.matches[0][0]
255
314
  repo = response.matches[0][1]
@@ -139,14 +139,51 @@ module PulpHelper
139
139
  ##
140
140
  ## Runcilbe does not proper include respone code
141
141
  ##
142
- if publish_response.code !=202 && !"#{publish_response.code}".start_with?("20")
143
- raise "Publish #{forge_id} failed with http response code: #{publish_response.code}"
142
+ presponse=JSON.parse(publish_response.to_json)
143
+ if presponse.nil? || presponse[0]["spawned_tasks"].length<1
144
+ raise "Exception: repo publish requeste failed, response : #{publish_response}"
144
145
  end
146
+ publish_response
145
147
  rescue StandardError => e
146
148
  raise "Excpetion: Failed to publish, #{e.message}"
147
149
  end
148
150
  end#publish_repo
149
151
 
152
+ def sync_repo!(forge_id)
153
+ begin
154
+ sync_response=client.extensions.repository.sync(forge_id)
155
+ ##
156
+ ## Runcilbe does not proper include respone code
157
+ ##
158
+ if sync_response.code !=201 && !"#{sync_response.code}".start_with?("20")
159
+ if sync_response.code == 404
160
+ raise "repository #{forge_id} not found"
161
+ end
162
+ raise "Sync #{forge_id} failed with http response code: #{sync_response.code}"
163
+ end
164
+ sync_response
165
+ rescue StandardError => e
166
+ raise "Excpetion: Failed to Sync, #{e.message}"
167
+ end
168
+ end#sync_repo
169
+
170
+ def sync_status(forge_id)
171
+ begin
172
+ sync_response=client.extensions.repository.sync_status(forge_id)
173
+ ##
174
+ ## Runcilbe does not proper include respone code
175
+ ##
176
+ if sync_response.code !=200 && !"#{sync_response.code}".start_with?("20")
177
+ if sync_response.code == 404
178
+ raise "repository #{forge_id} not found"
179
+ end
180
+ raise "Sync #{forge_id} failed with http response code: #{sync_response.code}"
181
+ end
182
+ rescue StandardError => e
183
+ raise "Excpetion: Failed to Sync, #{e.message}"
184
+ end
185
+ end
186
+
150
187
  def delete_rpm_newer!(forge_id, name, version, release, arch, auto_publish=false)
151
188
  criteria = get_rpm_unit_ass_criteria(name, version, release, arch)
152
189
  begin
data/lita-pulp.gemspec CHANGED
@@ -1,7 +1,7 @@
1
1
 
2
2
  Gem::Specification.new do |spec|
3
3
  spec.name = "lita-pulp"
4
- spec.version = "0.1.1"
4
+ spec.version = "0.1.2"
5
5
  spec.authors = ["Wang, Dawei"]
6
6
  spec.email = ["daweiwang.gatekeeper@gmail.com"]
7
7
  spec.description = "Lita bot for pulp server"
data/locales/en.yml CHANGED
@@ -23,3 +23,7 @@ en:
23
23
  delete_newer_puppet_value: "Delete newer version of specified puppet module from SRC_REPO , optionally publish the repo"
24
24
  show_repo_key: "pulp show repo REPO_ID"
25
25
  show_repo_value: "Show details of REPO_ID"
26
+ sync_repo_key: "pulp sync REPO_ID"
27
+ sync_repo_value: "Sync repository REPO_ID"
28
+ sync_status_key: "pulp sync_status REPO_ID"
29
+ sync_status_value: "Check repository REPO_ID sync status"
@@ -0,0 +1,140 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://pulp.co.epi.web/pulp/api/v2/repositories/ent-cent7-qa/?details=true
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept:
11
+ - application/json
12
+ Accept-Encoding:
13
+ - gzip, deflate
14
+ Content-Type:
15
+ - application/json
16
+ User-Agent:
17
+ - Ruby
18
+ Authorization:
19
+ - Basic YWRtaW46YWRtaW4=
20
+ response:
21
+ status:
22
+ code: 200
23
+ message: OK
24
+ headers:
25
+ Date:
26
+ - Thu, 30 Jun 2016 18:56:12 GMT
27
+ Server:
28
+ - Apache/2.2.15 (CentOS)
29
+ Content-Length:
30
+ - '1656'
31
+ Connection:
32
+ - close
33
+ Content-Type:
34
+ - application/json; charset=utf-8
35
+ body:
36
+ encoding: UTF-8
37
+ string: '{"scratchpad": {"checksum_type": "sha256"}, "display_name": "ent-cent7-qa",
38
+ "description": null, "distributors": [{"repo_id": "ent-cent7-qa", "_href":
39
+ "/pulp/api/v2/repositories/ent-cent7-qa/distributors/yum_distributor/", "_ns":
40
+ "repo_distributors", "last_publish": "2016-06-30T18:22:22Z", "distributor_type_id":
41
+ "yum_distributor", "auto_publish": true, "scratchpad": {}, "_id": {"$oid":
42
+ "56b5142ec20cde71a353fc80"}, "config": {"checksum_type": "sha256", "http":
43
+ true, "relative_url": "entertainment/qa/centos/7/x86_64", "https": true},
44
+ "id": "yum_distributor"}, {"repo_id": "ent-cent7-qa", "_href": "/pulp/api/v2/repositories/ent-cent7-qa/distributors/export_distributor/",
45
+ "_ns": "repo_distributors", "last_publish": "2016-06-30T18:22:33Z", "distributor_type_id":
46
+ "export_distributor", "auto_publish": false, "scratchpad": {}, "_id": {"$oid":
47
+ "56b5142ec20cde71a353fc81"}, "config": {"http": true, "relative_url": "entertainment/qa/centos/7/x86_64",
48
+ "https": true}, "id": "export_distributor"}], "last_unit_added": null, "notes":
49
+ {"_repo-type": "rpm-repo"}, "last_unit_removed": null, "content_unit_counts":
50
+ {"rpm": 23}, "_ns": "repos", "importers": [{"scratchpad": null, "_href": "/pulp/api/v2/repositories/ent-cent7-qa/importers/yum_importer/",
51
+ "_ns": "repo_importers", "importer_type_id": "yum_importer", "last_sync":
52
+ "2016-02-05T21:30:24Z", "repo_id": "ent-cent7-qa", "_id": {"$oid": "56b5142ec20cde71a353fc7f"},
53
+ "config": {"ssl_validation": false}, "id": "yum_importer"}], "locally_stored_units":
54
+ 23, "_id": {"$oid": "56b5142ec20cde71a353fc7e"}, "total_repository_units":
55
+ 23, "id": "ent-cent7-qa", "_href": "/pulp/api/v2/repositories/ent-cent7-qa/"}'
56
+ http_version:
57
+ recorded_at: Thu, 30 Jun 2016 18:56:13 GMT
58
+ - request:
59
+ method: post
60
+ uri: https://pulp.co.epi.web/pulp/api/v2/repositories/ent-cent7-qa/actions/publish/
61
+ body:
62
+ encoding: UTF-8
63
+ string: '{"id":"yum_distributor"}'
64
+ headers:
65
+ Accept:
66
+ - application/json
67
+ Accept-Encoding:
68
+ - gzip, deflate
69
+ Content-Type:
70
+ - application/json
71
+ Content-Length:
72
+ - '24'
73
+ User-Agent:
74
+ - Ruby
75
+ Authorization:
76
+ - Basic YWRtaW46YWRtaW4=
77
+ response:
78
+ status:
79
+ code: 202
80
+ message: ACCEPTED
81
+ headers:
82
+ Date:
83
+ - Thu, 30 Jun 2016 18:56:12 GMT
84
+ Server:
85
+ - Apache/2.2.15 (CentOS)
86
+ Content-Length:
87
+ - '172'
88
+ Connection:
89
+ - close
90
+ Content-Type:
91
+ - application/json; charset=utf-8
92
+ body:
93
+ encoding: UTF-8
94
+ string: '{"spawned_tasks": [{"_href": "/pulp/api/v2/tasks/03ba6b1d-409a-445a-a183-b56495fa71cc/",
95
+ "task_id": "03ba6b1d-409a-445a-a183-b56495fa71cc"}], "result": null, "error":
96
+ null}'
97
+ http_version:
98
+ recorded_at: Thu, 30 Jun 2016 18:56:13 GMT
99
+ - request:
100
+ method: post
101
+ uri: https://pulp.co.epi.web/pulp/api/v2/repositories/ent-cent7-qa/actions/publish/
102
+ body:
103
+ encoding: UTF-8
104
+ string: '{"id":"export_distributor"}'
105
+ headers:
106
+ Accept:
107
+ - application/json
108
+ Accept-Encoding:
109
+ - gzip, deflate
110
+ Content-Type:
111
+ - application/json
112
+ Content-Length:
113
+ - '27'
114
+ User-Agent:
115
+ - Ruby
116
+ Authorization:
117
+ - Basic YWRtaW46YWRtaW4=
118
+ response:
119
+ status:
120
+ code: 202
121
+ message: ACCEPTED
122
+ headers:
123
+ Date:
124
+ - Thu, 30 Jun 2016 18:56:12 GMT
125
+ Server:
126
+ - Apache/2.2.15 (CentOS)
127
+ Content-Length:
128
+ - '172'
129
+ Connection:
130
+ - close
131
+ Content-Type:
132
+ - application/json; charset=utf-8
133
+ body:
134
+ encoding: UTF-8
135
+ string: '{"spawned_tasks": [{"_href": "/pulp/api/v2/tasks/e6e15264-dc14-4c32-82b9-3bfbc820bbe6/",
136
+ "task_id": "e6e15264-dc14-4c32-82b9-3bfbc820bbe6"}], "result": null, "error":
137
+ null}'
138
+ http_version:
139
+ recorded_at: Thu, 30 Jun 2016 18:56:14 GMT
140
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,44 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://pulp.co.epi.web/pulp/api/v2/repositories/forge_dev/actions/sync/
6
+ body:
7
+ encoding: UTF-8
8
+ string: "{}"
9
+ headers:
10
+ Accept:
11
+ - application/json
12
+ Accept-Encoding:
13
+ - gzip, deflate
14
+ Content-Type:
15
+ - application/json
16
+ Content-Length:
17
+ - '2'
18
+ User-Agent:
19
+ - Ruby
20
+ Authorization:
21
+ - Basic YWRtaW46YWRtaW4=
22
+ response:
23
+ status:
24
+ code: 202
25
+ message: ACCEPTED
26
+ headers:
27
+ Date:
28
+ - Thu, 30 Jun 2016 18:37:09 GMT
29
+ Server:
30
+ - Apache/2.2.15 (CentOS)
31
+ Content-Length:
32
+ - '172'
33
+ Connection:
34
+ - close
35
+ Content-Type:
36
+ - application/json; charset=utf-8
37
+ body:
38
+ encoding: UTF-8
39
+ string: '{"spawned_tasks": [{"_href": "/pulp/api/v2/tasks/b94d1d2b-045f-48d7-8e8c-0ea56d26f031/",
40
+ "task_id": "b94d1d2b-045f-48d7-8e8c-0ea56d26f031"}], "result": null, "error":
41
+ null}'
42
+ http_version:
43
+ recorded_at: Thu, 30 Jun 2016 18:37:10 GMT
44
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,44 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://pulp.co.epi.web/pulp/api/v2/repositories/forge_dev/actions/sync/
6
+ body:
7
+ encoding: UTF-8
8
+ string: "{}"
9
+ headers:
10
+ Accept:
11
+ - application/json
12
+ Accept-Encoding:
13
+ - gzip, deflate
14
+ Content-Type:
15
+ - application/json
16
+ Content-Length:
17
+ - '2'
18
+ User-Agent:
19
+ - Ruby
20
+ Authorization:
21
+ - Basic YWRtaW46YWRtaW4=
22
+ response:
23
+ status:
24
+ code: 202
25
+ message: ACCEPTED
26
+ headers:
27
+ Date:
28
+ - Thu, 30 Jun 2016 18:19:18 GMT
29
+ Server:
30
+ - Apache/2.2.15 (CentOS)
31
+ Content-Length:
32
+ - '172'
33
+ Connection:
34
+ - close
35
+ Content-Type:
36
+ - application/json; charset=utf-8
37
+ body:
38
+ encoding: UTF-8
39
+ string: '{"spawned_tasks": [{"_href": "/pulp/api/v2/tasks/39a84e98-2a0d-41b9-9baa-2c70d2282305/",
40
+ "task_id": "39a84e98-2a0d-41b9-9baa-2c70d2282305"}], "result": null, "error":
41
+ null}'
42
+ http_version:
43
+ recorded_at: Thu, 30 Jun 2016 18:19:20 GMT
44
+ recorded_with: VCR 3.0.3
@@ -15,6 +15,9 @@ describe Lita::Handlers::Pulp, lita_handler: true, :vcr => vcr_options do
15
15
  it do
16
16
  is_expected.to route_command('pulp rpm repos').to(:rpm_repos)
17
17
  is_expected.to route_command('pulp puppet repos').to(:puppet_repos)
18
+ is_expected.to route_command('pulp show repo test').to(:show_repo)
19
+ is_expected.to route_command('pulp sync test').to(:repo_sync)
20
+ is_expected.to route_command('pulp publish test').to(:repo_publish)
18
21
  end
19
22
 
20
23
  describe '#rpm_repos' do
@@ -46,4 +49,20 @@ describe Lita::Handlers::Pulp, lita_handler: true, :vcr => vcr_options do
46
49
  end
47
50
  end
48
51
 
52
+ describe '#sync repo' do
53
+ it 'sync a repository' do
54
+ send_command('pulp sync forge_dev')
55
+ puts "***********"
56
+ puts replies
57
+ end
58
+ end
59
+
60
+ describe '#publish repo' do
61
+ it 'publish a repository' do
62
+ send_command('pulp publish ent-cent7-qa')
63
+ puts "***********"
64
+ puts replies
65
+ end
66
+ end
67
+
49
68
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lita-pulp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wang, Dawei
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-29 00:00:00.000000000 Z
11
+ date: 2016-06-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lita
@@ -172,6 +172,7 @@ files:
172
172
  - spec/fixtures/cassettes/Lita_Handlers_Pulp/_copy_puppet_between_repo/copy_puppet_module_delete_new_and_publish.yml
173
173
  - spec/fixtures/cassettes/Lita_Handlers_Pulp/_copy_rpm_between_repo/copy_rpm_package.yml
174
174
  - spec/fixtures/cassettes/Lita_Handlers_Pulp/_copy_rpm_between_repo/copy_rpm_package_delete_new_and_publish.yml
175
+ - spec/fixtures/cassettes/Lita_Handlers_Pulp/_publish_repo/publish_a_repository.yml
175
176
  - spec/fixtures/cassettes/Lita_Handlers_Pulp/_puppet_repos/list_puppet_repos.yml
176
177
  - spec/fixtures/cassettes/Lita_Handlers_Pulp/_puppet_search/search_puppet_with_repo.yml
177
178
  - spec/fixtures/cassettes/Lita_Handlers_Pulp/_puppet_search/search_puppet_without_author_name.yml
@@ -182,6 +183,8 @@ files:
182
183
  - spec/fixtures/cassettes/Lita_Handlers_Pulp/_show_repo_detail/show_a_puppet_repo_detail.yml
183
184
  - spec/fixtures/cassettes/Lita_Handlers_Pulp/_show_repo_detail/show_a_rpm_repo_detail.yml
184
185
  - spec/fixtures/cassettes/Lita_Handlers_Pulp/_show_rpm_repo_detail/show_an_rpm_repo_detail.yml
186
+ - spec/fixtures/cassettes/Lita_Handlers_Pulp/_sync_repo/sync_a_repository.yml
187
+ - spec/fixtures/cassettes/Lita_Handlers_Pulp/_sync_repo/syncs_a_repository.yml
185
188
  - spec/lita/handlers/pulp_repo_spec.rb
186
189
  - spec/lita/handlers/pulp_unit_spec.rb
187
190
  - spec/spec_helper.rb
@@ -217,6 +220,7 @@ test_files:
217
220
  - spec/fixtures/cassettes/Lita_Handlers_Pulp/_copy_puppet_between_repo/copy_puppet_module_delete_new_and_publish.yml
218
221
  - spec/fixtures/cassettes/Lita_Handlers_Pulp/_copy_rpm_between_repo/copy_rpm_package.yml
219
222
  - spec/fixtures/cassettes/Lita_Handlers_Pulp/_copy_rpm_between_repo/copy_rpm_package_delete_new_and_publish.yml
223
+ - spec/fixtures/cassettes/Lita_Handlers_Pulp/_publish_repo/publish_a_repository.yml
220
224
  - spec/fixtures/cassettes/Lita_Handlers_Pulp/_puppet_repos/list_puppet_repos.yml
221
225
  - spec/fixtures/cassettes/Lita_Handlers_Pulp/_puppet_search/search_puppet_with_repo.yml
222
226
  - spec/fixtures/cassettes/Lita_Handlers_Pulp/_puppet_search/search_puppet_without_author_name.yml
@@ -227,6 +231,8 @@ test_files:
227
231
  - spec/fixtures/cassettes/Lita_Handlers_Pulp/_show_repo_detail/show_a_puppet_repo_detail.yml
228
232
  - spec/fixtures/cassettes/Lita_Handlers_Pulp/_show_repo_detail/show_a_rpm_repo_detail.yml
229
233
  - spec/fixtures/cassettes/Lita_Handlers_Pulp/_show_rpm_repo_detail/show_an_rpm_repo_detail.yml
234
+ - spec/fixtures/cassettes/Lita_Handlers_Pulp/_sync_repo/sync_a_repository.yml
235
+ - spec/fixtures/cassettes/Lita_Handlers_Pulp/_sync_repo/syncs_a_repository.yml
230
236
  - spec/lita/handlers/pulp_repo_spec.rb
231
237
  - spec/lita/handlers/pulp_unit_spec.rb
232
238
  - spec/spec_helper.rb