bin/kvm-admin
changeset 115 75c299d0bf5a
parent 113 d180b27d13a9
child 116 455b335e203d
equal deleted inserted replaced
114:d146fb6e68ae 115:75c299d0bf5a
   107         action.add_argument(i, action="store", metavar=("domain"), 
   107         action.add_argument(i, action="store", metavar=("domain"), 
   108             help=my_help)
   108             help=my_help)
   109         if i == "status":
   109         if i == "status":
   110             action.add_argument("--full", default=False, action="store_true", 
   110             action.add_argument("--full", default=False, action="store_true", 
   111                 #metavar=("full status information"),
   111                 #metavar=("full status information"),
   112                 help=_("Display full status information for each running qemu-kvm domain."))
   112                 help=_("""Display full status information for each 
       
   113                     running qemu-kvm domain."""))
   113         if i == "monitor":               
   114         if i == "monitor":               
   114             action.add_argument("args_monitor", nargs="*", default=[],
   115             action.add_argument("args_monitor", nargs="*", default=[],
   115                 #metavar=("monitor argument"),
   116                 #metavar=("monitor argument"),
   116                 help=_("One ore more arguments to pass to the qemu-kvm monitor."))
   117                 help=_("One ore more arguments to pass to the qemu-kvm monitor."))
       
   118         if i == "shutdown":
       
   119             action.add_argument("--time-out", type=int, 
       
   120                 action="store", metavar="'in seconds'",
       
   121                 help=_("""Set the time out for waiting till the qemu-kvm domain,
       
   122                     will be killed."""))
       
   123             action.add_argument("--wait-to-send-enter", type=int,
       
   124                 action="store", metavar="'in seconds'",
       
   125                 help=_("""Set this will send, after a given time in seconds,
       
   126                     an enter signal to the qemu-kvm domain for the 
       
   127                     grafical shutdown dialog."""))
   117     
   128     
   118     args = parser.parse_args()
   129     args = parser.parse_args()
   119     
   130     
       
   131     print args
       
   132 
   120     kvm_admin.debug = args.debug
   133     kvm_admin.debug = args.debug
   121 
   134 
   122     # assign the action and domain name dynamically
   135     # assign the action and domain name dynamically
   123     for action in actions:
   136     for action in actions:
   124         if action in args: 
   137         if action in args: 
   125             kvm_admin.action = action
   138             kvm_admin.action = action
   126             kvm_admin.kvm_domain_name = str(getattr(args, action))
   139             kvm_admin.kvm_domain_name = str(getattr(args, action))
   127             break
   140             break
   128 
   141 
   129     # assign the optional monitor arguments 
   142     # assign optional monitor arguments 
   130     if "args_monitor" in args and len(args.args_monitor) > 0:
   143     if "args_monitor" in args and len(args.args_monitor) > 0:
   131         kvm_admin.monitor = args.args_monitor        
   144         kvm_admin.monitor = args.args_monitor        
   132     else:
   145     else:
   133         # set default monitor to help
   146         # set default monitor to help
   134         kvm_admin.monitor =["help"] 
   147         kvm_admin.monitor =["help"] 
   135 
   148 
       
   149     # assign optional argumente for shutdown
       
   150     if kvm_admin.action == "shutdown":
       
   151         kvm_admin.shutdown_wait_to_send_enter = args.wait_to_send_enter
       
   152         kvm_admin.shutdown_time_out = args.time_out
       
   153        
   136     # assign all as domain name its used for status
   154     # assign all as domain name its used for status
   137     if kvm_admin.kvm_domain_name == "all" and kvm_admin.action == "status":
   155     if kvm_admin.kvm_domain_name == "all" and kvm_admin.action == "status":
   138         # append "all" as pseudo domain name
   156         # append "all" as pseudo domain name
   139         domains.append("all")
   157         domains.append("all")
   140         kvm_admin.kvm_status_full = args.full
   158         kvm_admin.kvm_status_full = args.full
   141 
   159 
   142     # check if the domain name has a config file and is not create
   160     # check if the domain name has a config file and is not create
   143     if not kvm_admin.kvm_domain_name in domains and not "create" == kvm_admin.action:  
   161     if not kvm_admin.kvm_domain_name in domains and not "create" == kvm_admin.action:  
   144         parser.error(_("Available domains\n%s") % domains)
   162         parser.error(_("Available domains\n%s") % domains)
   145 
       
   146 
   163 
   147     # check if some error occurs
   164     # check if some error occurs
   148     if not kvm_admin.action == "modify" and kvm_admin.show_error():
   165     if not kvm_admin.action == "modify" and kvm_admin.show_error():
   149         sys.exit(1)
   166         sys.exit(1)
   150     
   167