本文整理汇总了Python中foam.geni.db.GeniDB.getSliverList方法的典型用法代码示例。如果您正苦于以下问题:Python GeniDB.getSliverList方法的具体用法?Python GeniDB.getSliverList怎么用?Python GeniDB.getSliverList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类foam.geni.db.GeniDB
的用法示例。
在下文中一共展示了GeniDB.getSliverList方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: pub_DeleteSliver
# 需要导入模块: from foam.geni.db import GeniDB [as 别名]
# 或者: from foam.geni.db.GeniDB import getSliverList [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
示例2: pub_SliverStatus
# 需要导入模块: from foam.geni.db import GeniDB [as 别名]
# 或者: from foam.geni.db.GeniDB import getSliverList [as 别名]
def pub_SliverStatus(self, slice_xrn=None, creds=[], options={}):
try:
self.pm.check_permissions("SliverStatus", locals())
except Exception as e:
return self.buildPropertyList(GENI_ERROR_CODE.CREDENTIAL_INVALID, output=e)
try:
slivers = GeniDB.getSliverList()
try:
sliver = get_slice_details_from_slivers(slivers, slice_xrn)
except:
raise Exception("Sliver for slice URN (%s) does not exist" % (slice_xrn))
result = dict()
result["slice_urn"] = slice_xrn
result["sliver_urn"] = sliver["sliver_urn"]
result["status"] = sliver["status"]
result["created"] = sliver["creation"]
result["description"] = sliver["desc"]
result["expires"] = sliver["expiration"]
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_xrn)
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
示例3: emailPendingQueue
# 需要导入模块: from foam.geni.db import GeniDB [as 别名]
# 或者: from foam.geni.db.GeniDB import getSliverList [as 别名]
def emailPendingQueue (self):
try:
lines = []
pending_list = GeniDB.getSliverList(False, None)
for sliver in pending_list:
sobj = GeniDB.getSliverObj(sliver["sliver_urn"])
lines.append("Sliver URN: %s" % sobj.getURN())
lines.append(" User: %s [%s]" % (sobj.getEmail(), sobj.getUserURN()))
lines.append("")
if lines:
self._log.info("[Daily Queue] Sending email for %d sliver(s)" % (len(lines)/3))
queue = "\n".join(lines)
foam.task.emailPendingQueue({"pending-queue" : queue})
return jsonify(None)
self._log.info("[Daily Queue] No pending slivers to email")
return jsonify(None)
except Exception, e:
self._log.exception("Exception")
return jsonify(None, code = 2, msg = traceback.format_exc())
示例4: processExpirationEmails
# 需要导入模块: from foam.geni.db import GeniDB [as 别名]
# 或者: from foam.geni.db.GeniDB import getSliverList [as 别名]
def processExpirationEmails (self):
now = _asUTC(datetime.datetime.utcnow())
self._log.debug("Expiration check: %s" % (str(now)))
day_alert = []
week_alert = []
try:
slivers = GeniDB.getSliverList(False)
for sliver in slivers:
sobj = GeniDB.getSliverObj(sliver["sliver_urn"])
(urn, action) = sobj.emailCheck(now)
if action == 1:
day_alert.append(urn)
self._log.info("[%s] Sent email for expiry within 30 hours" % (urn))
elif action == 2:
week_alert.append(urn)
self._log.info("[%s] Sent email for expiry within 7 days" % (urn))
else:
self._log.debug("[%s] Expiration check: No email required for sliver expiration (%s)" % (urn, sobj.getExpiration()))
return jsonify({"status" : "success", "day_alerts" : day_alert, "week_alerts" : week_alert})
except Exception, e:
self._log.exception("Exception")
return jsonify(None, code = 2, msg = traceback.format_exc())
示例5: adminListAllocatedVlans
# 需要导入模块: from foam.geni.db import GeniDB [as 别名]
# 或者: from foam.geni.db.GeniDB import getSliverList [as 别名]
def adminListAllocatedVlans(self, use_json = True):
#if not request.json:
# return
try:
used_vlans = []
slivers = GeniDB.getSliverList(False, True, True)
for sliv in slivers:
fspecs = sliv.getFlowspecs()
for fs in fspecs:
for vlanid in fs.getVLANs():
if vlanid not in used_vlans:
used_vlans.append(vlanid)
used_vlans.sort()
if (use_json == True):
return jsonify({"allocated-vlans" : used_vlans})
else:
return used_vlans
except JSONValidationError, e:
jd = e.__json__()
return jsonify(jd, code = 1, msg = jd["exception"])
示例6: adminListVLANs
# 需要导入模块: from foam.geni.db import GeniDB [as 别名]
# 或者: from foam.geni.db.GeniDB import getSliverList [as 别名]
def adminListVLANs (self): #use_json = True
#if not request.json:
# return
try:
global_vlan_list = {}
for i in range(4095):
global_vlan_list[i] = "free"
slivers = GeniDB.getSliverList(False, True, True)
for sliv in slivers:
fspecs = sliv.getFlowspecs()
for fs in fspecs:
for vlanid in fs.getVLANs():
global_vlan_list[vlanid] = "allocated"
free_vlan_list = []
for i in global_vlan_list.iterkeys():
if global_vlan_list[i] == "free":
free_vlan_list.append(i)
free_vlan_list.sort()
allocated_vlan_list = []
for i in global_vlan_list.iterkeys():
if global_vlan_list[i] == "allocated":
allocated_vlan_list.append(i)
allocated_vlan_list.sort()
for vlan_id in locsettings.UNALLOWED_VLANS:
free_vlan_list.remove(vlan_id)
#if (use_json == True):
return jsonify({"free-vlans" : free_vlan_list, "allocated-vlans" : allocated_vlan_list})
#else:
# return {"free-vlans" : free_vlan_list, "allocated-vlans" : allocated_vlan_list}
except JSONValidationError, e:
jd = e.__json__()
return jsonify(jd, code = 1, msg = jd["exception"])
示例7: listSlivers
# 需要导入模块: from foam.geni.db import GeniDB [as 别名]
# 或者: from foam.geni.db.GeniDB import getSliverList [as 别名]
def listSlivers (self):
try:
deleted = False
status = 0
if request.method == "POST":
if not request.json:
return ""
if request.json.has_key("deleted"):
deleted = request.json["deleted"]
if request.json.has_key("status"):
st = request.json["status"].lower()
if st == "approved":
status = True
elif st == "rejected":
status = False
elif st == "pending":
status = None
slivers = GeniDB.getSliverList(deleted, status)
return jsonify({"slivers" : slivers})
except JSONValidationError, e:
jd = e.__json__()
return jsonify(jd, code = 1, msg = jd["exception"])
示例8: rebuild
# 需要导入模块: from foam.geni.db import GeniDB [as 别名]
# 或者: from foam.geni.db.GeniDB import getSliverList [as 别名]
def rebuild (self):
self._log.info("Rebuilding approval database")
self._initCore()
self._build(GeniDB.getSliverList(False, True, True))
示例9: iterMACs
# 需要导入模块: from foam.geni.db import GeniDB [as 别名]
# 或者: from foam.geni.db.GeniDB import getSliverList [as 别名]
previnttpport = inttpport
def iterMACs (self):
for x in self._macs:
yield x
def iterEthertypes (self):
for x in self._ethertypes:
yield x
def iterVLANs (self):
for x in self._vlans:
yield x
def iterSubnets (self):
for x in self._subnets:
yield x
def iterNWProtos (self):
for x in self._nwprotos:
yield x
def iterTPPorts (self):
for x in self._tpports:
yield x
from foam.core.configdb import ConfigDB
of_AppData = of_ApprovalData(GeniDB.getSliverList(False, True, True))