lita-pulp 0.1.0 → 0.1.1

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: df5d209cbd637fa2e641a80918bce7306fcd3b59
4
- data.tar.gz: 4699d7f5ef9e5fffd707e4e430e0b8ebd291cabd
3
+ metadata.gz: 53bb22e0cf58e3709b3db64aebde429b738468ec
4
+ data.tar.gz: 8c3052b58f6c0a5e2cf5f91698c7b4cd6e359427
5
5
  SHA512:
6
- metadata.gz: 437604596ddb5d70685dde9956fa9ecd8a9e4697b870963c8897655ac54e0ebd86798c9665ff09c917b589d76ad35fa4c5df5f6d7abfd2c4daf20fcd97efad8c
7
- data.tar.gz: bce0fb5b4e7b3108fae5fe0e7ce98ee1d834373a08540ac605a2a9ba50f7c5d30945e1cf9c23c1f7f515289b9a4877a9adc43679bd0d5656850b6f6513b075c1
6
+ metadata.gz: a28398bfcdda019c4f473a537403fc87065afa566d9923172c58bbd60185ed7d5b87dae925728c92e695a4606d25f5e3bf76eeff6eb88504062e44a9310e1640
7
+ data.tar.gz: 0d781e000638c3595c8e4a37ff20d0f33662f0ef7df00b04d51fbcf7b9a196a362be4453aa31a26371c0f936852271f73c0175bc69eb549170ee8a1577b7d8e3
data/README.md CHANGED
@@ -29,6 +29,7 @@ end
29
29
  It can do following:
30
30
  - List all rpm repositories
31
31
  - List all puppet repositories
32
+ - Show a repository details
32
33
  - Search rpm package
33
34
  - Search puppet module
34
35
  - Copy rpm package from one repository to another
@@ -190,13 +190,22 @@ module Lita
190
190
  }
191
191
  )
192
192
 
193
+ route(
194
+ /^pulp\s+show\s+repo\s+(\S+)$/,
195
+ :show_repo,
196
+ command: true,
197
+ help: {
198
+ t('help.show_repo_key') => t('help.show_repo_value')
199
+ }
200
+ )
201
+
193
202
  def rpm_repos(response)
194
203
  begin
195
204
  result=list_repo(REPO_TYPE_RPM)
196
205
  #puts "********result"
197
206
  s = StringIO.new
198
207
  result.each do |r|
199
- s << "["<< r[:id] << "] : " << r[:name] << "," << r[:description] << "\n"
208
+ s << "["<< r[:id] << "] : " << r[:name] << ", " << r[:description] << "\n"
200
209
  end
201
210
  response.reply s.string
202
211
  rescue Exception => e
@@ -210,7 +219,7 @@ module Lita
210
219
  #response.reply result.to_json
211
220
  s = StringIO.new
212
221
  result.each do |r|
213
- s << "["<< r[:id] << "] : " << r[:name] << "," << r[:description] << "\n"
222
+ s << "["<< r[:id] << "] : " << r[:name] << ", " << r[:description] << "\n"
214
223
  end
215
224
  response.reply s.string
216
225
  rescue Exception => e
@@ -218,6 +227,15 @@ module Lita
218
227
  end
219
228
  end
220
229
 
230
+ def show_repo(response)
231
+ repo_id = response.matches[0][0]
232
+ begin
233
+ repo = get_repo(repo_id)
234
+ response.reply JSON.pretty_generate(repo)
235
+ rescue Exception => e
236
+ response.reply e.message
237
+ end
238
+ end
221
239
  def publish_repo(response)
222
240
  repo_id = response.matchs[0][0]
223
241
  if repo_id
@@ -249,7 +267,7 @@ module Lita
249
267
  result=search_rpm(name, repo)
250
268
  s = StringIO.new
251
269
  result.each do |r|
252
- s << "["<< r[:name] << "] : " << r[:version] << "," << r[:release] << "," << r[:repos] <<"\n"
270
+ s << "["<< r[:name] << "] : " << r[:version] << ", " << r[:release] << ", " << r[:repos] <<"\n"
253
271
  end
254
272
  response.reply s.string
255
273
  rescue StandardError => e
@@ -275,7 +293,7 @@ module Lita
275
293
  result=search_puppet(author, name, repo)
276
294
  s = StringIO.new
277
295
  result.each do |r|
278
- s << "["<< r[:author] << "/" << r[:name]<< "] :" <<r[:version] << "," << r[:repos] <<"\n"
296
+ s << "["<< r[:author] << "/" << r[:name]<< "] : " <<r[:version] << ", " << r[:repos] <<"\n"
279
297
  end
280
298
  response.reply s.string
281
299
  rescue StandardError => e
@@ -61,29 +61,20 @@ module PulpHelper
61
61
  # config :
62
62
  # importers:
63
63
  # importer_type_id: "puppet_importer"
64
- def list_repo_details(type)
65
- criteria = {
66
- "filters" => {
67
- "notes._repo-type" => {
68
- "$in" => [type]
69
- }
70
- }
71
- }
72
- #puts "criteria:#{criteria}"
73
- response=client.resources.repository.search(criteria, {"details" => true})
64
+ def get_repo(repo_id)
65
+ response=client.extensions.repository.retrieve_with_details(repo_id)
74
66
  code=response.code
75
67
  body=response.body
76
- result=[]
77
68
  case code
78
69
  when 200
79
- repos=JSON.parse(body.to_json)
70
+ repo=JSON.parse(body.to_json)
71
+ type = repo["notes"]["_repo-type"]
80
72
  #puts repos
81
- repos.each do |repo|
82
- case type
73
+ repo_data=nil
74
+ case type
83
75
  when REPO_TYPE_RPM
84
76
  yum_distributor = repo["distributors"].select{ |d| d["distributor_type_id"] == 'yum_distributor'}[0]
85
77
  yum_importer = repo["distributors"].select{ |d| d["distributor_type_id"] == 'yum_importer'}[0]
86
-
87
78
  distributor = nil
88
79
  if yum_distributor
89
80
  distributor = {
@@ -106,19 +97,20 @@ module PulpHelper
106
97
  :description => repo["description"],
107
98
  :content_unit_counts => repo["content_unit_counts"],
108
99
  :type => REPO_TYPE_RPM,
100
+ :last_unit_removed => repo["last_unit_removed"],
101
+ :last_unit_added => repo["last_unit_added"],
109
102
  :distributor => distributor,
110
103
  :importer => importer,
111
104
  }
112
105
  #puts repos
113
- result << repo_data
114
106
  when REPO_TYPE_PUPPET
115
107
  puppet_distributor = repo["distributors"].select{ |d| d["distributor_type_id"] == 'puppet_distributor'}[0]
116
108
  distributor =nil
117
109
  if puppet_distributor
118
110
  distributor = {
119
- :auto_publish => yum_distributor["auto_publish"],
120
- :last_publish => yum_distributor["last_publish"],
121
- :config => yum_distributor["config"]
111
+ :auto_publish => puppet_distributor["auto_publish"],
112
+ :last_publish => puppet_distributor["last_publish"],
113
+ :config => puppet_distributor["config"]
122
114
  }
123
115
  end
124
116
  repo_data={
@@ -127,17 +119,16 @@ module PulpHelper
127
119
  :description => repo["description"],
128
120
  :content_unit_counts => repo["content_unit_counts"],
129
121
  :type => REPO_TYPE_PUPPET,
122
+ :last_unit_removed => repo["last_unit_removed"],
123
+ :last_unit_added => repo["last_unit_added"],
130
124
  :distributor => distributor
131
125
  }
132
- #puts repos
133
- result << repo_data
134
126
  else
135
127
  end
136
- end
128
+ repo_data
137
129
  else
138
- raise "Exception: cannot list repository: response code :#{code}"
130
+ raise "Exception: cannot get repository detail: response code :#{code}"
139
131
  end
140
- return result
141
132
  end#list_repo_details
142
133
 
143
134
  def publish_repo!(forge_id)
data/lita-pulp.gemspec CHANGED
@@ -1,6 +1,7 @@
1
+
1
2
  Gem::Specification.new do |spec|
2
3
  spec.name = "lita-pulp"
3
- spec.version = "0.1.0"
4
+ spec.version = "0.1.1"
4
5
  spec.authors = ["Wang, Dawei"]
5
6
  spec.email = ["daweiwang.gatekeeper@gmail.com"]
6
7
  spec.description = "Lita bot for pulp server"
data/locales/en.yml CHANGED
@@ -18,6 +18,8 @@ en:
18
18
  copy_puppet_key: "pulp puppet copy --from SRC_REPO --to DEST_REPO --author author --name PACKAGE --version VERSION [--delete_new] [--publish]"
19
19
  copy_puppet_value: "Copy specified puppet module package from SRC_REPO to DEST_REPO, optionally delete newer version in DEST_REPO and publish the repo"
20
20
  delete_newer_rpm_key: "pulp rpm delete newer --from SRC_REPO --name PACKAGE --version VERSION --release RELEASE --arch ARCH [--publish] [--delete_new]"
21
- delete_newer_rpm_value: "Deletw newer version of specified rpm package from SRC_REPO , optionally publish the repo"
21
+ delete_newer_rpm_value: "Delete newer version of specified rpm package from SRC_REPO , optionally publish the repo"
22
22
  delete_newer_puppet_key: "pulp puppet delete newer --from SRC_REPO --author AUTHOR --name MODULE --version VERSION --arch ARCH [--publish] [--delete_new]"
23
- delete_newer_puppet_value: "Deletw newer version of specified puppet module from SRC_REPO , optionally publish the repo"
23
+ delete_newer_puppet_value: "Delete newer version of specified puppet module from SRC_REPO , optionally publish the repo"
24
+ show_repo_key: "pulp show repo REPO_ID"
25
+ show_repo_value: "Show details of REPO_ID"
@@ -0,0 +1,52 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://pulp.co.epi.web/pulp/api/v2/repositories/forge_dev/?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
+ - Wed, 29 Jun 2016 21:24:47 GMT
27
+ Server:
28
+ - Apache/2.2.15 (CentOS)
29
+ Content-Length:
30
+ - '1100'
31
+ Connection:
32
+ - close
33
+ Content-Type:
34
+ - application/json; charset=utf-8
35
+ body:
36
+ encoding: UTF-8
37
+ string: '{"scratchpad": {}, "display_name": "forge_dev", "description": null,
38
+ "distributors": [{"repo_id": "forge_dev", "_href": "/pulp/api/v2/repositories/forge_dev/distributors/puppet_distributor/",
39
+ "_ns": "repo_distributors", "last_publish": "2016-06-28T19:46:22Z", "distributor_type_id":
40
+ "puppet_distributor", "auto_publish": true, "scratchpad": {}, "_id": {"$oid":
41
+ "56ba3b59c20cde7c072e6778"}, "config": {}, "id": "puppet_distributor"}], "last_unit_added":
42
+ "2016-06-28T19:46:14Z", "notes": {"_repo-type": "puppet-repo"}, "last_unit_removed":
43
+ "2016-06-02T18:37:52Z", "content_unit_counts": {"puppet_module": 125}, "_ns":
44
+ "repos", "importers": [{"scratchpad": null, "_href": "/pulp/api/v2/repositories/forge_dev/importers/puppet_importer/",
45
+ "_ns": "repo_importers", "importer_type_id": "puppet_importer", "last_sync":
46
+ null, "repo_id": "forge_dev", "_id": {"$oid": "56ba3b59c20cde7c072e6777"},
47
+ "config": {}, "id": "puppet_importer"}], "locally_stored_units": 125, "_id":
48
+ {"$oid": "56ba3b58c20cde7c072e6776"}, "total_repository_units": 125, "id":
49
+ "forge_dev", "_href": "/pulp/api/v2/repositories/forge_dev/"}'
50
+ http_version:
51
+ recorded_at: Wed, 29 Jun 2016 21:24:48 GMT
52
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,57 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://pulp.co.epi.web/pulp/api/v2/repositories/ent-cent7-dev/?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
+ - Wed, 29 Jun 2016 21:24:47 GMT
27
+ Server:
28
+ - Apache/2.2.15 (CentOS)
29
+ Content-Length:
30
+ - '1619'
31
+ Connection:
32
+ - close
33
+ Content-Type:
34
+ - application/json; charset=utf-8
35
+ body:
36
+ encoding: UTF-8
37
+ string: '{"scratchpad": {}, "display_name": "ent-cent7-dev", "description":
38
+ null, "distributors": [{"repo_id": "ent-cent7-dev", "_href": "/pulp/api/v2/repositories/ent-cent7-dev/distributors/yum_distributor/",
39
+ "_ns": "repo_distributors", "last_publish": "2016-06-29T15:17:30Z", "distributor_type_id":
40
+ "yum_distributor", "auto_publish": true, "scratchpad": {}, "_id": {"$oid":
41
+ "56b50adac20cde71a43ebeaa"}, "config": {"checksum_type": "sha256", "http":
42
+ true, "https": true, "relative_url": "entertainment/dev/centos/7/x86_64"},
43
+ "id": "yum_distributor"}, {"repo_id": "ent-cent7-dev", "_href": "/pulp/api/v2/repositories/ent-cent7-dev/distributors/export_distributor/",
44
+ "_ns": "repo_distributors", "last_publish": "2016-06-29T15:19:01Z", "distributor_type_id":
45
+ "export_distributor", "auto_publish": false, "scratchpad": {}, "_id": {"$oid":
46
+ "56b50adac20cde71a43ebeab"}, "config": {"http": true, "relative_url": "entertainment/dev/centos/7/x86_64",
47
+ "https": true}, "id": "export_distributor"}], "last_unit_added": null, "notes":
48
+ {"_repo-type": "rpm-repo"}, "last_unit_removed": "2016-05-09T19:10:43Z", "content_unit_counts":
49
+ {"rpm": 65}, "_ns": "repos", "importers": [{"scratchpad": null, "_href": "/pulp/api/v2/repositories/ent-cent7-dev/importers/yum_importer/",
50
+ "_ns": "repo_importers", "importer_type_id": "yum_importer", "last_sync":
51
+ null, "repo_id": "ent-cent7-dev", "_id": {"$oid": "56b50adac20cde71a43ebea9"},
52
+ "config": {}, "id": "yum_importer"}], "locally_stored_units": 65, "_id": {"$oid":
53
+ "56b50adac20cde71a43ebea8"}, "total_repository_units": 65, "id": "ent-cent7-dev",
54
+ "_href": "/pulp/api/v2/repositories/ent-cent7-dev/"}'
55
+ http_version:
56
+ recorded_at: Wed, 29 Jun 2016 21:24:47 GMT
57
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,100 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://pulp.co.epi.web/pulp/api/v2/repositories/v/?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: 404
23
+ message: NOT FOUND
24
+ headers:
25
+ Date:
26
+ - Wed, 29 Jun 2016 21:19:57 GMT
27
+ Server:
28
+ - Apache/2.2.15 (CentOS)
29
+ Content-Encoding:
30
+ - utf-8
31
+ Content-Length:
32
+ - '374'
33
+ Connection:
34
+ - close
35
+ Content-Type:
36
+ - application/json; charset=utf-8
37
+ body:
38
+ encoding: UTF-8
39
+ string: '{"http_request_method": "GET", "exception": null, "error_message":
40
+ "Missing resource(s): repository=v", "_href": "/pulp/api/v2/repositories/v/?details=true",
41
+ "http_status": 404, "error": {"code": "PLP0009", "data": {"resources": {"repository":
42
+ "v"}}, "description": "Missing resource(s): repository=v", "sub_errors": []},
43
+ "traceback": null, "resources": {"repository": "v"}}'
44
+ http_version:
45
+ recorded_at: Wed, 29 Jun 2016 21:19:59 GMT
46
+ - request:
47
+ method: get
48
+ uri: https://pulp.co.epi.web/pulp/api/v2/repositories/ent-cent7-dev/?details=true
49
+ body:
50
+ encoding: US-ASCII
51
+ string: ''
52
+ headers:
53
+ Accept:
54
+ - application/json
55
+ Accept-Encoding:
56
+ - gzip, deflate
57
+ Content-Type:
58
+ - application/json
59
+ User-Agent:
60
+ - Ruby
61
+ Authorization:
62
+ - Basic YWRtaW46YWRtaW4=
63
+ response:
64
+ status:
65
+ code: 200
66
+ message: OK
67
+ headers:
68
+ Date:
69
+ - Wed, 29 Jun 2016 21:21:48 GMT
70
+ Server:
71
+ - Apache/2.2.15 (CentOS)
72
+ Content-Length:
73
+ - '1619'
74
+ Connection:
75
+ - close
76
+ Content-Type:
77
+ - application/json; charset=utf-8
78
+ body:
79
+ encoding: UTF-8
80
+ string: '{"scratchpad": {}, "display_name": "ent-cent7-dev", "description":
81
+ null, "distributors": [{"repo_id": "ent-cent7-dev", "_href": "/pulp/api/v2/repositories/ent-cent7-dev/distributors/yum_distributor/",
82
+ "_ns": "repo_distributors", "last_publish": "2016-06-29T15:17:30Z", "distributor_type_id":
83
+ "yum_distributor", "auto_publish": true, "scratchpad": {}, "_id": {"$oid":
84
+ "56b50adac20cde71a43ebeaa"}, "config": {"checksum_type": "sha256", "http":
85
+ true, "https": true, "relative_url": "entertainment/dev/centos/7/x86_64"},
86
+ "id": "yum_distributor"}, {"repo_id": "ent-cent7-dev", "_href": "/pulp/api/v2/repositories/ent-cent7-dev/distributors/export_distributor/",
87
+ "_ns": "repo_distributors", "last_publish": "2016-06-29T15:19:01Z", "distributor_type_id":
88
+ "export_distributor", "auto_publish": false, "scratchpad": {}, "_id": {"$oid":
89
+ "56b50adac20cde71a43ebeab"}, "config": {"http": true, "relative_url": "entertainment/dev/centos/7/x86_64",
90
+ "https": true}, "id": "export_distributor"}], "last_unit_added": null, "notes":
91
+ {"_repo-type": "rpm-repo"}, "last_unit_removed": "2016-05-09T19:10:43Z", "content_unit_counts":
92
+ {"rpm": 65}, "_ns": "repos", "importers": [{"scratchpad": null, "_href": "/pulp/api/v2/repositories/ent-cent7-dev/importers/yum_importer/",
93
+ "_ns": "repo_importers", "importer_type_id": "yum_importer", "last_sync":
94
+ null, "repo_id": "ent-cent7-dev", "_id": {"$oid": "56b50adac20cde71a43ebea9"},
95
+ "config": {}, "id": "yum_importer"}], "locally_stored_units": 65, "_id": {"$oid":
96
+ "56b50adac20cde71a43ebea8"}, "total_repository_units": 65, "id": "ent-cent7-dev",
97
+ "_href": "/pulp/api/v2/repositories/ent-cent7-dev/"}'
98
+ http_version:
99
+ recorded_at: Wed, 29 Jun 2016 21:21:49 GMT
100
+ recorded_with: VCR 3.0.3
@@ -32,4 +32,18 @@ describe Lita::Handlers::Pulp, lita_handler: true, :vcr => vcr_options do
32
32
  puts replies
33
33
  end
34
34
  end
35
+
36
+ describe '#show repo detail' do
37
+ it 'show a rpm repo detail' do
38
+ send_command('pulp show repo ent-cent7-dev')
39
+ puts "************"
40
+ puts replies
41
+ end
42
+ it 'show a puppet repo detail' do
43
+ send_command('pulp show repo forge_dev')
44
+ puts "************"
45
+ puts replies
46
+ end
47
+ end
48
+
35
49
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lita-pulp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wang, Dawei
@@ -179,6 +179,9 @@ files:
179
179
  - spec/fixtures/cassettes/Lita_Handlers_Pulp/_rpm_repos/list_rpm_repos.yml
180
180
  - spec/fixtures/cassettes/Lita_Handlers_Pulp/_rpm_search/search_rpm_with_repo.yml
181
181
  - spec/fixtures/cassettes/Lita_Handlers_Pulp/_rpm_search/search_rpm_without_repo.yml
182
+ - spec/fixtures/cassettes/Lita_Handlers_Pulp/_show_repo_detail/show_a_puppet_repo_detail.yml
183
+ - spec/fixtures/cassettes/Lita_Handlers_Pulp/_show_repo_detail/show_a_rpm_repo_detail.yml
184
+ - spec/fixtures/cassettes/Lita_Handlers_Pulp/_show_rpm_repo_detail/show_an_rpm_repo_detail.yml
182
185
  - spec/lita/handlers/pulp_repo_spec.rb
183
186
  - spec/lita/handlers/pulp_unit_spec.rb
184
187
  - spec/spec_helper.rb
@@ -221,6 +224,9 @@ test_files:
221
224
  - spec/fixtures/cassettes/Lita_Handlers_Pulp/_rpm_repos/list_rpm_repos.yml
222
225
  - spec/fixtures/cassettes/Lita_Handlers_Pulp/_rpm_search/search_rpm_with_repo.yml
223
226
  - spec/fixtures/cassettes/Lita_Handlers_Pulp/_rpm_search/search_rpm_without_repo.yml
227
+ - spec/fixtures/cassettes/Lita_Handlers_Pulp/_show_repo_detail/show_a_puppet_repo_detail.yml
228
+ - spec/fixtures/cassettes/Lita_Handlers_Pulp/_show_repo_detail/show_a_rpm_repo_detail.yml
229
+ - spec/fixtures/cassettes/Lita_Handlers_Pulp/_show_rpm_repo_detail/show_an_rpm_repo_detail.yml
224
230
  - spec/lita/handlers/pulp_repo_spec.rb
225
231
  - spec/lita/handlers/pulp_unit_spec.rb
226
232
  - spec/spec_helper.rb