# coding: utf-8

from qingcloud.cli.iaas_client.actions.base import BaseAction

class ModifyRouterAttributesAction(BaseAction):

    action = 'ModifyRouterAttributes'
    command = 'modify-router-attributes'
    usage = '%(prog)s -r <router_id>] [-s <security_group> -e <eip>] [options] [-f <conf_file>]'

    @classmethod
    def add_ext_arguments(cls, parser):
        parser.add_argument('-r', '--router', dest='router',
                action='store', type=str, default='',
                help='the id of the router whose attributes you want to modify.')

        parser.add_argument('-e', '--eip', dest='eip',
                action='store', type=str, default='',
                help='ID of eip that will apply to the router.')

        parser.add_argument('-s', '--security_group', dest='security_group',
                action='store', type=str, default='',
                help='the id of the security_group you want to apply to router.')

        parser.add_argument('-N', '--router_name', dest='router_name',
                action='store', type=str, default=None,
                help='new router_name.')

        parser.add_argument('-D', '--description', dest='description',
                action='store', type=str, default=None,
                help='new description.')

    @classmethod
    def build_directive(cls, options):
        router = options.router
        if not router:
            print '[router] should be specified.'
            return None

        return {
                'router': router,
                'router_name': options.router_name,
                'description': options.description,
                'eip': options.eip,
                'security_group': options.security_group,
                }

@@ -237,17 +237,16 @@
 uter_id%3E
-%5D
  %5B-s %3Cse
@@ -267,16 +267,75 @@
 -e %3Ceip%3E
+ -v %3Cvxnet%3E -F %3Cfeatures%3E -S %3Cdyn_start_ip%3E -E %3Cdyn_end_ip%3E
 %5D %5Boptio
@@ -1347,113 +1347,1355 @@
     
-@classmethod%0A    def build_directive(cls, options):%0A        router = options.router%0A        if not router
+    parser.add_argument('-v', '--vxnet', dest='vxnet',%0A                action='store', type=str, default=None,%0A                help='the id of the vxnet whose feature you want to modify.')%0A%0A        parser.add_argument('-F', '--features', dest='features',%0A                action='store', type=int, default=None,%0A                help='''%0A                the integer value of the bit mask that represent the selected features.%0A                Masking Bit:%0A                1 - dhcp server%0A                ''')%0A%0A        parser.add_argument('-S', '--dyn_ip_start', dest='dyn_ip_start',%0A                action='store', type=str, default=None,%0A                help='starting ip allocated from DHCP server, e.g. %22192.168.x.2%22.')%0A%0A        parser.add_argument('-E', '--dyn_ip_end', dest='dyn_ip_end',%0A                action='store', type=str, default=None,%0A                help='ending ip allocated from DHCP server, e.g. %22192.168.x.254%22.')%0A%0A    @classmethod%0A    def build_directive(cls, options):%0A        if not options.router:%0A            print 'error: %5Brouter%5D should be specified.'%0A            return None%0A%0A        if options.features is not None and not options.vxnet:%0A            print 'error: %5Bvxnet%5D should be specified if modify features.'%0A            return None%0A%0A        if (options.dyn_ip_start or options.dyn_ip_end) and options.features is None
 :%0A  
@@ -2711,23 +2711,32 @@
  print '
-%5Brouter
+error: %5Bfeatures
 %5D should
@@ -2740,32 +2740,51 @@
 uld be specified
+ if modify ip range
 .'%0A            r
@@ -2838,16 +2838,24 @@
 outer': 
+options.
 router,%0A
@@ -3052,16 +3052,206 @@
 _group,%0A
+                'vxnet': options.vxnet,%0A                'features': options.features,%0A                'dyn_ip_start': options.dyn_ip_start,%0A                'dyn_ip_end': options.dyn_ip_end,%0A
         

Add options to modify-router-attributes