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