Class: Chef::Knife::RhnSystemMove
- Inherits:
-
Chef::Knife
- Object
- Chef::Knife
- Chef::Knife::RhnSystemMove
- Includes:
- RhnBase
- Defined in:
- lib/chef/knife/rhn_system_move.rb
Instance Method Summary collapse
Methods included from RhnBase
#get_config, #get_satellite_system, included, #set_rhn_connection_options
Instance Method Details
#run ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/chef/knife/rhn_system_move.rb', line 17 def run $stdout.sync = true system = name_args.first if system.nil? ui.fatal "You need a system name!" show_usage exit 1 end group = name_args[1] if group.nil? ui.fatal "You need a systemgroup name!" show_usage exit 1 end satellite_system = get_satellite_system(system) system_groups = RhnSatellite::Systemgroup.all system_groups.sort! {|a,b| a['name'] <=> b['name']} system_groups.each do |system_group| if RhnSatellite::Systemgroup.systems(system_group['name']).find{|s| s['id'] == satellite_system['id']} RhnSatellite::Systemgroup.remove_systems(system_group['name'],[satellite_system['id']]) ui.info "Removed system #{system} from RHN systemgroup: #{system_group['name']}" end end RhnSatellite::Systemgroup.add_systems(group,[satellite_system['id']]) ui.info "Added system #{system} to RHN systemgroup: #{group}" end |