本文整理匯總了Python中foam.geni.db.GeniDB.getSliverData方法的典型用法代碼示例。如果您正苦於以下問題:Python GeniDB.getSliverData方法的具體用法?Python GeniDB.getSliverData怎麽用?Python GeniDB.getSliverData使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類foam.geni.db.GeniDB
的用法示例。
在下文中一共展示了GeniDB.getSliverData方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: pub_SliverStatus
# 需要導入模塊: from foam.geni.db import GeniDB [as 別名]
# 或者: from foam.geni.db.GeniDB import getSliverData [as 別名]
def pub_SliverStatus (self, slice_urn, credentials, options):
"""Returns the status of the reservation for this slice at this aggregate"""
try:
if CredVerifier.checkValid(credentials, "sliverstatus", slice_urn):
self.recordAction("sliverstatus", credentials, slice_urn)
result = {}
sliver_urn = GeniDB.getSliverURN(slice_urn)
if not sliver_urn:
raise Exception("Sliver for slice URN (%s) does not exist" % (slice_urn))
sdata = GeniDB.getSliverData(sliver_urn, True)
status = foam.geni.lib.getSliverStatus(sliver_urn)
result["geni_urn"] = sliver_urn
result["geni_status"] = status
result["geni_resources"] = [{"geni_urn" : sliver_urn, "geni_status": status, "geni_error" : ""}]
result["foam_status"] = sdata["status"]
result["foam_expires"] = sdata["expiration"]
result["foam_pend_reason"] = sdata["pend_reason"]
propertyList = self.buildPropertyList(GENI_ERROR_CODE.SUCCESS, value=result)
except UnknownSlice as e:
msg = "Attempt to get status on unknown sliver for slice %s" % (slice_urn)
propertyList = self.buildPropertyList(GENI_ERROR_CODE.SEARCHFAILED, 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
示例2: pub_CreateSliver
# 需要導入模塊: from foam.geni.db import GeniDB [as 別名]
# 或者: from foam.geni.db.GeniDB import getSliverData [as 別名]
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
示例3: pub_DeleteSliver
# 需要導入模塊: from foam.geni.db import GeniDB [as 別名]
# 或者: from foam.geni.db.GeniDB import getSliverData [as 別名]
def pub_DeleteSliver (self, slice_urn, credentials, options):
"""Delete a sliver
Stop all the slice's resources and remove the reservation.
Returns True or False indicating whether it did this successfully.
"""
try:
if CredVerifier.checkValid(credentials, "deletesliver", slice_urn):
self.recordAction("deletesliver", credentials, slice_urn)
if GeniDB.getSliverURN(slice_urn) is None:
raise UnkownSlice(slice_urn)
sliver_urn = GeniDB.getSliverURN(slice_urn)
data = GeniDB.getSliverData(sliver_urn, True)
foam.geni.lib.deleteSliver(sliver_urn = sliver_urn)
foam.task.emailGAPIDeleteSliver(data)
propertyList = self.buildPropertyList(GENI_ERROR_CODE.SUCCESS, value=True)
except UnknownSlice as e:
msg = "Attempt to delete unknown sliver for slice URN %s" % (slice_urn)
propertyList = self.buildPropertyList(GENI_ERROR_CODE.SEARCHFAILED, 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("Exception")
finally:
return propertyList
示例4: pub_DeleteSliver
# 需要導入模塊: from foam.geni.db import GeniDB [as 別名]
# 或者: from foam.geni.db.GeniDB import getSliverData [as 別名]
def pub_DeleteSliver(self, xrn, creds, options={}):
"""Delete a sliver
Stop all the slice's resources and remove the reservation.
Returns True or False indicating whether it did this successfully.
"""
try:
self.pm.check_permissions("DeleteSliver", locals())
except Exception as e:
return self.buildPropertyList(GENI_ERROR_CODE.CREDENTIAL_INVALID, output=e)
self._log.info("Is HERE:")
try:
slivers = GeniDB.getSliverList()
self._log.info("Is HERE:")
sliver = get_slice_details_from_slivers(slivers, xrn)
self._log.info("Deleteing Sliver")
self._log.info(sliver["slice_urn"])
data = GeniDB.getSliverData(sliver["sliver_urn"], True)
foam.geni.lib.deleteSliver(sliver_urn=sliver["sliver_urn"])
# foam.task.emailGAPIDeleteSliver(data)
propertyList = self.buildPropertyList(GENI_ERROR_CODE.SUCCESS, value=True)
except UnknownSlice as e:
propertyList = self.buildPropertyList(GENI_ERROR_CODE.SEARCHFAILED, output=msg)
except Exception as e:
msg = "Exception: %s" % str(e)
propertyList = self.buildPropertyList(GENI_ERROR_CODE.ERROR, output=msg)
finally:
return propertyList
示例5: gapi_CreateSliver
# 需要導入模塊: from foam.geni.db import GeniDB [as 別名]
# 或者: from foam.geni.db.GeniDB import getSliverData [as 別名]
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
示例6: approveSliver
# 需要導入模塊: from foam.geni.db import GeniDB [as 別名]
# 或者: from foam.geni.db.GeniDB import getSliverData [as 別名]
def approveSliver (request, logger):
try:
jsonValidate(request.json, [("sliver_urn", (unicode,str)), ("priority", int)], logger)
if (not request.json.has_key("sliver_urn")) or (not request.json.has_key("priority")):
return jsonify({"exception" : "You must specify a sliver_urn and priority"})
slice_name = GeniDB.getFlowvisorSliceName(sliver_urn=request.json["sliver_urn"])
if FV.sliceExists(slice_name):
return jsonify({"Fault" : "Flowvisor slice '%s' already exists" % (slice_name)})
sobj = GeniDB.getSliverObj(request.json["sliver_urn"])
GeniDB.setSliverStatus(request.json["sliver_urn"], True)
GeniDB.setSliverPriority(request.json["sliver_urn"], request.json["priority"])
GeniDB.commit()
foam.geni.approval.AppData.addSliver(sobj)
sobj.createSlice()
sobj.insertFlowspace(request.json["priority"])
sobj.insertVirtualLink()
data = GeniDB.getSliverData(sobj.getURN(), True)
foam.task.emailApproveSliver(data)
return jsonify(None)
except JSONValidationError, e:
jd = e.__json__()
return jsonify(jd, code = 1, msg = jd["exception"])
示例7: priv_CreateSliver
# 需要導入模塊: from foam.geni.db import GeniDB [as 別名]
# 或者: from foam.geni.db.GeniDB import getSliverData [as 別名]
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
示例8: pub_CreateSliver
# 需要導入模塊: from foam.geni.db import GeniDB [as 別名]
# 或者: from foam.geni.db.GeniDB import getSliverData [as 別名]
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
示例9: pub_Shutdown
# 需要導入模塊: from foam.geni.db import GeniDB [as 別名]
# 或者: from foam.geni.db.GeniDB import getSliverData [as 別名]
def pub_Shutdown (self, slice_urn, credentials, options):
"""Perform an emergency shutdown of the resources in a slice at this aggregate"""
if CredVerifier.checkValid(credentials, "shutdown", slice_urn):
self.recordAction("shutdown", credentials, slice_urn)
#foam.lib.shutdown(slice_urn)
sliver_urn = GeniDB.getSliverURN(slice_urn)
data = GeniDB.getSliverData(sliver_urn, True)
foam.geni.lib.deleteSliver(sliver_urn = sliver_urn)
return self.buildPropertyList(GENI_ERROR_CODE.SUCCESS, value=True)
return self.buildPropertyList(GENI_ERROR_CODE.SUCCESS, value=False)
示例10: emailCheck
# 需要導入模塊: from foam.geni.db import GeniDB [as 別名]
# 或者: from foam.geni.db.GeniDB import getSliverData [as 別名]
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)
示例11: pub_RenewSliver
# 需要導入模塊: from foam.geni.db import GeniDB [as 別名]
# 或者: from foam.geni.db.GeniDB import getSliverData [as 別名]
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
示例12: deleteSliver
# 需要導入模塊: from foam.geni.db import GeniDB [as 別名]
# 或者: from foam.geni.db.GeniDB import getSliverData [as 別名]
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"])
示例13: priv_DeleteSliver
# 需要導入模塊: from foam.geni.db import GeniDB [as 別名]
# 或者: from foam.geni.db.GeniDB import getSliverData [as 別名]
def priv_DeleteSliver(self, slice_urn, credentials, options=None):
try:
#if CredVerifier.checkValid(credentials, "deletesliver", slice_urn):
if True:
self.recordAction("deletesliver", credentials, slice_urn)
if GeniDB.getSliverURN(slice_urn) is None:
raise Fault("DeleteSliver", "Sliver for slice URN (%s) does not exist" % (slice_urn))
return self.errorResult(12, "") #not sure if this is needed
sliver_urn = GeniDB.getSliverURN(slice_urn)
data = GeniDB.getSliverData(sliver_urn, True)
foam.geni.lib.deleteSliver(sliver_urn = sliver_urn)
foam.task.emailGAPIDeleteSliver(data)
return self.successResult(True)
return self.successResult(False)
except UnknownSlice, x:
self._log.info("Attempt to delete unknown sliver for slice URN %s" % (slice_urn))
x._foam_logged = True
raise x
示例14: expireSlivers
# 需要導入模塊: from foam.geni.db import GeniDB [as 別名]
# 或者: from foam.geni.db.GeniDB import getSliverData [as 別名]
def expireSlivers (self):
now = _asUTC(datetime.datetime.utcnow())
exc_stack = []
expired_slivers = []
try:
slivers = GeniDB.getExpiredSliverList(now)
for sliver in slivers:
try:
data = GeniDB.getSliverData(sliver["sliver_urn"], True)
TokenVerifier.checkToken("expire-sliver", sliver["sliver_urn"])
foam.geni.lib.deleteSliver(sliver_urn = sliver["sliver_urn"])
foam.task.emailExpireSliver(data)
expired_slivers.append(data["sliver_urn"])
except TokenError, e:
exc_stack.append(jsonify({"exception" : traceback.format_exc()}))
return jsonify({"expired" : expired_slivers})
示例15: pub_DeleteSliver
# 需要導入模塊: from foam.geni.db import GeniDB [as 別名]
# 或者: from foam.geni.db.GeniDB import getSliverData [as 別名]
def pub_DeleteSliver (self, slice_urn, credentials):
try:
if CredVerifier.checkValid(credentials, "deletesliver", slice_urn):
self.recordAction("deletesliver", credentials, slice_urn)
if GeniDB.getSliverURN(slice_urn) is None:
raise Fault("DeleteSliver", "Sliver for slice URN (%s) does not exist" % (slice_urn))
sliver_urn = GeniDB.getSliverURN(slice_urn)
data = GeniDB.getSliverData(sliver_urn, True)
foam.geni.lib.deleteSliver(sliver_urn = sliver_urn)
foam.task.emailGAPIDeleteSliver(data)
return True
return False
except UnknownSlice, x:
self._log.info("Attempt to delete unknown sliver for slice URN %s" % (slice_urn))
x._foam_logged = True
raise x