- Timestamp:
- 08/04/12 17:07:18 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
etherws/trunk/etherws.py
r210 r211 597 597 return {'entries': [self._portstat(self._switch.get_port(portnum))]} 598 598 599 def handle_setPort(self, params): 600 port = self._switch.get_port(int(params['port'])) 601 shut = params.get('shut') 602 if shut is not None: 603 port.shut = bool(shut) 604 return {'entries': [self._portstat(port)]} 605 599 606 def handle_delPort(self, params): 600 607 port = self._switch.get_port(int(params['port'])) 601 608 port.interface.close() 602 return {'entries': [self._portstat(port)]}603 604 def handle_shutPort(self, params):605 port = self._switch.get_port(int(params['port']))606 port.shut = bool(params['shut'])607 609 return {'entries': [self._portstat(port)]} 608 610 … … 837 839 print_portlist(result['result']['entries']) 838 840 839 def handle_ctl_s hutport(args):841 def handle_ctl_setport(args): 840 842 if args.port <= 0: 841 843 raise ValueError('Invalid port: %d' % args.port) 842 result = request(args, 'shutPort', { 843 'port': args.port, 844 'shut': args.no, 845 }) 844 req = {'port': args.port} 845 shut = getattr(args, 'shut', None) 846 if shut is not None: 847 req['shut'] = bool(shut) 848 result = request(args, 'setPort', req) 846 849 if 'error' in result: 847 850 _print_error(result['error']) … … 932 935 '--insecure', action='store_true', default=False) 933 936 934 # -- ctl shutport 935 parser_ctl_shutport = control_method.add_parser('shutport') 936 parser_ctl_shutport.add_argument('port', type=int) 937 parser_ctl_shutport.add_argument( 938 '--no', action='store_false', default=True) 937 # -- ctl setport 938 parser_ctl_setport = control_method.add_parser('setport') 939 parser_ctl_setport.add_argument('port', type=int) 940 parser_ctl_setport.add_argument('--shut', type=int, choices=(0, 1)) 939 941 940 942 # -- ctl delport
Note: See TracChangeset
for help on using the changeset viewer.