Here are the examples of the python api foam.geni.db.GeniDB.getSliverData taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
11 Examples
3
Example 1
Project: ocf Source File: gapi1.py
def pub_RenewSliver (self, slice_urn, credentials, exptime):
try:
if CredVerifier.checkValid(credentials, "renewsliver", slice_urn):
self.recordAction("renewsliver", credentials, slice_urn)
creds = CredVerifier.fromStrings(credentials, "renewsliver", slice_urn)
sliver_urn = foam.lib.renewSliver(slice_urn, creds, exptime)
data = GeniDB.getSliverData(sliver_urn, True)
foam.task.emailRenewSliver(data)
return True
return False
except foam.lib.BadSliverExpiration, e:
self._log.info("Bad expiration request: %s" % (e.msg))
e._foam_logged = True
raise e
except Exception, e:
self._log.exception("Exception")
raise e
3
Example 2
def __json__ (self):
data = self.getDataDict(True)
if self.__urn:
dbdata = GeniDB.getSliverData(self.__urn, False)
data.update(dbdata)
return data
3
Example 3
Project: ocf Source File: lib.py
def emailCheck (self, now):
tdw = datetime.timedelta(7)
tdd = datetime.timedelta(hours=30)
exp = self.getExpiration()
if not self.getEmailStatus("day"):
if now + tdd > exp:
foam.task.emailSliverExpDay(GeniDB.getSliverData(self.__urn, True))
self.setEmailStatus("day")
self.setEmailStatus("week")
self.store()
return (self.__urn, 1)
if not self.getEmailStatus("week"):
if now + tdw > exp:
foam.task.emailSliverExpWeek(GeniDB.getSliverData(self.__urn, True))
self.setEmailStatus("week")
self.store()
return (self.__urn, 2)
return (self.__urn, 0)
0
Example 4
@route('/core/admin/delete-sliver', methods=["POST"])
def deleteSliver (self):
if not request.json:
return
try:
self.validate(request.json, [("sliver_urn", (unicode,str))])
data = GeniDB.getSliverData(request.json["sliver_urn"], True)
foam.geni.lib.deleteSliver(sliver_urn=request.json["sliver_urn"])
foam.task.emailJSONDeleteSliver(data)
return jsonify(None)
except JSONValidationError, e:
jd = e.__json__()
return jsonify(jd, code = 1, msg = jd["exception"])
except Exception, e:
self._log.exception("Exception")
return jsonify(None, code = 2, msg = traceback.format_exc())
0
Example 5
Project: ocf Source File: admin.py
def gapi_CreateSliver(self, slice_urn, credentials, rspec, users, force_approval=False, options=None):
#GENI API imports
from foam.geni.db import GeniDB, UnknownSlice, UnknownNode
import foam.geni.approval
import foam.geni.ofeliaapproval
import sfa
user_info = users
try:
if True:
#self.recordAction("createsliver", credentials, slice_urn)
try:
self._log.debug("Parsed user cert with URN (%(urn)s) and email (%(email)s)" % users)
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)
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
else:
approve = foam.geni.ofeliaapproval.of_analyzeForApproval(sliver)
if approve or force_approval:
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 self.successResult(GeniDB.getManifest(sliver.getURN()))
return
except foam.geni.lib.RspecParseError, e:
self._log.info(str(e))
e._foam_logged = True
raise e
except foam.geni.lib.RspecValidationError, e:
self._log.info(str(e))
e._foam_logged = True
raise e
except foam.geni.lib.DuplicateSliver, ds:
self._log.info("Attempt to create multiple slivers for slice [%s]" % (ds.slice_urn))
ds._foam_logged = True
raise ds
except foam.geni.lib.UnknownComponentManagerID, ucm:
raise Fault("UnknownComponentManager", "Component Manager ID specified in %s does not match this aggregate." % (ucm.cid))
except (foam.geni.lib.UnmanagedComponent, UnknownNode), uc:
self._log.info("Attempt to request unknown component %s" % (uc.cid))
f = Fault("UnmanagedComponent", "DPID in component %s is unknown to this aggregate." % (uc.cid))
f._foam_logged = True
raise f
except Exception, e:
self._log.exception("Exception")
raise e
0
Example 6
Project: ocf Source File: gapi1.py
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
except foam.geni.lib.RspecParseError, e:
self._log.info(str(e))
e._foam_logged = True
raise e
except foam.geni.lib.RspecValidationError, e:
self._log.info(str(e))
e._foam_logged = True
raise e
except foam.geni.lib.DuplicateSliver, ds:
self._log.info("Attempt to create multiple slivers for slice [%s]" % (ds.slice_urn))
ds._foam_logged = True
raise ds
except foam.geni.lib.UnknownComponentManagerID, ucm:
raise Fault("UnknownComponentManager", "Component Manager ID specified in %s does not match this aggregate." % (ucm.cid))
except (foam.geni.lib.UnmanagedComponent, UnknownNode), uc:
self._log.info("Attempt to request unknown component %s" % (uc.cid))
f = Fault("UnmanagedComponent", "DPID in component %s is unknown to this aggregate." % (uc.cid))
f._foam_logged = True
raise f
except Exception, e:
self._log.exception("Exception")
raise e
0
Example 7
Project: ocf Source File: gapi2.py
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
0
Example 8
def pub_RenewSliver (self, slice_urn, credentials, exptime, options):
"""Renew the reservation for resources in this slice"""
try:
if CredVerifier.checkValid(credentials, "renewsliver", slice_urn):
self.recordAction("renewsliver", credentials, slice_urn)
creds = CredVerifier.fromStrings(credentials, "renewsliver", slice_urn)
sliver_urn = foam.lib.renewSliver(slice_urn, creds, exptime)
data = GeniDB.getSliverData(sliver_urn, True)
foam.task.emailRenewSliver(data)
propertyList = self.buildPropertyList(GENI_ERROR_CODE.SUCCESS, value=True)
except foam.lib.BadSliverExpiration as e:
msg = "Bad expiration request: %s" % (e.msg)
propertyList = self.buildPropertyList(GENI_ERROR_CODE.ERROR, output=msg)
e.log(self._log, msg, logging.INFO)
except Exception:
msg = "Exception"
propertyList = self.buildPropertyList(GENI_ERROR_CODE.ERROR, output=msg)
self._log.exception("Exception")
finally:
return propertyList
0
Example 9
Project: ocf Source File: legacyexpedientapi.py
def priv_CreateSliver(self, slice_urn, credentials, rspec, users, force_approval=False, options=None):
#user_info = {}
user_info = users
try:
#if CredVerifier.checkValid(credentials, "createsliver"):
if True:
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)" % users)
except Exception, e:
self._log.exception("UNFILTERED EXCEPTION")
user_info["urn"] = None
user_info["email"] = None
from foam.app import admin_apih
if not admin_apih.vlan_automation_on:
sliver = foam.geni.lib.createSliver(slice_urn, credentials, rspec, user_info)
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
else:
approve = foam.geni.ofeliaapproval.of_analyzeForApproval(sliver)
if approve or force_approval:
pid = foam.task.approveSliver(sliver.getURN(), AUTO_SLIVER_PRIORITY)
self._log.debug("task.py launched for approve-sliver (PID: %d)" % pid)
else:
free_vlan_list = self.pub_get_offered_vlans(1)
free_vlan = free_vlan_list[0]
slice_id = slice_urn.split("+slice+")[1].split(":")[0].split("id_")[1].split("name_")[0]
#filedir = './opt/ofelia/ofam/local/db'
#filename = os.path.join(filedir, 'expedient_slices_info.json')
#f = open(filename, 'r')
#self.slice_info_dict = json.load(f)
#f.close()
if (slice_id == "") or (slice_id not in self.slice_info_dict):
self._log.exception("The slice id you specified is non-existent")
raise Exception
updated_slice_info_dict = self.slice_info_dict.copy()
for sliv_pos, sliver in enumerate(self.slice_info_dict[slice_id]['switch_slivers']):
for sfs_pos, sfs in enumerate(sliver['flowspace']):
updated_slice_info_dict[slice_id]['switch_slivers'][sliv_pos]['flowspace'][sfs_pos]['vlan_id_start'] = free_vlan
updated_slice_info_dict[slice_id]['switch_slivers'][sliv_pos]['flowspace'][sfs_pos]['vlan_id_end'] = free_vlan
all_efs = self.create_slice_fs(updated_slice_info_dict[slice_id]['switch_slivers'])
new_slice_of_rspec = create_ofv3_rspec(slice_id, updated_slice_info_dict[slice_id]['project_name'], updated_slice_info_dict[slice_id]['project_desc'], \
updated_slice_info_dict[slice_id]['slice_name'], updated_slice_info_dict[slice_id]['slice_desc'], \
updated_slice_info_dict[slice_id]['controller_url'], updated_slice_info_dict[slice_id]['owner_email'], \
updated_slice_info_dict[slice_id]['owner_password'], \
updated_slice_info_dict[slice_id]['switch_slivers'], all_efs)
self.slice_info_dict = updated_slice_info_dict.copy()
sliver = foam.geni.lib.createSliver(slice_urn, credentials, new_slice_of_rspec, user_info)
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 self.successResult(GeniDB.getManifest(sliver.getURN()))
return
except foam.geni.lib.RspecParseError, e:
self._log.info(str(e))
e._foam_logged = True
raise e
except foam.geni.lib.RspecValidationError, e:
self._log.info(str(e))
e._foam_logged = True
raise e
except foam.geni.lib.DuplicateSliver, ds:
self._log.info("Attempt to create multiple slivers for slice [%s]" % (ds.slice_urn))
ds._foam_logged = True
raise ds
except foam.geni.lib.UnknownComponentManagerID, ucm:
raise Fault("UnknownComponentManager", "Component Manager ID specified in %s does not match this aggregate." % (ucm.cid))
except (foam.geni.lib.UnmanagedComponent, UnknownNode), uc:
self._log.info("Attempt to request unknown component %s" % (uc.cid))
f = Fault("UnmanagedComponent", "DPID in component %s is unknown to this aggregate." % (uc.cid))
f._foam_logged = True
raise f
except Exception, e:
self._log.exception("Exception")
raise e
0
Example 10
Project: ocf Source File: sfaapi.py
def pub_CreateSliver(self, slice_xrn, creds, 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.
"""
try:
self.pm.check_permissions('CreateSliver',locals())
except Exception as e:
return self.buildPropertyList(GENI_ERROR_CODE.CREDENTIAL_INVALID, output=e)
self.recordAction("createsliver", creds, slice_xrn)
user_info = {}
user_info["urn"] = None
user_info["email"] = None
request.environ.pop("CLIENT_RAW_CERT",None)
sliver = foam.geni.lib.createSliver(slice_xrn, creds, rspec, user_info)
try:
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)
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)
self._log.info(e)
return msg
propertyList = self.buildPropertyList(GENI_ERROR_CODE.BADARGS, output=msg)
except foam.geni.lib.RspecValidationError as e:
self._log.info(e)
msg = str(e)
return msg
propertyList = self.buildPropertyList(GENI_ERROR_CODE.BADARGS, output=msg)
except foam.geni.lib.DuplicateSliver as ds:
msg = "Attempt to create multiple slivers for slice [%s]" % (ds.slice_urn)
self._log.info(msg)
propertyList = self.buildPropertyList(GENI_ERROR_CODE.ERROR, output=msg)
except foam.geni.lib.UnknownComponentManagerID as ucm:
msg = "Component Manager ID specified in %s does not match this aggregate." % (ucm.cid)
self._log.info(msg)
propertyList = self.buildPropertyList(GENI_ERROR_CODE.ERROR, output=msg)
except (foam.geni.lib.UnmanagedComponent, UnknownNode) as uc:
msg = "DPID in component %s is unknown to this aggregate." % (uc.cid)
self._log.info(msg)
propertyList = self.buildPropertyList(GENI_ERROR_CODE.ERROR, output=msg)
except Exception as e:
msg = "Exception %s" % str(e)
self._log.info(e)
propertyList = self.buildPropertyList(GENI_ERROR_CODE.ERROR, output=msg)
finally:
return propertyList
0
Example 11
def pub_RenewSliver(self,slice_xrn=None, creds=[], expiration_time=None, options={}):
try:
self.pm.check_permissions('Start',locals())
except Exception as e:
return self.buildPropertyList(GENI_ERROR_CODE.CREDENTIAL_INVALID, output=e)
try:
sliver_urn = foam.lib.renewSliver(slice_xrn, creds, expiration_time)
data = GeniDB.getSliverData(sliver_xrn, True)
#foam.task.emailRenewSliver(data)
propertyList = self.buildPropertyList(GENI_ERROR_CODE.SUCCESS, value=True)
except foam.lib.BadSliverExpiration as e:
msg = "Bad expiration request: %s" % (e.msg)
propertyList = self.buildPropertyList(GENI_ERROR_CODE.ERROR, output=msg)
e.log(self._log, msg, logging.INFO)
except Exception as e:
msg = "Exception: %s" %str(e)
propertyList = self.buildPropertyList(GENI_ERROR_CODE.ERROR, output=msg)
self._log.exception(msg)
finally:
return propertyList