def validate_port_name(port): """Valid port names for this switch are of the form 1/0/1 or 1/2""" val = re.compile(r'^\d+/\d+(/\d+)?$') if not val.match(port): raise BadArgumentError("Invalid port name. Valid port names for " "this switch are of the from 1/0/1 or 1/2") return
def validate_port_name(port): """ Valid port names for this switch are of the form gi1/0/11, te1/0/12, gi1/12, or te1/3 """ val = re.compile(r'^(gi|te)\d+/\d+(/\d+)?$') if not val.match(port): raise BadArgumentError("Invalid port name. Valid port names for " "this switch are of the form gi1/0/11, " "te1/0/12, gi1/12, or te1/3") return
def validate_port_name(port): """ Valid port names for this switch are of the form: Ethernet1/12, ethernet1/12, Ethernet1/0/10, or ethernet1/0/10 """ val = re.compile(r'^(E|e)thernet\d+/\d+(/\d+)?$') if not val.match(port): raise BadArgumentError("Invalid port name. Valid port names for " "this switch are of the form: Ethernet1/12" " ethernet1/12, Ethernet1/0/10, or" " ethernet1/0/10") return
def require_legal_bootdev(self, dev): if dev not in self.valid_bootdevices: raise BadArgumentError('Invald boot device')
def check_reserved(obj_type, obj_string, slashes_ok=False): """Check for illegal characters and report of their existence""" bad_chars = _find_reserved(obj_string, slashes_ok) if bool(bad_chars): error = obj_type + " may not contain: " + str(bad_chars) raise BadArgumentError(error)