rh_entitlement 0.2.1 → 0.3.0
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 +4 -4
- data/README.md +87 -5
- data/bin/rh-entitlement +75 -0
- metadata +3 -3
- data/bin/rh-entitlement-urls +0 -8
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4b4626c081a3b41b31db30460f3ab389cc489bd6
|
|
4
|
+
data.tar.gz: ee952e2170e9ec2fc6abd75a5d16cafea63e6131
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f2e0371685f5faeae6f3049ecc1e1c3931dd2550cf8185611b14cade8562b2a02d3b64ab4badca8c32a48d4e23747cec17bd44ce8e7958b9c8f78a58ccb767b0
|
|
7
|
+
data.tar.gz: c8482998f6ea3c160b146e59532599d390f2e061e6154ba762e3efc7f98a0f707b12a7008091f6bcab5c0f04d3c3388695cd40512a7638114b094f4f6e94823a
|
data/README.md
CHANGED
|
@@ -5,18 +5,100 @@ your RedHat entitlement certificates. This is helpful when dealing with multiple
|
|
|
5
5
|
RH subscriptions and the requirement to figure out which certificate / which ID
|
|
6
6
|
to use for what repository.
|
|
7
7
|
|
|
8
|
+
It can be used as a library and ships a related CLI command.
|
|
9
|
+
|
|
8
10
|
## Installation
|
|
9
11
|
|
|
10
|
-
|
|
12
|
+
gem install rh_entitlement
|
|
13
|
+
|
|
14
|
+
**Requires Ruby 1.9.3 or later.**
|
|
15
|
+
|
|
16
|
+
## Usage
|
|
17
|
+
|
|
18
|
+
### CLI command
|
|
11
19
|
|
|
12
|
-
```ruby
|
|
13
|
-
gem "rh_entitlement"
|
|
14
20
|
```
|
|
21
|
+
usage: rh-entitlement <command> [<args>]
|
|
15
22
|
|
|
16
|
-
|
|
23
|
+
commands:
|
|
17
24
|
|
|
25
|
+
urls List all repository URLs in the given certificate
|
|
26
|
+
find Find the best certificate for a given repository URL
|
|
18
27
|
|
|
19
|
-
|
|
28
|
+
urls
|
|
29
|
+
----
|
|
30
|
+
usage: rh-entitlement urls <cert-file>
|
|
31
|
+
|
|
32
|
+
cert-file:
|
|
33
|
+
Absolute paths to an entitlement certificate file, like
|
|
34
|
+
/etc/pki/entitlement/9999999999.pem
|
|
35
|
+
|
|
36
|
+
find
|
|
37
|
+
----
|
|
38
|
+
usage: rh-entitlement find <repo-url> [<cert-file>[ ...]]
|
|
39
|
+
|
|
40
|
+
repo-url:
|
|
41
|
+
Relative repository URL, like
|
|
42
|
+
/content/beta/rhel/server/5/$releasever/$basearch/highavailability/os
|
|
43
|
+
|
|
44
|
+
cert-file:
|
|
45
|
+
One or more absolute paths to entitlement certificate files. All <numeric>.pem
|
|
46
|
+
files in /etc/pki/entitlement will be used if no <cert-file> has been given
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
#### Examples
|
|
50
|
+
|
|
51
|
+
##### List repository URLs
|
|
52
|
+
|
|
53
|
+
Get all URLs from a specific entitlement certificate:
|
|
54
|
+
|
|
55
|
+
rh-entitlement urls /etc/pki/entitlement/9999999999.pem
|
|
56
|
+
|
|
57
|
+
Sample output:
|
|
58
|
+
|
|
59
|
+
```
|
|
60
|
+
Type: Basic
|
|
61
|
+
/content/beta/rhel/server/5/$releasever/$basearch/highavailability/debug
|
|
62
|
+
/content/beta/rhel/server/5/$releasever/$basearch/highavailability/os
|
|
63
|
+
/content/beta/rhel/server/5/$releasever/$basearch/highavailability/source/SRPMS
|
|
64
|
+
/content/beta/rhel/server/6/$releasever/$basearch/highavailability/debug
|
|
65
|
+
/content/beta/rhel/server/6/$releasever/$basearch/highavailability/os
|
|
66
|
+
/content/beta/rhel/server/6/$releasever/$basearch/highavailability/source/SRPMS
|
|
67
|
+
/content/beta/rhel/server/7/$basearch/highavailability/debug
|
|
68
|
+
/content/beta/rhel/server/7/$basearch/highavailability/os
|
|
69
|
+
/content/beta/rhel/server/7/$basearch/highavailability/source/SRPMS
|
|
70
|
+
...
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
##### Certificate lookup
|
|
74
|
+
|
|
75
|
+
Find the correct certificate for a specific repository URL:
|
|
76
|
+
|
|
77
|
+
```sh
|
|
78
|
+
rh-entitlement find-cert \
|
|
79
|
+
'/content/beta/rhel/server/6/$releasever/$basearch/highavailability/os' \
|
|
80
|
+
/etc/pki/entitlement/*.pem
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
When a matching certificate has been found, the script exits with code 0 and
|
|
84
|
+
outputs the certificate path on a single line:
|
|
85
|
+
|
|
86
|
+
/etc/pki/entitlement/9999999999.pem
|
|
87
|
+
|
|
88
|
+
In case there was no matching certificate, an error message is shown, exit code
|
|
89
|
+
is 1:
|
|
90
|
+
|
|
91
|
+
ERROR: no certificate has been found for /content/beta/rhel/...
|
|
92
|
+
|
|
93
|
+
### As a library
|
|
94
|
+
|
|
95
|
+
Add `rh_entitlement` to your Gemfile and run the `bundle` command to install it:
|
|
96
|
+
|
|
97
|
+
```ruby
|
|
98
|
+
gem "rh_entitlement"
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
#### Sample code
|
|
20
102
|
|
|
21
103
|
```ruby
|
|
22
104
|
require 'rh_entitlement'
|
data/bin/rh-entitlement
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require 'rh_entitlement'
|
|
4
|
+
|
|
5
|
+
def help_generic
|
|
6
|
+
<<-END
|
|
7
|
+
usage: #{File.basename($0)} <command> [<args>]
|
|
8
|
+
|
|
9
|
+
commands:
|
|
10
|
+
|
|
11
|
+
urls List all repository URLs in the given certificate
|
|
12
|
+
find Find the best certificate for a given repository URL
|
|
13
|
+
|
|
14
|
+
urls
|
|
15
|
+
----
|
|
16
|
+
usage: #{File.basename($0)} urls <cert-file>
|
|
17
|
+
|
|
18
|
+
cert-file:
|
|
19
|
+
Absolute paths to an entitlement certificate file, like
|
|
20
|
+
/etc/pki/entitlement/9999999999.pem
|
|
21
|
+
|
|
22
|
+
find
|
|
23
|
+
----
|
|
24
|
+
usage: #{File.basename($0)} find <repo-url> [<cert-file>[ ...]]
|
|
25
|
+
|
|
26
|
+
repo-url:
|
|
27
|
+
Relative repository URL, like
|
|
28
|
+
/content/beta/rhel/server/5/$releasever/$basearch/highavailability/os
|
|
29
|
+
|
|
30
|
+
cert-file:
|
|
31
|
+
One or more absolute paths to entitlement certificate files. All <numeric>.pem
|
|
32
|
+
files in /etc/pki/entitlement will be used if no <cert-file> has been given
|
|
33
|
+
END
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def usage_error(msg)
|
|
37
|
+
puts "ERROR: #{msg}"
|
|
38
|
+
puts
|
|
39
|
+
puts help_generic
|
|
40
|
+
exit 64
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
opts = ARGV.clone
|
|
44
|
+
usage_error '<command> is required' unless opts.length > 0
|
|
45
|
+
command = opts.shift
|
|
46
|
+
|
|
47
|
+
case command
|
|
48
|
+
when 'urls'
|
|
49
|
+
cert = RhEntitlement::Certificate.new(File.read(opts[0]))
|
|
50
|
+
puts "Type: #{cert.type}"
|
|
51
|
+
puts cert.urls.list.join("\n")
|
|
52
|
+
when 'find'
|
|
53
|
+
usage_error '<repo_url> is required' unless opts.length > 0
|
|
54
|
+
repo_url = opts.shift
|
|
55
|
+
usage_error 'Invalid <repo_url>' unless repo_url.match(/^\/content\//)
|
|
56
|
+
|
|
57
|
+
if opts.length == 0
|
|
58
|
+
cert_files = Dir.glob('/etc/pki/entitlement/*.pem').grep(/\/\d+\.pem$/)
|
|
59
|
+
else
|
|
60
|
+
cert_files = opts
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
cert_files.each do |file|
|
|
64
|
+
cert = RhEntitlement::Certificate.new(File.read(file))
|
|
65
|
+
if cert.urls.has? repo_url
|
|
66
|
+
puts file
|
|
67
|
+
exit 0
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
puts "ERROR: no certificate has been found for #{repo_url}"
|
|
72
|
+
exit 1
|
|
73
|
+
else
|
|
74
|
+
usage_error 'Invalid <command>'
|
|
75
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rh_entitlement
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Thomas Gelf
|
|
@@ -13,13 +13,13 @@ dependencies: []
|
|
|
13
13
|
description: Helper library allowing one to deal with RH entitlement certs
|
|
14
14
|
email: thomas@gelf.net
|
|
15
15
|
executables:
|
|
16
|
-
- rh-entitlement
|
|
16
|
+
- rh-entitlement
|
|
17
17
|
extensions: []
|
|
18
18
|
extra_rdoc_files: []
|
|
19
19
|
files:
|
|
20
20
|
- LICENSE
|
|
21
21
|
- README.md
|
|
22
|
-
- bin/rh-entitlement
|
|
22
|
+
- bin/rh-entitlement
|
|
23
23
|
- lib/rh_entitlement.rb
|
|
24
24
|
- lib/rh_entitlement/certificate.rb
|
|
25
25
|
- lib/rh_entitlement/certificate_urls.rb
|
data/bin/rh-entitlement-urls
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
|
|
3
|
-
require 'rh_entitlement'
|
|
4
|
-
|
|
5
|
-
raise "USAGE: #{File.basename($0)} /path/to/certificate.pem" unless ARGV.length > 0
|
|
6
|
-
cert = RhEntitlement::Certificate.new(File.read(ARGV[0]))
|
|
7
|
-
puts "Type: #{cert.type}"
|
|
8
|
-
puts "URLs:\n#{cert.urls.list.join("\n")}"
|