Method: Cisco::Yum.remove

Defined in:
lib/cisco_node_utils/yum.rb

.remove(pkg) ⇒ Object



81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/cisco_node_utils/yum.rb', line 81

def self.remove(pkg)
  # get committed state
  cstate = query_committed(pkg)
  # get activated state
  astate = query_activated(pkg)

  if astate && cstate
    # pkg is active and committed
    # so deactivate, commit and remove
    deactivate(pkg)
    commit_deactivate(pkg)
    delete(pkg)
  elsif cstate
    # pkg is inactive and committed
    # so commit and remove
    commit_deactivate(pkg)
    delete(pkg)
  elsif astate
    # pkg is active and not committed
    # so deactivate and remove
    deactivate(pkg)
    delete(pkg)
  else
    # pkg is inactive and not committed
    # so just remove
    delete(pkg)
  end
rescue Cisco::CliError, RuntimeError => e
  raise Cisco::CliError, "#{e.class}, #{e.message}"
end