def show(argv): """ Show IP-related information syntax: show ip address|route """ output = lib.output.CLIoutput("ip", _output_handlers) if len(argv) > 2: lib.errorhandler.InvalidArgumentCount(syntax=show.__doc__) return output if len(argv) == 1 : if 'address' in argv[0] or 'route' in argv[0]: keyword = argv[0].split() if keyword[1].startswith('address'): _show_ip_addresses(output, []) elif keyword[1].startswith('route'): _show_ip_routes(output, []) else: output.completeOutputError(InvalidArgumentCount(syntax=show.__doc__)) return output #print show.__doc__ else: output.completeOutputError(InvalidArgumentCount(syntax=show.__doc__)) #print show.__doc__ return output return output
def show(argv): """Show the contents of the ARP cache syntax: show arp """ output = lib.output.CLIoutput("arp", _output_handlers) if len(argv) != 1: output.completeOutputError(InvalidArgumentCount (syntax = show.__doc__)) return output arp_entries = open("/proc/net/arp", 'r').readlines() output.beginList("ARPentryList") for line in arp_entries[1:]: # skip header fields = line.split() output.beginAssembling("ARPentry") output.setVirtualNameValue("IPaddress", fields[0]) if int(fields[2], 16) == 0: output.setVirtualNameValue("HWaddress", "(unresolved)") else: output.setVirtualNameValue("HWaddress", fields[3]) output.setVirtualNameValue("InterfaceName", fields[5]) output.endAssembling("ARPentry") output.endList("ARPentryList") output.completeOutputSuccess() #print output return output
def edit(argv): """Halt the system. syntax: halt [now] """ output = lib.output.CLIoutput("halt") xml_out = 0 if len(argv) == 2 and argv[1] == "now": xml_out = 1 if (len(argv) == 2 and argv[1] != "now") or len(argv) > 2: output.completeOutputError(InvalidArgumentCount()) return output if (len(argv) == 1): try: doit = lib.essentials.confirm( "Are you sure that you want to halt the system") except lib.errorhandler.InteractiveCliRequired, ex: output.completeOutputError(ex) return output if not doit: print "\nHalt aborted." output.completeOutputSuccess() return output
def show(argv): """ Show IP-related information syntax: show ip address|route """ output = lib.output.CLIoutput("ip", _output_handlers) if len(argv) > 2: lib.errorhandler.InvalidArgumentCount(syntax=show.__doc__) return output if len(argv) == 1: if 'address' in argv[0] or 'route' in argv[0]: keyword = argv[0].split() if keyword[1].startswith('address'): _show_ip_addresses(output, []) elif keyword[1].startswith('route'): _show_ip_routes(output, []) else: output.completeOutputError( InvalidArgumentCount(syntax=show.__doc__)) return output #print show.__doc__ else: output.completeOutputError(InvalidArgumentCount(syntax=show.__doc__)) #print show.__doc__ return output return output
def no(argv): """Invalidate an ARP entry or all ARP entries syntax: no arp [<ip-address>] """ if argv[0] == 'clear_arp': msg = clear.__doc__ else: msg = no.__doc__ output = lib.output.CLIoutput("arp") if len(argv) > 2: output.completeOutputError(InvalidArgumentCount (syntax = msg)) return output if len(argv) == 1: arp_entries = open("/proc/net/arp", 'r').readlines() for line in arp_entries[1:]: # skip header cmd = (_ARP, "-d", line.split()[0]) lib.process.execute_command(cmd) output.completeOutputSuccess() return output ipaddr = argv[1] try: lib.essentials.checkIp(ipaddr) except InvalidIpException, ex: output.completeOutputError(ex) return output
def validateID(output, id): """ This checks for the valid digit format in the id. Also the length of the ID from the lib.constants._LENGTH_ """ if re.compile('[0-9]+').match(id) == None: output.completeOutputError( InvalidArgumentCount( descape= "'%s' is not a valid Id. ID should be numeric with Length = '%s' " % (id, lib.constants._ATTR_ID_LENGHT))) return -1 else: # Check for the lenght counter = 0 for char in id: counter += 1 print counter, lib.constants._ATTR_ID_LENGHT if counter > lib.constants._ATTR_ID_LENGHT: output.completeOutputError( InvalidArgumentCount( descape= "'%s' exceeded the given length i.e Max Length = '%s'" % (id, lib.constants._ATTR_ID_LENGHT))) return -1 else: return 0 return 0
def no(argv): """Invalidate an ARP entry or all ARP entries syntax: no arp [<ip-address>] """ if argv[0] == 'clear_arp': msg = clear.__doc__ else: msg = no.__doc__ output = lib.output.CLIoutput("arp") if len(argv) > 2: output.completeOutputError(InvalidArgumentCount(syntax=msg)) return output if len(argv) == 1: arp_entries = open("/proc/net/arp", 'r').readlines() for line in arp_entries[1:]: # skip header cmd = (_ARP, "-d", line.split()[0]) lib.process.execute_command(cmd) output.completeOutputSuccess() return output ipaddr = argv[1] try: lib.essentials.checkIp(ipaddr) except InvalidIpException, ex: output.completeOutputError(ex) return output
def validateIOmoduleId(output, arg_dict, key): """ Check in the database for the valid key. if Not found then return "None". Else return arg_dict INTERCHANGEABLE : Here we can change the id with the name. """ id = arg_dict[key] counter = 0 for char in id: counter += 1 if re.compile('[0-9]+').match(char[0]) == None: output.completeOutputError( InvalidArgumentCount( descape= "'%s'='%s' is not a valid Id. \n ID should be numeric " % (key, id))) return None if counter > lib.constants._ATTR_ID_LENGHT: output.completeOutputError( InvalidArgumentCount( descape= "'%s'='%s' is not a valid Id. \n ID should be numeric with Length = '%s' " % (key, id, lib.constants._ATTR_ID_LENGHT))) return None return arg_dict
def show(argv): """Show the contents of the ARP cache syntax: show arp """ output = lib.output.CLIoutput("arp", _output_handlers) if len(argv) != 1: output.completeOutputError(InvalidArgumentCount(syntax=show.__doc__)) return output arp_entries = open("/proc/net/arp", 'r').readlines() output.beginList("ARPentryList") for line in arp_entries[1:]: # skip header fields = line.split() output.beginAssembling("ARPentry") output.setVirtualNameValue("IPaddress", fields[0]) if int(fields[2], 16) == 0: output.setVirtualNameValue("HWaddress", "(unresolved)") else: output.setVirtualNameValue("HWaddress", fields[3]) output.setVirtualNameValue("InterfaceName", fields[5]) output.endAssembling("ARPentry") output.endList("ARPentryList") output.completeOutputSuccess() #print output return output
def edit(argv): """Halt the system. syntax: halt [now] """ output = lib.output.CLIoutput("halt") xml_out = 0 if len(argv) == 2 and argv[1] == "now": xml_out = 1 if (len(argv) == 2 and argv[1] != "now") or len(argv) > 2: output.completeOutputError(InvalidArgumentCount ()) return output if (len(argv) == 1): try: doit = lib.essentials.confirm( "Are you sure that you want to halt the system") except lib.errorhandler.InteractiveCliRequired, ex: output.completeOutputError(ex) return output if not doit: print "\nHalt aborted." output.completeOutputSuccess() return output
def show(argv): """ Show io-module-related information syntax: show iomodule <iomodule-id> show iomodule """ output = lib.output.CLIoutput("iomodule", _output_handlers) if len(argv) > 2: output.completeOutputError(InvalidArgumentCount(syntax = show.__doc__)) return output if len(argv) == 2: _show_imodule_module(output, argv, argv[1]) return output if len(argv) == 1: _show_iomodule(output, argv) return output else: output.completeOutputError(InvalidArgumentCount(syntax = show.__doc__)) return output return output
def edit(argv): """ [edit] vfabric <vfabric-id> online [edit] vfabric <vfabric-id> [<general-attrs>] protocol [EN <en-attrs>] | [FC <fc-attrs>] general-attrs: [running_mode <OFFLINE | ONLINE>] [desc <"DETAILS">] [ha_state < NORMAL | FAILOVER>] [auto_failover < DISABLED | ENABLED>] [auto_failback < DISABLED | ENABLED>] [primary_gw_id <primary_gw_id>] [backup_gw_id <backup_gw_id>] [protocol <protocol>] [component_mask <component_mask>] en-attrs: [mac <mac-addr>] [vlan <vlan-value>] fc-attrs: [wwpn <world-wide-port-name>] [wwnn <world-wide-node-name>] """ output = lib.output.CLIoutput("vfabric") valid_list = ['primary_gw_id', 'backup_gw_id', 'running_mode', 'desc', 'ha_state', 'component_mask','type','mac', 'auto_failover' , 'auto_failback', 'protocol','vlan' ,'wwnn','wwpn',] if (len(argv) < 2 ): output.completeOutputError(lib.errorhandler.InvalidArgumentCount(3, "vfabric-id", syntax=edit.__doc__,descape = "Please specify the vfabric id")) return output if ( argv[1] == '?' or argv[1] == 'help'): output.completeOutputError(lib.errorhandler.InvalidArgumentCount(syntax=edit.__doc__, descape = "Help")) return output if argv[2].lower() == 'online': if isEditName(output, argv[1]) == -1: print "Error Not a valid Id" return output else: dict = {} dict['id'] = int(argv[1]) try: result = vfm.py_vfm_vfabric_online(dict) except StandardError, e: print "Error!" ,e return output else: print result return output
def _add_vadapter_en_prop(output, argv, arg_dict, call_from): """ [edit | add ] vadapter <vadapter-name> [<general-atts>] [EN <en-attrs>] | [FC <fc-attrs>] en-attrs: [mac <mac-addr>] [promiscuous [TRUE | FALSE]] [silent_listener [TRUE | FALSE]] [vlan <vlan-value>] """ _NON_EN_PROP = [ 'wwnn','wwpn','fc_id','spma','fmpa'] # Check for attributes which are not in en properties. for n in _NON_EN_PROP: if arg_dict.has_key(n): output.completeOutputError(InvalidArgumentCount(syntax=_add_vadapter_en_prop.__doc__, descape = " Keyword '%s' is not an EN attribute" % (n,))) return output # Check Boolean values. if arg_dict.has_key('promiscuous'): if _check_boolean_value(arg_dict, 'promiscuous') !=0: msg = " Keyword 'promiscuous' expected value [Enabled| Disabled]" output.completeOutputError(InvalidArgumentCount(descape = " \n '%s'='%s' Invalid promiscuous value . \n %s \n" % ('promiscuous',arg_dict['promiscuous'],msg))) return output if arg_dict.has_key('silent_listener'): if _check_boolean_value(arg_dict, 'silent_listener') !=0: msg1 = " Keyword 'silent_listener' expected value [Enabled| Disabled]" output.completeOutputError(InvalidArgumentCount(descape = "\n '%s'='%s' Invalid silent_listener value . \n %s \n " % ('silent_listener', arg_dict['silent_listener'], msg1))) return output if arg_dict.has_key('mac'): if isMAC(arg_dict['mac']) != 1: output.completeOutputError(InvalidArgumentCount(descape = "\n Invalid MAC address \n ")) return output if arg_dict.has_key('vlan'): if _isVLAN(arg_dict['vlan']) != 1: output.completeOutputError(InvalidArgumentCount(descape = "\n Invalid VLAN value, Expected values : d,d,d-d or d,d or d-d Syntax:d = digit [0-9] \n")) return output #print arg_dict arg_dict = _editing_edit_dictionary(arg_dict) if call_from == 'edit': # # Change the dictionary according to the reggression.py # result = vfm.py_vfm_vadapter_edit_general_attr(arg_dict) print "vdapter edited:", result elif call_from == 'add': vadapter = vfm.py_vfm_vadapter_create(arg_dict) print "vadpter created:", vadapter return output
def edit(argv): """ [edit] vadapter <vadapter-id> online [edit] vadapter <vadapter-id> [<general-attrs>] protocol [EN <en-attrs>] | [FC <fc-attrs>] general-attrs: [name <name>] [vfabric_id <vfabric_id>] [io_module_id <io_module_id>] [status [ONLINE | OFFLINE]] [init_type [ HOST | NETWORK]] [assignment_type [AUTO | MANUAL | ONCE ]] [component_mask [INT]] en-attrs: [mac <mac-addr>] [promiscuous [Enabled | Disabled]] [silent_listener [Enabled | Disabled]] [vlan <vlan-value>] fc-attrs: [wwpn <world-wide-port-name>] [wwnn <world-wide-node-name>] """ output = lib.output.CLIoutput("vadapter") valid_list = ['assignment_type','component_mask' ,'vfabric_id', 'init_type', 'io_module_id', 'name', 'mac', 'promiscuous', 'protocol', 'silent_listener', 'vlan' ,'wwnn', 'wwpn','status'] if (len(argv) < 2 ): output.completeOutputError(lib.errorhandler.InvalidArgumentCount(3, "vadapter-name", syntax=edit.__doc__, descape = "Please specify the vadapter id")) return output if ( argv[1] == '?' or argv[1] == 'help'): output.completeOutputError(lib.errorhandler.InvalidArgumentCount(syntax=edit.__doc__, descape = "Help")) return output if argv[2].lower() == 'online': if isEditName(argv[1]) == -1: print "Error Not a valid Id" return output else: dict = {} dict['id'] = int(argv[1]) try: result = vfm.py_vfm_vadapter_online(dict) except StandardError, e: print "Error!" ,e return output else: print result return output
def _add_vadapter_protcol(output, argv, arg_dict, call_from, syntax = None): # This expects [ EN | FC ] as the protocol name. proto_value = arg_dict['protocol'].lower() if proto_value in ['en', 'fc']: if proto_value == 'en': _add_vadapter_en_prop(output, argv, arg_dict, call_from) elif proto_value == 'fc': _add_vadapter_fc_prop(output, argv, arg_dict, call_from) else: print 'Unknown Error' else: output.completeOutputError(lib.errorhandler.InvalidArgumentCount(5, "[EN | FC]", syntax=edit.__doc__, descape = "Expecting [EN | FC] as protocol value only " ))
def _edit_ip_route(output , argv): """Edit IP-route-related information syntax: [edit] ip route default gateway <gateway-address> interface <interface> """ argc = len(argv) interface = None if argc < 6: output.completeOutputError(InvalidArgumentCount(syntax = _edit_ip_route.__doc__)) return output if argv[1] == '' or not "default".startswith(argv[1].lower()) \ or argv[2] == '' or not "gateway".startswith(argv[2].lower()): msg = 'Expected initial keywords "default" and "gateway".' output.completeOutputError(InvalidArgumentCount(5, "ip-route",syntax=_edit_ip_route.__doc__, desc=msg)) return output gateway = argv[3] if argc == 5: if argv[4] == '' or not "interface".startswith(argv[4].lower()): msg = 'Expected keyword "interface".' output.completeOutputError(InvalidArgumentCount(7, "ip-route", _edit_ip_route.__doc__, msg)) return output interface = argv[5] try: checkInterface(interface) except UnknownInterfaceCheck, ex: output.completeOutputError(InvalidArgumentCount(8, "ip-route", _edit_ip_route.__doc__, "Not a Valid Interface")) return output
def add(argv): """ [add] vfabric <vfabric-name> [<general-attrs>] protocol [EN <en-attrs>] | [FC <fc-attrs>] general-attrs: [running_mode <OFFLINE | ONLINE> [desc < "DETAILS">] [ha_state < NORMAL | FAILOVER>] [auto_failover < DISABLED | ENABLED>] [auto_failback < DISABLED | ENABLED>] [primary_gw_id <primary_gw_id>] [backup_gw_id <backup_gw_id>] [protocol <protocol>] [component_mask <component_mask>] en-attrs: [vlan <vlan-value>] fc-attrs: [wwpn <world-wide-port-name>] [wwnn <world-wide-node-name>] """ output = lib.output.CLIoutput("vfabric") valid_list = [ 'primary_gw_id', 'backup_gw_id', 'ha_state', 'auto_failover', 'auto_failback', 'running_mode', 'desc', 'component_mask', 'type', 'mac', 'protocol', 'vlan', 'wwnn', 'wwpn' ] if (len(argv) < 2): output.completeOutputError( InvalidArgumentCount(3, "vfabric-name", syntax=add.__doc__, descape="Please specify the vfabric name")) return output if (argv[1] == '?' or argv[1] == 'help'): output.completeOutputError( InvalidArgumentCount(syntax=add.__doc__, descape="Help")) return output _parse_edit_or_add_argv(output, argv, valid_list, syntax=add.__doc__, call_from='add') return output
def edit(argv): """Set the hostname syntax: [edit] hostname <new-hostname> """ output = lib.output.CLIoutput("hostname") if len(argv) != 2: output.completeOutputError(InvalidArgumentCount (syntax=edit.__doc__)) return output new_name = argv[1] try: checkHostname(new_name) except InvalidHostnameException, ex: output.completeOutputError(ex) return output
def show(argv): """ Show Bridge-related information syntax: show bridge <bridge-id> """ output = lib.output.CLIoutput("bridge", _output_handlers) if len(argv) > 2: output.completeOutputError(lib.errorhandler.InvalidArgumentCount(syntax=show__doc__)) return output if len(argv) == 2: _show_bridge(output, argv, argv[1]) elif len(argv) == 1: _show_bridge(output, argv, "ALL") return output
def show(argv): """ Show Bridge-related information syntax: show bridge <bridge-id> """ output = lib.output.CLIoutput("bridge", _output_handlers) if len(argv) > 2: output.completeOutputError(lib.errorhandler.InvalidArgumentCount(syntax = show__doc__)) return output if len(argv) == 2: _show_bridge(output, argv, argv[1]) elif len(argv) == 1: _show_bridge(output, argv, "ALL") return output
def validateIOmoduleId(output, arg_dict , key): """ Check in the database for the valid key. if Not found then return "None". Else return arg_dict INTERCHANGEABLE : Here we can change the id with the name. """ id = arg_dict[key] counter = 0 for char in id: counter += 1 if re.compile('[0-9]+').match(char[0]) == None: output.completeOutputError(InvalidArgumentCount(descape = "'%s'='%s' is not a valid Id. \n ID should be numeric " % (key,id))) return None if counter > lib.constants._ATTR_ID_LENGHT: output.completeOutputError(InvalidArgumentCount(descape = "'%s'='%s' is not a valid Id. \n ID should be numeric with Length = '%s' " % (key,id, lib.constants._ATTR_ID_LENGHT))) return None return arg_dict
def add(argv): """ [add] vfabric <vfabric-name> [<general-attrs>] protocol [EN <en-attrs>] | [FC <fc-attrs>] general-attrs: [running_mode <OFFLINE | ONLINE> [desc < "DETAILS">] [ha_state < NORMAL | FAILOVER>] [auto_failover < DISABLED | ENABLED>] [auto_failback < DISABLED | ENABLED>] [primary_gw_id <primary_gw_id>] [backup_gw_id <backup_gw_id>] [protocol <protocol>] [component_mask <component_mask>] en-attrs: [vlan <vlan-value>] fc-attrs: [wwpn <world-wide-port-name>] [wwnn <world-wide-node-name>] """ output = lib.output.CLIoutput("vfabric") valid_list = ['primary_gw_id', 'backup_gw_id', 'ha_state','auto_failover', 'auto_failback', 'running_mode','desc' ,'component_mask','type','mac', 'protocol','vlan' ,'wwnn','wwpn'] if (len(argv) < 2 ): output.completeOutputError(InvalidArgumentCount(3, "vfabric-name", syntax=add.__doc__,descape = "Please specify the vfabric name")) return output if ( argv[1] == '?' or argv[1] == 'help'): output.completeOutputError(InvalidArgumentCount(syntax=add.__doc__, descape = "Help")) return output _parse_edit_or_add_argv(output, argv, valid_list,syntax = add.__doc__ , call_from = 'add' ) return output
def _show_gateway(output, argv): """ Show gateway syntax : show gateway show gateway < gateway-id > show gateway < help | ? > """ if len(argv) > 1 or argv[0] == "?" or argv[0] == "help" or argv[0] == "": output.completeOutputError(InvalidArgumentCount(syntax =show.__doc__)) return output elif len(argv) == 1: print argv[0] output.beginList("GatewaySpecList") _get_gateway_from_db(output,"gateway") output.endList("GatewaySpecList") output.completeOutputSuccess()
def show(argv): """Get the hostname syntax: show hostname """ output = lib.output.CLIoutput("hostname") if len(argv) > 1: output.completeOutputError(InvalidArgumentCount (syntax=show.__doc__)) return output # Get hostname from the system. hostname = getSystemHostname() #print hostname if hostname is None: output.completeOutputError("unable to determine current hostname") return output output.beginAssembling("hostname") output.setVirtualNameValue("hostname",hostname) output.endAssembling("hostname") output.completeOutputSuccess() return output
def _show_gateway(output, argv): """ Show gateway syntax : show gateway show gateway < gateway-id > show gateway < help | ? > """ if len(argv) > 1 or argv[0] == "?" or argv[0] == "help" or argv[0] == "": output.completeOutputError(InvalidArgumentCount(syntax=show.__doc__)) return output elif len(argv) == 1: print argv[0] output.beginList("GatewaySpecList") _get_gateway_from_db(output, "gateway") output.endList("GatewaySpecList") output.completeOutputSuccess()
def validateID(output, id): """ This checks for the valid digit format in the id. Also the length of the ID from the lib.constants._LENGTH_ """ if re.compile('[0-9]+').match(id) == None: output.completeOutputError(InvalidArgumentCount(descape = "'%s' is not a valid Id. ID should be numeric with Length = '%s' " % (id, lib.constants._ATTR_ID_LENGHT))) return -1 else: # Check for the lenght counter = 0 for char in id: counter += 1 print counter , lib.constants._ATTR_ID_LENGHT if counter > lib.constants._ATTR_ID_LENGHT : output.completeOutputError(InvalidArgumentCount(descape ="'%s' exceeded the given length i.e Max Length = '%s'" % (id, lib.constants._ATTR_ID_LENGHT))) return -1 else: return 0 return 0
def _edit_ip_address(output, argv): """Edit IP-address-related information syntax: [edit] ip address <ip-address> interface <interface> netmask <netmask> """ argc = len(argv) interface = None if argc < 6: output.completeOutputError(InvalidArgumentCount(syntax=_edit_ip_address.__doc__)) return output if argv[2] == '' or not "interface".startswith(argv[2].lower()): if argv[4] == '' or not "netmask".startwith(argv[4].lower()): msg = 'Expected keywords "interface" and "netmask" ' output.completeOutputError(InvalidArgumentCount(syntax=_edit_ip_address.__doc__)) return output interface = argv[3] try: checkInterface(interface) except UnknownInterfaceCheck, ex: error_msg = ex output.completeOutputError(InvalidArgumentCount(descape = "Error: error_msg")) return output
def _show_ip_addresses(output, argv): """Show IP addresses syntax: show ip address [<ip-address> [usage]] """ if len(argv) > 2: output.completeOutputError( InvalidArgumentCount(syntax=_show_ip_addresses.__doc__)) return output addr = None if len(argv) >= 1: addr = argv[0] try: checkIp(addr) except UnknownIpCheck, ex: output.completeOutputError( InvalidArgumentCount(2, argv[0], _show_ip_addresses.__doc__, str(ex))) return output if len(argv) == 2: if (argv[1] == '' or not "usage".startswith(argv[1].lower())): output.completeOutputError( InvalidArgumentCount(3, argv[1], _show_ip_addresses.__doc__)) return output
def _edit_ip_address(output, argv): """Edit IP-address-related information syntax: [edit] ip address <ip-address> interface <interface> netmask <netmask> """ argc = len(argv) interface = None if argc < 6: output.completeOutputError( InvalidArgumentCount(syntax=_edit_ip_address.__doc__)) return output if argv[2] == '' or not "interface".startswith(argv[2].lower()): if argv[4] == '' or not "netmask".startwith(argv[4].lower()): msg = 'Expected keywords "interface" and "netmask" ' output.completeOutputError( InvalidArgumentCount(syntax=_edit_ip_address.__doc__)) return output interface = argv[3] try: checkInterface(interface) except UnknownInterfaceCheck, ex: error_msg = ex output.completeOutputError( InvalidArgumentCount(descape="Error: error_msg")) return output
def isAddName(output, name): """ Checks the name if correct then return 1 else return -1""" if lib.essentials.isAlphanumeric(name) != 0: output.completeOutputError( InvalidArgumentCount( descape= "'%s' is not valid name. \n Vfabric-name should be an alphanumeric." % (name))) return -1 if lib.essentials.isStartNumeric(name) != 0: output.completeOutputError( InvalidArgumentCount( descape= "'%s' is not valid name. \n Vfabric name should not start with an digit" % (name))) return -1 if lib.essentials.isContainSpecial(name) != 0: output.completeOutputError( InvalidArgumentCount( descape= "'%s' is not valid name. \n Vfabric name should not contain special characher" % (name))) return -1 # if lib.db.db.ifExistsInDatabase(name) == 0: # print NameError("'%s' is not valid name. \n Already Exists" % (name)) # return -1 return 0
def add(argv): """ [add ] vadapter <vadapter-name> [<general-atts>] protocol [EN <en-attrs>] | [FC <fc-attrs>] general-attrs: [vfabric_id <vfabric_id>] [io_module_id <io_module_id>] [status [ONLINE | OFFLINE]] [init_type [ HOST | NETWORK]] [assignment_type [AUTO | MANUAL | ONCE ]] [component_mask [INT]] en-attrs: [mac <mac-addr>] [promiscuous [Enabled | Disabled]] [silent_listener [Enabled | Disabled]] [vlan <vlan-value>] fc-attrs: [wwpn <world-wide-port-name>] [wwnn <world-wide-node-name>] """ output = lib.output.CLIoutput("vadapter") valid_list = ['assignment_type','component_mask','init_type', 'io_module_id','status', 'vfabric_id', 'mac', 'promiscuous', 'protocol', 'silent_listener', 'vlan' ,'wwnn', 'wwpn'] if (len(argv) < 2 ): output.completeOutputError(lib.errorhandler.InvalidArgumentCount(3, "vadapter-name", syntax=add.__doc__, descape = "Please specify the vadapter name")) return output if ( argv[1] == '?' or argv[1] == 'help'): output.completeOutputError(lib.errorhandler.InvalidArgumentCount(syntax=add.__doc__, descape = "Help")) return output _parse_edit_or_add_argv(output, argv, valid_list,syntax = add.__doc__, call_from = 'add') return output
def show(argv): """ Show Vfabric-related information syntax: show vfabric show vfabric --detail show vfabric <vfabric_id> show vfabric <vfabric-name> show vfabric [ help | ? ] """ output = lib.output.CLIoutput("vfabric", _output_handlers) # Done to mke changes if needed later with more refining. global _DETAIL_SHOW global _LIMITED_SHOW if len(argv) > 3: output.completeOutputError(InvalidArgumentCount(syntax=show.__doc__)) return output if len(argv) == 2: _DETAIL_SHOW = True _LIMITED_SHOW = False if argv[1] == "--detail": _show_vfabric(output, argv) elif argv[1] == "?" or argv[1] == "help": if vps_cli.vps_xml_mode: output.completeOutputError( InvalidArgumentCount(syntax=show.__doc__)) else: print show.__doc__ elif "-" not in argv[1]: _show_vfabric_module(output, argv, argv[1]) else: output.completeOutputError( InvalidArgumentCount(syntax=show.__doc__)) return output elif len(argv) == 1: _DETAIL_SHOW = False _LIMITED_SHOW = True _show_vfabric(output, argv) return output else: output.completeOutputError(InvalidArgumentCount(syntax=show.__doc__)) return output return output
def show(argv): """ Show Vfabric-related information syntax: show vfabric show vfabric --detail show vfabric <vfabric_id> show vfabric <vfabric-name> show vfabric [ help | ? ] """ output = lib.output.CLIoutput("vfabric", _output_handlers) # Done to mke changes if needed later with more refining. global _DETAIL_SHOW global _LIMITED_SHOW if len(argv) > 3: output.completeOutputError(InvalidArgumentCount(syntax = show.__doc__)) return output if len(argv) == 2: _DETAIL_SHOW = True _LIMITED_SHOW = False if argv[1] == "--detail": _show_vfabric(output, argv) elif argv[1] == "?" or argv[1] == "help": if vps_cli.vps_xml_mode: output.completeOutputError(InvalidArgumentCount(syntax = show.__doc__)) else: print show.__doc__ elif "-" not in argv[1]: _show_vfabric_module(output, argv, argv[1]) else: output.completeOutputError(InvalidArgumentCount(syntax = show.__doc__)) return output elif len(argv) == 1: _DETAIL_SHOW = False _LIMITED_SHOW = True _show_vfabric(output, argv) return output else: output.completeOutputError(InvalidArgumentCount(syntax = show.__doc__)) return output return output
def _edit_ip_route(output, argv): """Edit IP-route-related information syntax: [edit] ip route default gateway <gateway-address> interface <interface> """ argc = len(argv) interface = None if argc < 6: output.completeOutputError( InvalidArgumentCount(syntax=_edit_ip_route.__doc__)) return output if argv[1] == '' or not "default".startswith(argv[1].lower()) \ or argv[2] == '' or not "gateway".startswith(argv[2].lower()): msg = 'Expected initial keywords "default" and "gateway".' output.completeOutputError( InvalidArgumentCount(5, "ip-route", syntax=_edit_ip_route.__doc__, desc=msg)) return output gateway = argv[3] if argc == 5: if argv[4] == '' or not "interface".startswith(argv[4].lower()): msg = 'Expected keyword "interface".' output.completeOutputError( InvalidArgumentCount(7, "ip-route", _edit_ip_route.__doc__, msg)) return output interface = argv[5] try: checkInterface(interface) except UnknownInterfaceCheck, ex: output.completeOutputError( InvalidArgumentCount(8, "ip-route", _edit_ip_route.__doc__, "Not a Valid Interface")) return output
def _add_vfabric_fc_prop(output, argv, arg_dict, call_from): """ [edit | add] vfabric <vfabric-name> [<general-atts>] [EN <en-attrs>] | [FC <fc-attrs>] fc-attrs: [wwpn <world-wide-port-name>] [wwnn <world-wide-node-name>] """ _NON_FC_PROP = ['mac', 'vlan'] # Check for attributes which are not in fc properties. for n in _NON_FC_PROP: if arg_dict.has_key(n): output.completeOutputError( InvalidArgumentCount( syntax=_add_vfabric_fc_prop.__doc__, descape=" Keyword '%s' is not an FC attribute \n" % (n, ))) return output if arg_dict.has_key('wwpn'): if _validateWorldWideNodeOrPortName(arg_dict, 'wwpn') != 0: output.completeOutputError( InvalidArgumentCount( syntax=_add_vfabric_fc_prop.__doc__, descape=" '%s' = '%s' is not valid Value \n " % ('wwpn', arg_dict['wwpn']))) return output if arg_dict.has_key('wwnn'): if _validateWorldWideNodeOrPortName(arg_dict, 'wwnn') != 0: output.completeOutputError( InvalidArgumentCount( syntax=_add_vfabric_fc_prop.__doc__, descape=" '%s' = '%s' is not valid Value \n " % ('wwnn', arg_dict['wwnn']))) return output # FC-ID ? print arg_dict arg_dict = _editing_edit_dictionary(arg_dict) if call_from == 'edit': result = vfm.py_vfm_vfabric_edit_general_attr(arg_dict) print "vfabric edited:", result elif call_from == 'add': vfabric = vfm.py_vfm_vfabric_create(arg_dict) print "vfabric created:", vfabric return output
def _add_vfabric_en_prop(output, argv, arg_dict, call_from): """ [edit | add ] vfabric <vfabric-name> [<general-atts>] [EN <en-attrs>] | [FC <fc-attrs>] en-attrs: [mac <mac-addr>] [vlan <vlan-value>] """ _NON_EN_PROP = ['wwnn', 'wwpn', 'fcid'] # Check for attributes which are not in en properties. for n in _NON_EN_PROP: if arg_dict.has_key(n): output.completeOutputError( InvalidArgumentCount( syntax=_add_vfabric_en_prop.__doc__, descape=" Keyword '%s' is not an EN attribute" % (n, ))) return output if arg_dict.has_key('mac'): if isMAC(arg_dict['mac']) != 1: output.completeOutputError( InvalidArgumentCount(descape="\n Invalid MAC address \n ")) return output if arg_dict.has_key('vlan'): if _isVLAN(arg_dict['vlan']) != 1: output.completeOutputError( InvalidArgumentCount( descape= "\n Invalid VLAN value, Expected values : d,d,d-d or d,d or d-d Syntax:d = digit [0-9] \n" )) return output print arg_dict arg_dict = _editing_edit_dictionary(arg_dict) if call_from == 'edit': result = vfm.py_vfm_vfabric_edit_general_attr(arg_dict) print "vfabric edited:", result elif call_from == 'add': vfabric = vfm.py_vfm_vfabric_create(arg_dict) print "vfabric created:", vfabric return output
def isAddName(output, name): """ Checks the name if correct then return 1 else return -1""" if lib.essentials.isAlphanumeric(name) != 0: output.completeOutputError(InvalidArgumentCount(descape ="'%s' is not valid name. \n Vfabric-name should be an alphanumeric." % (name))) return -1 if lib.essentials.isStartNumeric(name) != 0: output.completeOutputError(InvalidArgumentCount(descape = "'%s' is not valid name. \n Vfabric name should not start with an digit"% (name))) return -1 if lib.essentials.isContainSpecial(name) != 0: output.completeOutputError(InvalidArgumentCount(descape = "'%s' is not valid name. \n Vfabric name should not contain special characher" % (name))) return -1 # if lib.db.db.ifExistsInDatabase(name) == 0: # print NameError("'%s' is not valid name. \n Already Exists" % (name)) # return -1 return 0
def _add_vadapter_fc_prop(output, argv, arg_dict, call_from): """ [edit | add] vadapter <vadapter-name> [<general-atts>] [EN <en-attrs>] | [FC <fc-attrs>] fc-attrs: [wwpn <world-wide-port-name>] [wwnn <world-wide-node-name>] """ _NON_FC_PROP = ['mac','silent_listener','promiscuous','vlan'] # Check for attributes which are not in fc properties. for n in _NON_FC_PROP: if arg_dict.has_key(n): output.completeOutputError(InvalidArgumentCount(syntax=_add_vadapter_fc_prop.__doc__, descape = " Keyword '%s' is not an FC attribute" % (n,))) return output if arg_dict.has_key('wwpn'): if _validateWorldWideNodeOrPortName(arg_dict, 'wwpn') != 0: output.completeOutputError(InvalidArgumentCount(syntax=_add_vadapter_fc_prop.__doc__, descape = " '%s' = '%s' is not valid Value" % ('wwpn',arg_dict['wwpn']))) return output if arg_dict.has_key('wwnn'): if _validateWorldWideNodeOrPortName(arg_dict, 'wwnn') != 0: output.completeOutputError(InvalidArgumentCount(syntax=_add_vadapter_fc_prop.__doc__, descape = " '%s' = '%s' is not valid Value" % ('wwnn', arg_dict['wwnn']))) return output # FC-ID ? #print arg_dict arg_dict = _editing_edit_dictionary(arg_dict) if call_from == 'edit': # # Change the dictionary according to the reggression.py # result = vfm.py_vfm_vadapter_edit_general_attr(arg_dict) print "vdapter edited:", result elif call_from == 'add': vadapter = vfm.py_vfm_vadapter_create(arg_dict) print "vadpter created:", vadapter
def _add_vfabric_fc_prop(output, argv, arg_dict, call_from): """ [edit | add] vfabric <vfabric-name> [<general-atts>] [EN <en-attrs>] | [FC <fc-attrs>] fc-attrs: [wwpn <world-wide-port-name>] [wwnn <world-wide-node-name>] """ _NON_FC_PROP = ['mac','vlan'] # Check for attributes which are not in fc properties. for n in _NON_FC_PROP: if arg_dict.has_key(n): output.completeOutputError(InvalidArgumentCount(syntax=_add_vfabric_fc_prop.__doc__, descape = " Keyword '%s' is not an FC attribute \n" % (n,))) return output if arg_dict.has_key('wwpn'): if _validateWorldWideNodeOrPortName(arg_dict, 'wwpn') != 0: output.completeOutputError(InvalidArgumentCount(syntax=_add_vfabric_fc_prop.__doc__, descape = " '%s' = '%s' is not valid Value \n " % ('wwpn',arg_dict['wwpn']))) return output if arg_dict.has_key('wwnn'): if _validateWorldWideNodeOrPortName(arg_dict, 'wwnn') != 0: output.completeOutputError(InvalidArgumentCount(syntax=_add_vfabric_fc_prop.__doc__, descape = " '%s' = '%s' is not valid Value \n " % ('wwnn', arg_dict['wwnn']))) return output # FC-ID ? print arg_dict arg_dict = _editing_edit_dictionary(arg_dict) if call_from == 'edit': result = vfm.py_vfm_vfabric_edit_general_attr(arg_dict) print "vfabric edited:", result elif call_from == 'add': vfabric = vfm.py_vfm_vfabric_create(arg_dict) print "vfabric created:", vfabric return output
def _show_ip_addresses(output, argv): """Show IP addresses syntax: show ip address [<ip-address> [usage]] """ if len(argv) > 2: output.completeOutputError(InvalidArgumentCount( syntax=_show_ip_addresses.__doc__)) return output addr = None if len(argv) >= 1: addr = argv[0] try: checkIp(addr) except UnknownIpCheck, ex: output.completeOutputError(InvalidArgumentCount(2, argv[0], _show_ip_addresses.__doc__, str(ex))) return output if len(argv) == 2: if (argv[1] == '' or not "usage".startswith(argv[1].lower())): output.completeOutputError(InvalidArgumentCount( 3, argv[1], _show_ip_addresses.__doc__)) return output
def _add_vfabric_en_prop(output, argv, arg_dict, call_from): """ [edit | add ] vfabric <vfabric-name> [<general-atts>] [EN <en-attrs>] | [FC <fc-attrs>] en-attrs: [mac <mac-addr>] [vlan <vlan-value>] """ _NON_EN_PROP = [ 'wwnn','wwpn','fcid'] # Check for attributes which are not in en properties. for n in _NON_EN_PROP: if arg_dict.has_key(n): output.completeOutputError(InvalidArgumentCount(syntax=_add_vfabric_en_prop.__doc__, descape = " Keyword '%s' is not an EN attribute" % (n,))) return output if arg_dict.has_key('mac'): if isMAC(arg_dict['mac']) != 1: output.completeOutputError(InvalidArgumentCount(descape = "\n Invalid MAC address \n ")) return output if arg_dict.has_key('vlan'): if _isVLAN(arg_dict['vlan']) != 1: output.completeOutputError(InvalidArgumentCount(descape = "\n Invalid VLAN value, Expected values : d,d,d-d or d,d or d-d Syntax:d = digit [0-9] \n")) return output print arg_dict arg_dict = _editing_edit_dictionary(arg_dict) if call_from == 'edit': result = vfm.py_vfm_vfabric_edit_general_attr(arg_dict) print "vfabric edited:", result elif call_from == 'add': vfabric = vfm.py_vfm_vfabric_create(arg_dict) print "vfabric created:", vfabric return output
output.completeOutputError(InvalidArgumentCount (syntax=edit.__doc__)) return output new_name = argv[1] try: checkHostname(new_name) except InvalidHostnameException, ex: output.completeOutputError(ex) return output #if '.' in new_name: # output.completeOutputError("cannot specify a domain") # return output if _set_hostname(new_name) != 1: output.completeOutputError("could not set the hostname") return output output.completeOutputSuccess() return output def _init(): """Hostname initialization. Reads the hostname from the configuration, and sets the hostname. """ try: hostname = lib.essentials.getHostname() cmd = (_SET_HOSTNAME_CMD, hostname) lib.process.execute_command(cmd) except: pass
"Are you sure that you want to halt the system") except lib.errorhandler.InteractiveCliRequired, ex: output.completeOutputError(ex) return output if not doit: print "\nHalt aborted." output.completeOutputSuccess() return output try: # # Instruct init to allows 45secs for processes to terminate (before # SIGKILLing them) and switch to runlevel 0. # status = os.system('/sbin/telinit -t 45 0') if status == 0: if not xml_out: print "Halting Virtual Fabric Manager..." output.completeOutputSuccess() return output else: output.completeOutputError("System halt failed.") return output except: pass output.completeOutputError("Exception calling system halt.") return output
def _parse_edit_or_add_argv(output, argv, valid_args, syntax = None, call_from = 'None'): arg_dict = {} index = 0 if len(argv[0].split()) > 1: output.completeOutputError(lib.errorhandler.InvalidArgumentCount(3, "vfabric-name", syntax, descape = "Please specify the vfabric name")) return output if call_from == "add" : if isAddName(output,argv[1]) != 0: return output elif call_from == "edit" : if isEditName(output, argv[1]) != 0: return output else: output.completeOutputError(InvalidArgumentCount(descape = "'%s' Command not found . Please type [ edit | add ] vfabric [ ? | help ] " % (argv[0]))) return output if call_from == "add" : arg_dict['name'] = argv[1] elif call_from == "edit" : arg_dict['id'] = argv[1] index = 2 len_args = len(argv) while index < len_args: args = argv[index] # Next argument should be from the valid_list if _check_valid_command_argument(valid_args, args) != 0: # Raise an Error output.completeOutputError(InvalidArgumentCount(index+3, args, syntax, descape = ("'%s' Not a valid Keyword" % args))) return output index += 1 if arg_dict.has_key(args): msg = " '%s' already specified." % (args,) output.completeOutputError(InvalidArgumentCount(index+2, args, syntax, descape = msg)) return output if (index >= len_args): if _check_valid_command_argument(valid_args, argv[index-1]) != 0: msg1 = "'%s' Not a valid Keyword" % args output.completeOutputError(InvalidArgumentCount(index+2, args, syntax,descape = msg1)) return output msg = " '%s' doesn't have the value defined" % (args,) output.completeOutputError(InvalidArgumentCount(index+2, args, syntax,descape = msg)) return output if _check_valid_command_argument(valid_args, argv[index]) == 0: msg = " '%s' is not an expected value of '%s'" % (argv[index], args) output.completeOutputError(InvalidArgumentCount(index+3, argv[index], syntax,descape = msg)) return output arg_dict[args] = argv[index] index += 1 #print arg_dict if arg_dict.has_key('protocol'): # Then it will call _add_en or add_fc respectively _add_vfabric_protcol(output, argv, arg_dict, call_from, syntax) return output else: # Add the values to the database. _add_vfabric_database(output, argv, arg_dict, call_from, syntax) return output return output
else: msg = no.__doc__ output = lib.output.CLIoutput("arp") if len(argv) > 2: output.completeOutputError(InvalidArgumentCount (syntax = msg)) return output if len(argv) == 1: arp_entries = open("/proc/net/arp", 'r').readlines() for line in arp_entries[1:]: # skip header cmd = (_ARP, "-d", line.split()[0]) lib.process.execute_command(cmd) output.completeOutputSuccess() return output ipaddr = argv[1] try: lib.essentials.checkIp(ipaddr) except InvalidIpException, ex: output.completeOutputError(ex) return output cmd = (_ARP, "-d", ipaddr) (exitval, output, err, fullstatus) = lib.process.execute_command(cmd) if exitval != 0: output.completeOutputError("IP address %s not in ARP cache" % (ipaddr,)) else: output.completeOutputSuccess() return output
def edit(argv): """Ping a host (or IP address) Syntax: ping <host> [count <count>] """ output = lib.output.CLIoutput("ping") if len(argv) == 4 and not "count".startswith(argv[2].lower()): print 'Not here' output.completeOutputError(InvalidArgumentCount (syntax=edit.__doc__, desc="Expecting 'count'", pos=2, param=argv[2])) return output if len(argv) not in [2, 4]: print 'not even here' output.completeOutputError(InvalidArgumentCount (syntax=edit.__doc__)) return output name = argv[1] count = "3" if len(argv) == 4: count = argv[3] try: cnt = int(count) if (cnt <= 0): output.completeOutputError("count should be a number greater than 0") return output if (cnt > 1024): output.completeOutputError("count should not exceed 1024") return output except ValueError: output.completeOutputError("count should be a number greater than 0") return output try: ipaddr = socket.gethostbyname(name) except socket.error, e: output.completeOutputError("cannot resolve '%s': %s" % (name, e)) return output
return output else: dict = {} dict['id'] = int(argv[1]) try: result = vfm.py_vfm_vfabric_online(dict) except StandardError, e: print "Error!", e return output else: print result return output if (argv[1] == '?' or argv[1] == 'help'): output.completeOutputError( lib.errorhandler.InvalidArgumentCount(syntax=edit.__doc__, descape="Help")) return output _parse_edit_or_add_argv(output, argv, valid_list, syntax=edit.__doc__, call_from='edit') return output def _parse_edit_or_add_argv(output, argv, valid_args,
doit = lib.essentials.confirm( "Are you sure that you want to halt the system") except lib.errorhandler.InteractiveCliRequired, ex: output.completeOutputError(ex) return output if not doit: print "\nHalt aborted." output.completeOutputSuccess() return output try: # # Instruct init to allows 45secs for processes to terminate (before # SIGKILLing them) and switch to runlevel 0. # status = os.system('/sbin/telinit -t 45 0') if status == 0: if not xml_out: print "Halting Virtual Fabric Manager..." output.completeOutputSuccess() return output else: output.completeOutputError("System halt failed.") return output except: pass output.completeOutputError("Exception calling system halt.") return output
ethernet = fields[-1] netmask = getSubNetMask(ethernet) addr = fields[1].split("/") ipAddress = addr[0] scope = fields[5] active = isActive(ethernet) _ip_address_spec(output, ipAddress, netmask, ethernet, scope, active) output.endList("IPaddressSpecList") if len(argv) == 2: _ipaddr_usage(output, address_list, addr) return if ipAddress is None: output.completeOutputError("cannot find IP address ") else: output.completeOutputSuccess() def isActive(interface): cmd = [_IFCONFIG, interface] (exitval, output, err, fullstatus) = lib.process.execute_command(cmd) to_return = 'DOWN' for ln in output[1:]: length = len(ln) if length > 1: fields = ln.split() if fields[0].find('UP') == 0: return fields[0] else:
output.completeOutputError("count should be a number greater than 0") return output if (cnt > 1024): output.completeOutputError("count should not exceed 1024") return output except ValueError: output.completeOutputError("count should be a number greater than 0") return output try: ipaddr = socket.gethostbyname(name) except socket.error, e: output.completeOutputError("cannot resolve '%s': %s" % (name, e)) return output try: pipe = popen2.Popen4("/bin/ping -nb -c %d -w %d %s" % \ (cnt, cnt+10, name), 0) #output.beginList("PingSpecList") output.beginAssembling("Ping") output.setVirtualNameValue("PingOutput", pipe) output.endAssembling("Ping") #output.endList("PingSpecList") output.completeOutputSuccess() except OSError, e: output.completeOutputError("Internal error: ping failed: %s" % (e,)) return output
def edit(argv): """ [edit] vfabric <vfabric-id> online [edit] vfabric <vfabric-id> [<general-attrs>] protocol [EN <en-attrs>] | [FC <fc-attrs>] general-attrs: [running_mode <OFFLINE | ONLINE>] [desc <"DETAILS">] [ha_state < NORMAL | FAILOVER>] [auto_failover < DISABLED | ENABLED>] [auto_failback < DISABLED | ENABLED>] [primary_gw_id <primary_gw_id>] [backup_gw_id <backup_gw_id>] [protocol <protocol>] [component_mask <component_mask>] en-attrs: [mac <mac-addr>] [vlan <vlan-value>] fc-attrs: [wwpn <world-wide-port-name>] [wwnn <world-wide-node-name>] """ output = lib.output.CLIoutput("vfabric") valid_list = [ 'primary_gw_id', 'backup_gw_id', 'running_mode', 'desc', 'ha_state', 'component_mask', 'type', 'mac', 'auto_failover', 'auto_failback', 'protocol', 'vlan', 'wwnn', 'wwpn', ] if (len(argv) < 2): output.completeOutputError( lib.errorhandler.InvalidArgumentCount( 3, "vfabric-id", syntax=edit.__doc__, descape="Please specify the vfabric id")) return output if (argv[1] == '?' or argv[1] == 'help'): output.completeOutputError( lib.errorhandler.InvalidArgumentCount(syntax=edit.__doc__, descape="Help")) return output if argv[2].lower() == 'online': if isEditName(output, argv[1]) == -1: print "Error Not a valid Id" return output else: dict = {} dict['id'] = int(argv[1]) try: result = vfm.py_vfm_vfabric_online(dict) except StandardError, e: print "Error!", e return output else: print result return output
def _parse_edit_or_add_argv(output, argv, valid_args, syntax=None, call_from='None'): arg_dict = {} index = 0 if len(argv[0].split()) > 1: output.completeOutputError( lib.errorhandler.InvalidArgumentCount( 3, "vfabric-name", syntax, descape="Please specify the vfabric name")) return output if call_from == "add": if isAddName(output, argv[1]) != 0: return output elif call_from == "edit": if isEditName(output, argv[1]) != 0: return output else: output.completeOutputError( InvalidArgumentCount( descape= "'%s' Command not found . Please type [ edit | add ] vfabric [ ? | help ] " % (argv[0]))) return output if call_from == "add": arg_dict['name'] = argv[1] elif call_from == "edit": arg_dict['id'] = argv[1] index = 2 len_args = len(argv) while index < len_args: args = argv[index] # Next argument should be from the valid_list if _check_valid_command_argument(valid_args, args) != 0: # Raise an Error output.completeOutputError( InvalidArgumentCount(index + 3, args, syntax, descape=("'%s' Not a valid Keyword" % args))) return output index += 1 if arg_dict.has_key(args): msg = " '%s' already specified." % (args, ) output.completeOutputError( InvalidArgumentCount(index + 2, args, syntax, descape=msg)) return output if (index >= len_args): if _check_valid_command_argument(valid_args, argv[index - 1]) != 0: msg1 = "'%s' Not a valid Keyword" % args output.completeOutputError( InvalidArgumentCount(index + 2, args, syntax, descape=msg1)) return output msg = " '%s' doesn't have the value defined" % (args, ) output.completeOutputError( InvalidArgumentCount(index + 2, args, syntax, descape=msg)) return output if _check_valid_command_argument(valid_args, argv[index]) == 0: msg = " '%s' is not an expected value of '%s'" % (argv[index], args) output.completeOutputError( InvalidArgumentCount(index + 3, argv[index], syntax, descape=msg)) return output arg_dict[args] = argv[index] index += 1 #print arg_dict if arg_dict.has_key('protocol'): # Then it will call _add_en or add_fc respectively _add_vfabric_protcol(output, argv, arg_dict, call_from, syntax) return output else: # Add the values to the database. _add_vfabric_database(output, argv, arg_dict, call_from, syntax) return output return output