Project

General

Profile

« Previous | Next » 

Revision 1a2d49fd

Added by Justin Sherrill over 7 years ago

Fixes #16466 - Add support for applicable rpms

View differences:

lib/runcible/extensions/consumer.rb
# Retrieve the set of errata that is applicable to a consumer(s)
#
# @param [String, Array] ids string containing a single consumer id or an array of ids
# @param [Array] repoids array of repository ids
# @param [Boolean] consumer_report if true, result will list consumers and their
# applicable errata; otherwise, it will list
# errata and the consumers they are applicable to
# @return [RestClient::Response] content applicability hash with details of errata available to consumer(s)
def applicable_errata(ids)
applicable_for_type(ids, Runcible::Extensions::Errata.content_type)
end
# Retrieve the set of rpms that are applicable to a consumer(s)
#
# @param [String, Array] ids string containing a single consumer id or an array of ids
# @return [RestClient::Response] content applicability hash with details of rpms available to consumer(s)
def applicable_rpms(ids)
applicable_for_type(ids, Runcible::Extensions::Rpm.content_type)
end
private
def applicable_for_type(ids, type)
ids = [ids] if ids.is_a? String
criteria = {
'criteria' => { 'filters' => { 'id' => { '$in' => ids } } },
'content_types' => [Runcible::Extensions::Errata.content_type]
'content_types' => [type]
}
applicability(criteria)
end
private
def repository_extension
Runcible::Extensions::Repository.new(self.config)
end
test/extensions/consumer_test.rb
assert_equal 200, response.code
end
def test_applicable_rpms
response = @extension.applicable_rpms([@consumer_id])
assert_equal 200, response.code
end
end
class TestConsumerApplicabilityScenario < MiniTest::Unit::TestCase
test/fixtures/vcr_cassettes/extensions/consumer/applicable_rpms.yml
---
http_interactions:
- request:
method: delete
uri: https://admin:rGox3G9QhfCRD8fTsNR7FxqdgbvfJfSJ@abed.usersys.redhat.com/pulp/api/v2/consumers/integration_test_consumer_support/
body:
encoding: US-ASCII
string: ''
headers:
Accept:
- application/json
Accept-Encoding:
- gzip, deflate
Content-Type:
- application/json
User-Agent:
- Ruby
response:
status:
code: 404
message: NOT FOUND
headers:
Date:
- Wed, 07 Sep 2016 00:43:18 GMT
Server:
- Apache/2.4.6 (CentOS)
Content-Length:
- '513'
Connection:
- close
Content-Type:
- application/json; charset=utf-8
body:
encoding: UTF-8
string: '{"http_request_method": "DELETE", "exception": null, "error_message":
"Missing resource(s): consumer=integration_test_consumer_support", "_href":
"/pulp/api/v2/consumers/integration_test_consumer_support/", "http_status":
404, "error": {"code": "PLP0009", "data": {"resources": {"consumer": "integration_test_consumer_support"}},
"description": "Missing resource(s): consumer=integration_test_consumer_support",
"sub_errors": []}, "traceback": null, "resources": {"consumer": "integration_test_consumer_support"}}'
http_version:
recorded_at: Wed, 07 Sep 2016 00:43:18 GMT
- request:
method: delete
uri: https://admin:rGox3G9QhfCRD8fTsNR7FxqdgbvfJfSJ@abed.usersys.redhat.com/pulp/api/v2/consumers/integration_test_consumer_support/
body:
encoding: US-ASCII
string: ''
headers:
Accept:
- application/json
Accept-Encoding:
- gzip, deflate
Content-Type:
- application/json
User-Agent:
- Ruby
response:
status:
code: 404
message: NOT FOUND
headers:
Date:
- Wed, 07 Sep 2016 00:43:18 GMT
Server:
- Apache/2.4.6 (CentOS)
Content-Length:
- '513'
Connection:
- close
Content-Type:
- application/json; charset=utf-8
body:
encoding: UTF-8
string: '{"http_request_method": "DELETE", "exception": null, "error_message":
"Missing resource(s): consumer=integration_test_consumer_support", "_href":
"/pulp/api/v2/consumers/integration_test_consumer_support/", "http_status":
404, "error": {"code": "PLP0009", "data": {"resources": {"consumer": "integration_test_consumer_support"}},
"description": "Missing resource(s): consumer=integration_test_consumer_support",
"sub_errors": []}, "traceback": null, "resources": {"consumer": "integration_test_consumer_support"}}'
http_version:
recorded_at: Wed, 07 Sep 2016 00:43:18 GMT
- request:
method: post
uri: https://admin:rGox3G9QhfCRD8fTsNR7FxqdgbvfJfSJ@abed.usersys.redhat.com/pulp/api/v2/consumers/
body:
encoding: UTF-8
string: '{"id":"integration_test_consumer_support"}'
headers:
Accept:
- application/json
Accept-Encoding:
- gzip, deflate
Content-Type:
- application/json
Content-Length:
- '42'
User-Agent:
- Ruby
response:
status:
code: 201
message: CREATED
headers:
Date:
- Wed, 07 Sep 2016 00:43:18 GMT
Server:
- Apache/2.4.6 (CentOS)
Content-Length:
- '2277'
Location:
- https://abed.usersys.redhat.com/pulp/api/v2/consumers/integration_test_consumer_support/
Connection:
- close
Content-Type:
- application/json; charset=utf-8
body:
encoding: UTF-8
string: '{"consumer": {"display_name": "integration_test_consumer_support",
"description": null, "_ns": "consumers", "notes": {}, "rsa_pub": null, "capabilities":
{}, "_id": {"$oid": "57cf62a65ca0131f92a6c584"}, "id": "integration_test_consumer_support",
"_href": "/pulp/api/v2/consumers/integration_test_consumer_support/"}, "certificate":
"-----BEGIN RSA PRIVATE KEY-----\nMIICXAIBAAKBgQCkfOT6Cr+FfPTZiH1wmpAGSEwqI5Pi4dmjKF+QPt5t7OLrbivp\n9b3IQ7Qlv/C+Ab8hGIj77/SbnviWPvtcEgKCC61vn/YNJUp1iiiXFNI7XGf80MQg\nGx19Wjv5tqwL82Xmvv4AGPL6Ju9MLqT797/gc8vSj4tFetCpt2jJ08l5rwIDAQAB\nAoGAZpHnKzC2myP/fwLIzgXj17cPn5tN5cXWNBLB/K3nf/6exhaOVbdCn/XwCTY2\nhhWKvLWS/h90lfI8q1wc3B3y52r3mGjmnRjSVzrmHADERmBH3YXigWJz2+1TAKEG\nnEza1ZKISCO8LHL//Za8E/59ymjrIMCKYr8w+4DtSqazk9ECQQDWro96JslDkDjg\nGnpG94jZcVw1Q2Jnfm+VpFm8w2bDzA8X3BH6Q58j/9tO4pxVhOSTUqUdYIVh0uBd\n7rpKkozpAkEAxCVCp9+gmIViqVuQYTsdhq0zCp4UuXh2uuiCQ8s1J1ZslRx9FPRm\nDEXDtSVWY/JTZwNRd6KCDABE4Wybl27S1wJBAKPV/jtLpGeChlVI/65vNKo1YBhp\n/4xaKpA6KB3txdyBO7eKxNGIj8fqeBUAzixZyhNAjDAaPFDGnWIyUUueAhkCQG7e\ncNLbALe1jZMVAoMzGvlpJRS3TheYE+SKUDdpwV2+6BlQxRL3IkeFl53owPA1pRbx\nNTdeUAvgiw6wiTILnnkCQBgzeZaTUF0S8De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2i7NucrtBh9Wfs68Kuty1uXFUWmWTfRcDKvl6Ombdl8SR3\n-----END
CERTIFICATE-----"}'
http_version:
recorded_at: Wed, 07 Sep 2016 00:43:18 GMT
- request:
method: post
uri: https://admin:rGox3G9QhfCRD8fTsNR7FxqdgbvfJfSJ@abed.usersys.redhat.com/pulp/api/v2/consumers/integration_test_consumer_support/profiles//
body:
encoding: UTF-8
string: '{"content_type":"rpm","profile":[{"name":"elephant","version":"0.2","release":"0.7","epoch":0,"arch":"noarch","vendor":"Fedora"}]}'
headers:
Accept:
- application/json
Accept-Encoding:
- gzip, deflate
Content-Type:
- application/json
Content-Length:
- '130'
User-Agent:
- Ruby
response:
status:
code: 201
message: CREATED
headers:
Date:
- Wed, 07 Sep 2016 00:43:18 GMT
Server:
- Apache/2.4.6 (CentOS)
Content-Length:
- '475'
Location:
- https://abed.usersys.redhat.com/pulp/api/v2/consumers/integration_test_consumer_support/profiles/rpm/
Connection:
- close
Content-Type:
- application/json; charset=utf-8
body:
encoding: UTF-8
string: '{"profile": [{"vendor": "Fedora", "name": "elephant", "epoch": 0, "version":
"0.2", "release": "0.7", "arch": "noarch"}], "_href": "/pulp/api/v2/consumers/integration_test_consumer_support/profiles/rpm/",
"_ns": "consumer_unit_profiles", "profile_hash": "db16b75e977ae3fbbf27beb919693137b26ba59eb7be73f2888197b89521e50d",
"consumer_id": "integration_test_consumer_support", "content_type": "rpm",
"_id": {"$oid": "57cf62a75ca0131f92a6c586"}, "id": "57cf62a75ca0131f92a6c586"}'
http_version:
recorded_at: Wed, 07 Sep 2016 00:43:19 GMT
- request:
method: get
uri: https://admin:rGox3G9QhfCRD8fTsNR7FxqdgbvfJfSJ@abed.usersys.redhat.com/pulp/api/v2/repositories/integration_test_id/?details=true
body:
encoding: US-ASCII
string: ''
headers:
Accept:
- application/json
Accept-Encoding:
- gzip, deflate
Content-Type:
- application/json
User-Agent:
- Ruby
response:
status:
code: 200
message: OK
headers:
Date:
- Wed, 07 Sep 2016 00:43:19 GMT
Server:
- Apache/2.4.6 (CentOS)
Vary:
- Accept-Encoding
Content-Length:
- '1257'
Connection:
- close
Content-Type:
- application/json; charset=utf-8
body:
encoding: ASCII-8BIT
string: '{"scratchpad": {"checksum_type": "sha256"}, "display_name": "integration_test_id",
"description": null, "distributors": [{"repo_id": "integration_test_id", "_href":
"/pulp/api/v2/repositories/integration_test_id/distributors/yum_dist/", "_ns":
"repo_distributors", "last_publish": null, "distributor_type_id": "yum_distributor",
"auto_publish": false, "scratchpad": {}, "_id": {"$oid": "57cf5cc45ca0131f93207bfe"},
"config": {"http": true, "https": true, "relative_url": "path"}, "id": "yum_dist"}],
"last_unit_added": null, "notes": {}, "last_unit_removed": null, "content_unit_counts":
{"package_group": 2, "distribution": 1, "package_category": 1, "rpm": 8, "erratum":
2}, "_ns": "repos", "importers": [{"scratchpad": null, "_href": "/pulp/api/v2/repositories/integration_test_id/importers/yum_importer/",
"_ns": "repo_importers", "importer_type_id": "yum_importer", "last_sync":
"2016-09-07T00:19:27Z", "repo_id": "integration_test_id", "_id": {"$oid":
"57cf5cc45ca0131f93207bfd"}, "config": {"feed": "file:///var/www/repositories/zoo5"},
"id": "yum_importer"}], "locally_stored_units": 14, "_id": {"$oid": "57cf5cc45ca0131f93207bfc"},
"total_repository_units": 14, "id": "integration_test_id", "_href": "/pulp/api/v2/repositories/integration_test_id/"}'
http_version:
recorded_at: Wed, 07 Sep 2016 00:43:21 GMT
- request:
method: post
uri: https://admin:rGox3G9QhfCRD8fTsNR7FxqdgbvfJfSJ@abed.usersys.redhat.com/pulp/api/v2/consumers/integration_test_consumer_support/bindings//
body:
encoding: UTF-8
string: '{"repo_id":"integration_test_id","distributor_id":"yum_dist","notify_agent":false}'
headers:
Accept:
- application/json
Accept-Encoding:
- gzip, deflate
Content-Type:
- application/json
Content-Length:
- '82'
User-Agent:
- Ruby
response:
status:
code: 200
message: OK
headers:
Date:
- Wed, 07 Sep 2016 00:43:21 GMT
Server:
- Apache/2.4.6 (CentOS)
Vary:
- Accept-Encoding
Content-Length:
- '358'
Connection:
- close
Content-Type:
- application/json; charset=utf-8
body:
encoding: ASCII-8BIT
string: '{"spawned_tasks": [], "result": {"notify_agent": false, "repo_id":
"integration_test_id", "deleted": false, "_ns": "consumer_bindings", "distributor_id":
"yum_dist", "consumer_id": "integration_test_consumer_support", "consumer_actions":
[], "binding_config": {}, "_id": {"$oid": "57cf62a95ca0131f9432cf39"}, "id":
"57cf62a95ca0131f9432cf39"}, "error": null}'
http_version:
recorded_at: Wed, 07 Sep 2016 00:43:21 GMT
- request:
method: post
uri: https://admin:rGox3G9QhfCRD8fTsNR7FxqdgbvfJfSJ@abed.usersys.redhat.com/pulp/api/v2/consumers/content/applicability/
body:
encoding: UTF-8
string: '{"criteria":{"filters":{"id":{"$in":["integration_test_consumer_support"]}}},"content_types":["rpm"]}'
headers:
Accept:
- application/json
Accept-Encoding:
- gzip, deflate
Content-Type:
- application/json
Content-Length:
- '101'
User-Agent:
- Ruby
response:
status:
code: 200
message: OK
headers:
Date:
- Wed, 07 Sep 2016 00:43:21 GMT
Server:
- Apache/2.4.6 (CentOS)
Vary:
- Accept-Encoding
Content-Length:
- '122'
Connection:
- close
Content-Type:
- application/json; charset=utf-8
body:
encoding: ASCII-8BIT
string: '[{"applicability": {"rpm": ["904206a3-d520-4f57-b84a-78b3af1597cd"]},
"consumers": ["integration_test_consumer_support"]}]'
http_version:
recorded_at: Wed, 07 Sep 2016 00:43:21 GMT
- request:
method: delete
uri: https://admin:rGox3G9QhfCRD8fTsNR7FxqdgbvfJfSJ@abed.usersys.redhat.com/pulp/api/v2/consumers/integration_test_consumer_support/
body:
encoding: US-ASCII
string: ''
headers:
Accept:
- application/json
Accept-Encoding:
- gzip, deflate
Content-Type:
- application/json
User-Agent:
- Ruby
response:
status:
code: 200
message: OK
headers:
Date:
- Wed, 07 Sep 2016 00:43:21 GMT
Server:
- Apache/2.4.6 (CentOS)
Content-Length:
- '4'
Connection:
- close
Content-Type:
- application/json; charset=utf-8
body:
encoding: UTF-8
string: 'null'
http_version:
recorded_at: Wed, 07 Sep 2016 00:43:21 GMT
recorded_with: VCR 3.0.1

Also available in: Unified diff