Package virtualization :: Module init_action
[hide private]
[frames] | no frames]

Source Code for Module virtualization.init_action

 1  # 
 2  # Copyright (c) 2008--2013 Red Hat, Inc. 
 3  # 
 4  # This software is licensed to you under the GNU General Public License, 
 5  # version 2 (GPLv2). There is NO WARRANTY for this software, express or 
 6  # implied, including the implied warranties of MERCHANTABILITY or FITNESS 
 7  # FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 
 8  # along with this software; if not, see 
 9  # http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. 
10  # 
11  # Red Hat trademarks are not licensed under GPLv2. No permission is 
12  # granted to use or replicate Red Hat trademarks that are incorporated 
13  # in this software or its documentation. 
14  # 
15   
16  import sys 
17  from virtualization import support 
18   
19  actions =   { 
20                  'shutdown'  :   support.shutdown, 
21                  'start'     :   support.start, 
22                  'suspend'   :   support.suspend, 
23                  'resume'    :   support.resume, 
24                  'reboot'    :   support.reboot, 
25                  'destroy'   :   support.destroy, 
26              } 
27   
28  action_type = sys.argv[1] 
29  uuid = sys.argv[2] 
30   
31  if not action_type in list(actions.keys()): 
32      sys.stderr.write("Unknown action: %s \n" % action_type) 
33      sys.exit(1) 
34   
35  try: 
36      actions[action_type](uuid) 
37  except Exception: 
38      e = sys.exc_info()[1] 
39      sys.stderr.write(str(e)) 
40      sys.exit(1) 
41   
42  sys.exit(0) 
43