def register(self, node, obmd_uri, obmd_admin_token, subtype, *args): """Register a node with appropriate OBM driver. """ # Registering a node requires apriori knowledge of the # available OBM driver and its corresponding arguments. # We assume that the HIL administrator is aware as to which # Node requires which OBM, and knows arguments required # for successful node registration. if (len(args) != 3): raise BadArgumentError("3 Arguments needed. Supplied " + str(len(args))) obm_api = "http://schema.massopencloud.org/haas/v0/obm/" # This is a bit of a hack, but this block of code will be removed # soon when obmd becomes the only mechanism. obm_types = ["ipmi", "mock"] if subtype in obm_types: obminfo = { "type": obm_api + subtype, "host": args[0], "user": args[1], "password": args[2] } else: raise UnknownSubtypeError("Unknown subtype provided.") url = self.object_url('node', node) payload = json.dumps({ "obm": obminfo, "obmd": { 'uri': obmd_uri, 'admin_token': obmd_admin_token, }, }) return self.check_response( self.httpClient.request('PUT', url, data=payload))
def register(self, node, subtype, *args): """Register a node with appropriate OBM driver. """ # Registering a node requires apriori knowledge of the # available OBM driver and its corresponding arguments. # We assume that the HIL administrator is aware as to which # Node requires which OBM, and knows arguments required # for successful node registration. # FIXME: In future obm_types should be dynamically fetched. # We need a new api call for querying available # and currently active drivers for HIL # obm_api = "http://schema.massopencloud.org/haas/v0/obm/" # obm_types = ["ipmi", "mock"] if (len(args) != 3): raise BadArgumentError("3 Arguments needed. Supplied " + str(len(args))) obm_api = "http://schema.massopencloud.org/haas/v0/obm/" # This is a temp fix. obmd will let node_register no longer # need a type so a new design will be required. obm_types = ["ipmi", "mock"] if subtype in obm_types: obminfo = { "type": obm_api + subtype, "host": args[0], "user": args[1], "password": args[2] } else: raise UnknownSubtypeError("Unknown subtype provided.") url = self.object_url('node', node) payload = json.dumps({"obm": obminfo}) return self.check_response( self.httpClient.request('PUT', url, data=payload))
def validate_port_name(port): """Valid port names for this switch are of the form 1/0/1 or 1/2""" if not re.match(r'^\d+/\d+(/\d+)?$', port): raise BadArgumentError("Invalid port name. Valid port names for " "this switch are of the form 1/0/1 or 1/2") return
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)