def pub_CreateSliver (self, slice_urn, credentials, rspec, users): user_info = {} try: if CredVerifier.checkValid(credentials, "createsliver"): self.recordAction("createsliver", credentials, slice_urn) try: cert = Certificate(request.environ['CLIENT_RAW_CERT']) user_info["urn"] = cert.getURN() user_info["email"] = cert.getEmailAddress() self._log.debug("Parsed user cert with URN (%(urn)s) and email (%(email)s)" % user_info) except Exception, e: self._log.exception("UNFILTERED EXCEPTION") user_info["urn"] = None user_info["email"] = None sliver = foam.geni.lib.createSliver(slice_urn, credentials, rspec, user_info) approve = foam.geni.approval.analyzeForApproval(sliver) style = ConfigDB.getConfigItemByKey("geni.approval.approve-on-creation").getValue() if style == foam.geni.approval.NEVER: approve = False elif style == foam.geni.approval.ALWAYS: approve = True if approve: pid = foam.task.approveSliver(sliver.getURN(), AUTO_SLIVER_PRIORITY) self._log.debug("task.py launched for approve-sliver (PID: %d)" % pid) data = GeniDB.getSliverData(sliver.getURN(), True) foam.task.emailCreateSliver(data) return GeniDB.getManifest(sliver.getURN()) return
def pub_CreateSliver (self, slice_urn, credentials, rspec, users, options): """Allocate resources to a slice Reserve the resources described in the given RSpec for the given slice, returning a manifest RSpec of what has been reserved. """ user_info = {} try: if CredVerifier.checkValid(credentials, "createsliver"): self.recordAction("createsliver", credentials, slice_urn) try: cert = Certificate(request.environ['CLIENT_RAW_CERT']) user_info["urn"] = cert.getURN() user_info["email"] = cert.getEmailAddress() self._log.debug("Parsed user cert with URN (%(urn)s) and email (%(email)s)" % user_info) except Exception as e: self._log.exception("UNFILTERED EXCEPTION") user_info["urn"] = None user_info["email"] = None sliver = foam.geni.lib.createSliver(slice_urn, credentials, rspec, user_info) approve = foam.geni.approval.analyzeForApproval(sliver) style = ConfigDB.getConfigItemByKey("geni.approval.approve-on-creation").getValue() if style == foam.geni.approval.NEVER: approve = False elif style == foam.geni.approval.ALWAYS: approve = True if approve: pid = foam.task.approveSliver(sliver.getURN(), self._auto_priority) self._log.debug("task.py launched for approve-sliver (PID: %d)" % pid) data = GeniDB.getSliverData(sliver.getURN(), True) foam.task.emailCreateSliver(data) propertyList = self.buildPropertyList(GENI_ERROR_CODE.SUCCESS, value=GeniDB.getManifest(sliver.getURN())) except foam.geni.lib.RspecParseError as e: msg = str(e) propertyList = self.buildPropertyList(GENI_ERROR_CODE.BADARGS, output=msg) e.log(self._log, msg, logging.INFO) except foam.geni.lib.RspecValidationError as e: msg = str(e) propertyList = self.buildPropertyList(GENI_ERROR_CODE.BADARGS, output=msg) e.log(self._log, msg, logging.INFO) except foam.geni.lib.DuplicateSliver as ds: msg = "Attempt to create multiple slivers for slice [%s]" % (ds.slice_urn) propertyList = self.buildPropertyList(GENI_ERROR_CODE.ERROR, output=msg) ds.log(self._log, msg, logging.INFO) except foam.geni.lib.UnknownComponentManagerID as ucm: msg = "Component Manager ID specified in %s does not match this aggregate." % (ucm.cid) propertyList = self.buildPropertyList(GENI_ERROR_CODE.ERROR, output=msg) ucm.log(self._log, msg, logging.INFO) except (foam.geni.lib.UnmanagedComponent, UnknownNode) as uc: msg = "DPID in component %s is unknown to this aggregate." % (uc.cid) propertyList = self.buildPropertyList(GENI_ERROR_CODE.ERROR, output=msg) uc.log(self._log, msg, logging.INFO) except Exception: msg = "Exception" propertyList = self.buildPropertyList(GENI_ERROR_CODE.ERROR, output=msg) self._log.exception(msg) finally: return propertyList
def pub_CreateSliver(self, slice_urn, credentials, rspec, users, options): """Allocate resources to a slice Reserve the resources described in the given RSpec for the given slice, returning a manifest RSpec of what has been reserved. """ user_info = {} try: if CredVerifier.checkValid(credentials, "createsliver"): self.recordAction("createsliver", credentials, slice_urn) try: cert = Certificate(request.environ['CLIENT_RAW_CERT']) user_info["urn"] = cert.getURN() user_info["email"] = cert.getEmailAddress() self._log.debug( "Parsed user cert with URN (%(urn)s) and email (%(email)s)" % user_info) except Exception as e: self._log.exception("UNFILTERED EXCEPTION") user_info["urn"] = None user_info["email"] = None sliver = foam.geni.lib.createSliver(slice_urn, credentials, rspec, user_info) approve = foam.geni.approval.analyzeForApproval(sliver) style = ConfigDB.getConfigItemByKey( "geni.approval.approve-on-creation").getValue() if style == foam.geni.approval.NEVER: approve = False elif style == foam.geni.approval.ALWAYS: approve = True if approve: pid = foam.task.approveSliver(sliver.getURN(), self._auto_priority) self._log.debug( "task.py launched for approve-sliver (PID: %d)" % pid) data = GeniDB.getSliverData(sliver.getURN(), True) foam.task.emailCreateSliver(data) propertyList = self.buildPropertyList(GENI_ERROR_CODE.SUCCESS, value=GeniDB.getManifest( sliver.getURN())) except foam.geni.lib.RspecParseError as e: msg = str(e) propertyList = self.buildPropertyList(GENI_ERROR_CODE.BADARGS, output=msg) e.log(self._log, msg, logging.INFO) except foam.geni.lib.RspecValidationError as e: msg = str(e) propertyList = self.buildPropertyList(GENI_ERROR_CODE.BADARGS, output=msg) e.log(self._log, msg, logging.INFO) except foam.geni.lib.DuplicateSliver as ds: msg = "Attempt to create multiple slivers for slice [%s]" % ( ds.slice_urn) propertyList = self.buildPropertyList(GENI_ERROR_CODE.ERROR, output=msg) ds.log(self._log, msg, logging.INFO) except foam.geni.lib.UnknownComponentManagerID as ucm: msg = "Component Manager ID specified in %s does not match this aggregate." % ( ucm.cid) propertyList = self.buildPropertyList(GENI_ERROR_CODE.ERROR, output=msg) ucm.log(self._log, msg, logging.INFO) except (foam.geni.lib.UnmanagedComponent, UnknownNode) as uc: msg = "DPID in component %s is unknown to this aggregate." % ( uc.cid) propertyList = self.buildPropertyList(GENI_ERROR_CODE.ERROR, output=msg) uc.log(self._log, msg, logging.INFO) except Exception: msg = "Exception" propertyList = self.buildPropertyList(GENI_ERROR_CODE.ERROR, output=msg) self._log.exception(msg) finally: return propertyList