knife-rhn 0.1.0 → 0.2.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.
- data/README.md +69 -9
- data/lib/chef/knife/rhn_base.rb +98 -0
- data/lib/chef/knife/rhn_system_delete.rb +29 -27
- data/lib/chef/knife/rhn_system_details.rb +52 -50
- data/lib/chef/knife/rhn_system_move.rb +34 -32
- data/lib/chef/knife/rhn_system_systemgroups.rb +24 -22
- data/lib/chef/knife/rhn_systemgroup_active.rb +36 -33
- data/lib/chef/knife/rhn_systemgroup_add.rb +27 -25
- data/lib/chef/knife/rhn_systemgroup_create.rb +22 -20
- data/lib/chef/knife/rhn_systemgroup_delete.rb +20 -18
- data/lib/chef/knife/rhn_systemgroup_inactive.rb +47 -45
- data/lib/chef/knife/rhn_systemgroup_list.rb +16 -14
- data/lib/chef/knife/rhn_systemgroup_outdated.rb +23 -21
- data/lib/chef/knife/rhn_systemgroup_remove.rb +27 -25
- data/lib/chef/knife/rhn_systemgroup_systems.rb +23 -21
- data/lib/knife-rhn/version.rb +2 -1
- metadata +35 -52
- data/lib/chef/knife/BaseRHNCommand.rb +0 -93
@@ -3,35 +3,37 @@
|
|
3
3
|
# License:: Apache License, Version 2.0
|
4
4
|
#
|
5
5
|
|
6
|
-
|
6
|
+
require 'chef/knife/rhn_base'
|
7
7
|
|
8
|
-
|
8
|
+
class Chef
|
9
|
+
class Knife
|
10
|
+
class RhnSystemgroupOutdated < Knife
|
9
11
|
|
10
|
-
|
12
|
+
include Knife::RhnBase
|
11
13
|
|
12
|
-
|
13
|
-
|
14
|
+
banner "knife rhn systemgroup outdated GROUP (options)"
|
15
|
+
category "rhn"
|
14
16
|
|
15
|
-
|
17
|
+
def run
|
18
|
+
$stdout.sync = true
|
19
|
+
|
20
|
+
group = name_args.first
|
16
21
|
|
17
|
-
|
18
|
-
|
19
|
-
|
22
|
+
if group.nil?
|
23
|
+
ui.fatal "You need a systemgroup name!"
|
24
|
+
show_usage
|
25
|
+
exit 1
|
26
|
+
end
|
20
27
|
|
21
|
-
|
22
|
-
ui.fatal "You need a systemgroup name!"
|
23
|
-
show_usage
|
24
|
-
exit 1
|
25
|
-
end
|
26
|
-
|
27
|
-
set_rhn_connection_options
|
28
|
+
set_rhn_connection_options
|
28
29
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
30
|
+
systems = RhnSatellite::Systemgroup.systems(group)
|
31
|
+
systems.sort! {|a,b| a['profile_name'] <=> b['profile_name']}
|
32
|
+
systems.each do |system|
|
33
|
+
ui.info "#{system['id']},#{system['profile_name']}" unless RhnSatellite::System.uptodate?(system['id'])
|
34
|
+
end
|
33
35
|
end
|
34
|
-
end
|
35
36
|
|
37
|
+
end
|
36
38
|
end
|
37
39
|
end
|
@@ -3,41 +3,43 @@
|
|
3
3
|
# License:: Apache License, Version 2.0
|
4
4
|
#
|
5
5
|
|
6
|
-
|
6
|
+
require 'chef/knife/rhn_base'
|
7
7
|
|
8
|
-
|
8
|
+
class Chef
|
9
|
+
class Knife
|
10
|
+
class RhnSystemgroupRemove < Knife
|
9
11
|
|
10
|
-
|
12
|
+
include Knife::RhnBase
|
11
13
|
|
12
|
-
|
13
|
-
|
14
|
+
banner "knife rhn systemgroup remove GROUP SYSTEM (options)"
|
15
|
+
category "rhn"
|
14
16
|
|
15
|
-
|
17
|
+
def run
|
18
|
+
$stdout.sync = true
|
19
|
+
|
20
|
+
group = name_args.first
|
16
21
|
|
17
|
-
|
18
|
-
|
19
|
-
|
22
|
+
if group.nil?
|
23
|
+
ui.fatal "You need a systemgroup name!"
|
24
|
+
show_usage
|
25
|
+
exit 1
|
26
|
+
end
|
20
27
|
|
21
|
-
|
22
|
-
ui.fatal "You need a systemgroup name!"
|
23
|
-
show_usage
|
24
|
-
exit 1
|
25
|
-
end
|
28
|
+
system = name_args[1]
|
26
29
|
|
27
|
-
|
30
|
+
if system.nil?
|
31
|
+
ui.fatal "You need a system name!"
|
32
|
+
show_usage
|
33
|
+
exit 1
|
34
|
+
end
|
28
35
|
|
29
|
-
|
30
|
-
ui.fatal "You need a system name!"
|
31
|
-
show_usage
|
32
|
-
exit 1
|
33
|
-
end
|
36
|
+
set_rhn_connection_options
|
34
37
|
|
35
|
-
|
38
|
+
satellite_system = get_satellite_system(system)
|
39
|
+
RhnSatellite::Systemgroup.remove_systems(group,[satellite_system['id']])
|
40
|
+
ui.info "Removed #{system} (ID: #{satellite_system['id']}) from RHN systemgroup: #{group}"
|
41
|
+
end
|
36
42
|
|
37
|
-
satellite_system = get_satellite_system(system)
|
38
|
-
RhnSatellite::Systemgroup.remove_systems(group,[satellite_system['id']])
|
39
|
-
ui.info "Removed #{system} (ID: #{satellite_system['id']}) from RHN systemgroup: #{group}"
|
40
43
|
end
|
41
|
-
|
42
44
|
end
|
43
45
|
end
|
@@ -3,35 +3,37 @@
|
|
3
3
|
# License:: Apache License, Version 2.0
|
4
4
|
#
|
5
5
|
|
6
|
-
|
6
|
+
require 'chef/knife/rhn_base'
|
7
7
|
|
8
|
-
|
8
|
+
class Chef
|
9
|
+
class Knife
|
10
|
+
class RhnSystemgroupSystems < Knife
|
9
11
|
|
10
|
-
|
12
|
+
include Knife::RhnBase
|
11
13
|
|
12
|
-
|
13
|
-
|
14
|
+
banner "knife rhn systemgroup systems GROUP (options)"
|
15
|
+
category "rhn"
|
14
16
|
|
15
|
-
|
17
|
+
def run
|
18
|
+
$stdout.sync = true
|
19
|
+
|
20
|
+
group = name_args.first
|
16
21
|
|
17
|
-
|
18
|
-
|
19
|
-
|
22
|
+
if group.nil?
|
23
|
+
ui.fatal "You need a systemgroup name!"
|
24
|
+
show_usage
|
25
|
+
exit 1
|
26
|
+
end
|
20
27
|
|
21
|
-
|
22
|
-
ui.fatal "You need a systemgroup name!"
|
23
|
-
show_usage
|
24
|
-
exit 1
|
25
|
-
end
|
26
|
-
|
27
|
-
set_rhn_connection_options
|
28
|
+
set_rhn_connection_options
|
28
29
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
30
|
+
systems = RhnSatellite::Systemgroup.systems(group)
|
31
|
+
systems.sort! {|a,b| a['profile_name'] <=> b['profile_name']}
|
32
|
+
systems.each do |system|
|
33
|
+
ui.info "#{system['id']},#{system['profile_name']}"
|
34
|
+
end
|
33
35
|
end
|
34
|
-
end
|
35
36
|
|
37
|
+
end
|
36
38
|
end
|
37
39
|
end
|
data/lib/knife-rhn/version.rb
CHANGED
metadata
CHANGED
@@ -1,52 +1,45 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: knife-rhn
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 1
|
9
|
-
- 0
|
10
|
-
version: 0.1.0
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Brian Flad
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2013-03-21 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
21
15
|
name: rhn_satellite
|
22
|
-
|
23
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
24
17
|
none: false
|
25
|
-
requirements:
|
26
|
-
- -
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
|
29
|
-
segments:
|
30
|
-
- 0
|
31
|
-
version: "0"
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
32
22
|
type: :runtime
|
33
|
-
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
34
30
|
description: A knife plugin for managing RHN.
|
35
|
-
email:
|
31
|
+
email:
|
36
32
|
- bflad@wharton.upenn.edu
|
37
33
|
executables: []
|
38
|
-
|
39
34
|
extensions: []
|
40
|
-
|
41
35
|
extra_rdoc_files: []
|
42
|
-
|
43
|
-
files:
|
36
|
+
files:
|
44
37
|
- .gitignore
|
45
38
|
- Gemfile
|
46
39
|
- README.md
|
47
40
|
- Rakefile
|
48
41
|
- knife-rhn.gemspec
|
49
|
-
- lib/chef/knife/
|
42
|
+
- lib/chef/knife/rhn_base.rb
|
50
43
|
- lib/chef/knife/rhn_system_delete.rb
|
51
44
|
- lib/chef/knife/rhn_system_details.rb
|
52
45
|
- lib/chef/knife/rhn_system_move.rb
|
@@ -63,36 +56,26 @@ files:
|
|
63
56
|
- lib/knife-rhn/version.rb
|
64
57
|
homepage: https://github.com/bflad/knife-rhn
|
65
58
|
licenses: []
|
66
|
-
|
67
59
|
post_install_message:
|
68
60
|
rdoc_options: []
|
69
|
-
|
70
|
-
require_paths:
|
61
|
+
require_paths:
|
71
62
|
- lib
|
72
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
63
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
73
64
|
none: false
|
74
|
-
requirements:
|
75
|
-
- -
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
|
78
|
-
|
79
|
-
- 0
|
80
|
-
version: "0"
|
81
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ! '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
82
70
|
none: false
|
83
|
-
requirements:
|
84
|
-
- -
|
85
|
-
- !ruby/object:Gem::Version
|
86
|
-
|
87
|
-
segments:
|
88
|
-
- 0
|
89
|
-
version: "0"
|
71
|
+
requirements:
|
72
|
+
- - ! '>='
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
90
75
|
requirements: []
|
91
|
-
|
92
76
|
rubyforge_project:
|
93
|
-
rubygems_version: 1.8.
|
77
|
+
rubygems_version: 1.8.23
|
94
78
|
signing_key:
|
95
79
|
specification_version: 3
|
96
|
-
summary:
|
80
|
+
summary: ''
|
97
81
|
test_files: []
|
98
|
-
|
@@ -1,93 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Brian Flad (<bflad417@gmail.com>)
|
3
|
-
# License:: Apache License, Version 2.0
|
4
|
-
#
|
5
|
-
|
6
|
-
module RhnKnifePlugin
|
7
|
-
|
8
|
-
require 'chef/knife'
|
9
|
-
require 'rhn_satellite'
|
10
|
-
|
11
|
-
class BaseRhnCommand < Chef::Knife
|
12
|
-
|
13
|
-
#deps do
|
14
|
-
# require 'highline/import'
|
15
|
-
#end
|
16
|
-
|
17
|
-
def self.get_common_options
|
18
|
-
unless defined? $default
|
19
|
-
$default = Hash.new
|
20
|
-
end
|
21
|
-
|
22
|
-
option :rhn_debug,
|
23
|
-
:long => "--rhn-debug",
|
24
|
-
:description => "Enable debugging for RHN connection",
|
25
|
-
:boolean => false
|
26
|
-
|
27
|
-
option :rhn_hostname,
|
28
|
-
:short => "-h HOSTNAME",
|
29
|
-
:long => "--rhn-hostname HOSTNAME",
|
30
|
-
:description => "The hostname for RHN"
|
31
|
-
|
32
|
-
option :rhn_no_https,
|
33
|
-
:long => "--rhn-no-https",
|
34
|
-
:description => "Disable HTTPS for RHN connection",
|
35
|
-
:boolean => false
|
36
|
-
|
37
|
-
option :rhn_password,
|
38
|
-
:short => "-p PASSWORD",
|
39
|
-
:long => "--rhn-password PASSWORD",
|
40
|
-
:description => "The password for RHN"
|
41
|
-
|
42
|
-
option :rhn_timeout,
|
43
|
-
:long => "--rhn-timeout SECONDS",
|
44
|
-
:description => "The timeout in seconds for RHN"
|
45
|
-
$default[:rhn_timeout] = 30
|
46
|
-
|
47
|
-
option :rhn_username,
|
48
|
-
:short => "-u USERNAME",
|
49
|
-
:long => "--rhn-username USERNAME",
|
50
|
-
:description => "The username for RHN"
|
51
|
-
end
|
52
|
-
|
53
|
-
def get_config(key)
|
54
|
-
key = key.to_sym
|
55
|
-
rval = config[key] || Chef::Config[:knife][key] || $default[key]
|
56
|
-
Chef::Log.debug("value for config item #{key}: #{rval}")
|
57
|
-
rval
|
58
|
-
end
|
59
|
-
|
60
|
-
def get_satellite_system(system)
|
61
|
-
satellite_system = RhnSatellite::System.get(system)
|
62
|
-
|
63
|
-
if satellite_system.nil?
|
64
|
-
ui.fatal "Could not find system in RHN!"
|
65
|
-
exit 1
|
66
|
-
end
|
67
|
-
|
68
|
-
satellite_system
|
69
|
-
end
|
70
|
-
|
71
|
-
def set_rhn_connection_options
|
72
|
-
RhnSatellite::Connection::Handler.debug_enabled = true if get_config(:rhn_debug)
|
73
|
-
RhnSatellite::Connection::Handler.default_hostname = get_config(:rhn_hostname)
|
74
|
-
RhnSatellite::Connection::Handler.default_https = false if get_config(:rhn_no_https)
|
75
|
-
# See: https://github.com/duritong/ruby-rhn_satellite/issues/3
|
76
|
-
RhnSatellite::ActivationKey.https = false if get_config(:rhn_no_https)
|
77
|
-
RhnSatellite::Api.https = false if get_config(:rhn_no_https)
|
78
|
-
RhnSatellite::Channel.https = false if get_config(:rhn_no_https)
|
79
|
-
RhnSatellite::ChannelAccess.https = false if get_config(:rhn_no_https)
|
80
|
-
RhnSatellite::ChannelSoftware.https = false if get_config(:rhn_no_https)
|
81
|
-
RhnSatellite::Packages.https = false if get_config(:rhn_no_https)
|
82
|
-
RhnSatellite::System.https = false if get_config(:rhn_no_https)
|
83
|
-
RhnSatellite::Systemgroup.https = false if get_config(:rhn_no_https)
|
84
|
-
# End of issue 3 workaround
|
85
|
-
RhnSatellite::Connection::Handler.default_timeout = get_config(:rhn_timeout)
|
86
|
-
RhnSatellite::Connection::Handler.default_username = get_config(:rhn_username)
|
87
|
-
password = get_config(:rhn_password)
|
88
|
-
password ||= ask("RHN Password for #{get_config(:rhn_username)}: ") { |q| q.echo = "*" }
|
89
|
-
RhnSatellite::Connection::Handler.default_password = password
|
90
|
-
end
|
91
|
-
|
92
|
-
end
|
93
|
-
end
|