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,36 +3,38 @@
|
|
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 RhnSystemSystemgroups < Knife
|
9
11
|
|
10
|
-
|
12
|
+
include Knife::RhnBase
|
11
13
|
|
12
|
-
|
13
|
-
|
14
|
+
banner "knife rhn system systemgroups SYSTEM (options)"
|
15
|
+
category "rhn"
|
14
16
|
|
15
|
-
|
17
|
+
def run
|
18
|
+
$stdout.sync = true
|
19
|
+
|
20
|
+
system = name_args.first
|
16
21
|
|
17
|
-
|
18
|
-
|
19
|
-
|
22
|
+
if system.nil?
|
23
|
+
ui.fatal "You need a system name!"
|
24
|
+
show_usage
|
25
|
+
exit 1
|
26
|
+
end
|
20
27
|
|
21
|
-
|
22
|
-
ui.fatal "You need a system 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
|
-
|
33
|
-
|
30
|
+
satellite_system = get_satellite_system(system)
|
31
|
+
system_groups = RhnSatellite::Systemgroup.all
|
32
|
+
system_groups.sort! {|a,b| a['name'] <=> b['name']}
|
33
|
+
system_groups.each do |system_group|
|
34
|
+
ui.info "#{system_group['name']}" if RhnSatellite::Systemgroup.systems(system_group['name']).find{|s| s['id'] == satellite_system['id']}
|
35
|
+
end
|
34
36
|
end
|
35
|
-
end
|
36
37
|
|
38
|
+
end
|
37
39
|
end
|
38
40
|
end
|
@@ -3,47 +3,50 @@
|
|
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 RhnSystemgroupActive < Knife
|
9
11
|
|
10
|
-
|
11
|
-
module Systemgroup
|
12
|
-
def active_systems(group_name)
|
13
|
-
base.default_call('systemgroup.listActiveSystemsInGroup',group_name)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
class RhnSystemgroupActive < BaseRhnCommand
|
12
|
+
include Knife::RhnBase
|
18
13
|
|
19
|
-
|
20
|
-
|
14
|
+
banner "knife rhn systemgroup active GROUP (options)"
|
15
|
+
category "rhn"
|
21
16
|
|
22
|
-
get_common_options
|
23
|
-
|
24
|
-
def run
|
25
|
-
|
26
|
-
group = name_args.first
|
27
17
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
18
|
+
# Until released: https://github.com/duritong/ruby-rhn_satellite/pull/7
|
19
|
+
module Systemgroup
|
20
|
+
def active_systems(group_name)
|
21
|
+
base.default_call('systemgroup.listActiveSystemsInGroup',group_name)
|
22
|
+
end
|
32
23
|
end
|
33
24
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
25
|
+
def run
|
26
|
+
$stdout.sync = true
|
27
|
+
|
28
|
+
group = name_args.first
|
29
|
+
|
30
|
+
if group.nil?
|
31
|
+
ui.fatal "You need a systemgroup name!"
|
32
|
+
show_usage
|
33
|
+
exit 1
|
34
|
+
end
|
35
|
+
|
36
|
+
set_rhn_connection_options
|
37
|
+
|
38
|
+
RhnSatellite::Systemgroup.extend(Systemgroup)
|
39
|
+
system_ids = RhnSatellite::Systemgroup.active_systems(group)
|
40
|
+
systems = []
|
41
|
+
system_ids.each do |system_id|
|
42
|
+
systems << RhnSatellite::System.details(system_id)
|
43
|
+
end
|
44
|
+
systems.sort! {|a,b| a['profile_name'] <=> b['profile_name']}
|
45
|
+
systems.each do |system|
|
46
|
+
ui.info "#{system['id']},#{system['profile_name']}"
|
47
|
+
end
|
45
48
|
end
|
49
|
+
|
46
50
|
end
|
47
|
-
|
48
51
|
end
|
49
52
|
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 RhnSystemgroupAdd < Knife
|
9
11
|
|
10
|
-
|
12
|
+
include Knife::RhnBase
|
11
13
|
|
12
|
-
|
13
|
-
|
14
|
+
banner "knife rhn systemgroup add 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.add_systems(group,[satellite_system['id']])
|
40
|
+
ui.info "Added #{system} (ID: #{satellite_system['id']}) to RHN systemgroup: #{group}"
|
41
|
+
end
|
36
42
|
|
37
|
-
satellite_system = get_satellite_system(system)
|
38
|
-
RhnSatellite::Systemgroup.add_systems(group,[satellite_system['id']])
|
39
|
-
ui.info "Added #{system} (ID: #{satellite_system['id']}) to 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 RhnSystemgroupCreate < Knife
|
9
11
|
|
10
|
-
|
12
|
+
include Knife::RhnBase
|
11
13
|
|
12
|
-
|
13
|
-
|
14
|
+
banner "knife rhn systemgroup create GROUP DESCRIPTION (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
|
-
|
23
|
-
show_usage
|
24
|
-
exit 1
|
25
|
-
end
|
28
|
+
description = name_args[1]
|
29
|
+
description ||= group
|
26
30
|
|
27
|
-
|
28
|
-
description ||= group
|
31
|
+
set_rhn_connection_options
|
29
32
|
|
30
|
-
|
33
|
+
RhnSatellite::Systemgroup.create(group,description)
|
34
|
+
ui.info "Created RHN Systemgroup: #{group}"
|
35
|
+
end
|
31
36
|
|
32
|
-
RhnSatellite::Systemgroup.create(group,description)
|
33
|
-
ui.info "Created RHN Systemgroup: #{group}"
|
34
37
|
end
|
35
|
-
|
36
38
|
end
|
37
39
|
end
|
@@ -3,32 +3,34 @@
|
|
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 RhnSystemgroupDelete < Knife
|
9
11
|
|
10
|
-
|
12
|
+
include Knife::RhnBase
|
11
13
|
|
12
|
-
|
13
|
-
|
14
|
+
banner "knife rhn systemgroup delete 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
|
28
|
+
set_rhn_connection_options
|
26
29
|
|
27
|
-
|
30
|
+
RhnSatellite::Systemgroup.delete(group)
|
31
|
+
ui.info "Deleted RHN Systemgroup: #{group}"
|
32
|
+
end
|
28
33
|
|
29
|
-
RhnSatellite::Systemgroup.delete(group)
|
30
|
-
ui.info "Deleted RHN Systemgroup: #{group}"
|
31
34
|
end
|
32
|
-
|
33
35
|
end
|
34
36
|
end
|
@@ -3,55 +3,57 @@
|
|
3
3
|
# License:: Apache License, Version 2.0
|
4
4
|
#
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
6
|
+
require 'chef/knife/rhn_base'
|
7
|
+
|
8
|
+
class Chef
|
9
|
+
class Knife
|
10
|
+
class RhnSystemgroupInactive < Knife
|
11
|
+
|
12
|
+
include Knife::RhnBase
|
13
|
+
|
14
|
+
banner "knife rhn systemgroup inactive GROUP (options)"
|
15
|
+
category "rhn"
|
16
|
+
|
17
|
+
option :days,
|
18
|
+
:long => "--days DAYS",
|
19
|
+
:description => "The number of inactive days"
|
20
|
+
|
21
|
+
# Until released: https://github.com/duritong/ruby-rhn_satellite/pull/7
|
22
|
+
module Systemgroup
|
23
|
+
def inactive_systems(group_name,days=nil)
|
24
|
+
if days
|
25
|
+
base.default_call('systemgroup.listInactiveSystemsInGroup',group_name,days.to_i)
|
26
|
+
else
|
27
|
+
base.default_call('systemgroup.listInactiveSystemsInGroup',group_name)
|
28
|
+
end
|
29
|
+
end
|
17
30
|
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
class RhnSystemgroupInactive < BaseRhnCommand
|
22
|
-
|
23
|
-
banner "knife rhn systemgroup inactive GROUP (options)"
|
24
|
-
category "rhn"
|
25
|
-
|
26
|
-
get_common_options
|
27
31
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
32
|
+
def run
|
33
|
+
$stdout.sync = true
|
34
|
+
|
35
|
+
group = name_args.first
|
36
|
+
|
37
|
+
if group.nil?
|
38
|
+
ui.fatal "You need a systemgroup name!"
|
39
|
+
show_usage
|
40
|
+
exit 1
|
41
|
+
end
|
42
|
+
|
43
|
+
set_rhn_connection_options
|
44
|
+
|
45
|
+
RhnSatellite::Systemgroup.extend(Systemgroup)
|
46
|
+
system_ids = RhnSatellite::Systemgroup.inactive_systems(group,get_config(:days))
|
47
|
+
systems = []
|
48
|
+
system_ids.each do |system_id|
|
49
|
+
systems << RhnSatellite::System.details(system_id)
|
50
|
+
end
|
51
|
+
systems.sort! {|a,b| a['profile_name'] <=> b['profile_name']}
|
52
|
+
systems.each do |system|
|
53
|
+
ui.info "#{system['id']},#{system['profile_name']}"
|
54
|
+
end
|
40
55
|
end
|
41
56
|
|
42
|
-
set_rhn_connection_options
|
43
|
-
|
44
|
-
RhnSatellite::Systemgroup.extend(Systemgroup)
|
45
|
-
system_ids = RhnSatellite::Systemgroup.inactive_systems(group,get_config(:days))
|
46
|
-
systems = []
|
47
|
-
system_ids.each do |system_id|
|
48
|
-
systems << RhnSatellite::System.details(system_id)
|
49
|
-
end
|
50
|
-
systems.sort! {|a,b| a['profile_name'] <=> b['profile_name']}
|
51
|
-
systems.each do |system|
|
52
|
-
ui.info "#{system['id']},#{system['profile_name']}"
|
53
|
-
end
|
54
57
|
end
|
55
|
-
|
56
58
|
end
|
57
59
|
end
|
@@ -3,27 +3,29 @@
|
|
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 RhnSystemgroupList < Knife
|
9
11
|
|
10
|
-
|
12
|
+
include Knife::RhnBase
|
11
13
|
|
12
|
-
|
13
|
-
|
14
|
+
banner "knife rhn ystemgroup list (options)"
|
15
|
+
category "rhn"
|
14
16
|
|
15
|
-
|
17
|
+
def run
|
18
|
+
$stdout.sync = true
|
16
19
|
|
17
|
-
|
20
|
+
set_rhn_connection_options
|
18
21
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
ui.info "#{system_group['name']}"
|
22
|
+
system_groups = RhnSatellite::Systemgroup.all
|
23
|
+
system_groups.sort! {|a,b| a['name'] <=> b['name']}
|
24
|
+
system_groups.each do |system_group|
|
25
|
+
ui.info "#{system_group['name']}"
|
26
|
+
end
|
25
27
|
end
|
26
|
-
end
|
27
28
|
|
29
|
+
end
|
28
30
|
end
|
29
31
|
end
|