本文整理汇总了Python中foam.geni.db.GeniDB.getManifest方法的典型用法代码示例。如果您正苦于以下问题:Python GeniDB.getManifest方法的具体用法?Python GeniDB.getManifest怎么用?Python GeniDB.getManifest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类foam.geni.db.GeniDB
的用法示例。
在下文中一共展示了GeniDB.getManifest方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: pub_ListResources
# 需要导入模块: from foam.geni.db import GeniDB [as 别名]
# 或者: from foam.geni.db.GeniDB import getManifest [as 别名]
def pub_ListResources (self, credentials, options):
try:
CredVerifier.checkValid(credentials, [])
compressed = options.get("geni_compressed", False)
urn = options.get("geni_slice_urn", None)
if urn:
CredVerifier.checkValid(credentials, "getsliceresources", urn)
self.recordAction("listresources", credentials, urn)
sliver_urn = GeniDB.getSliverURN(urn)
if sliver_urn is None:
raise Fault("ListResources", "Sliver for slice URN (%s) does not exist" % (urn))
rspec = GeniDB.getManifest(sliver_urn)
else:
self.recordAction("listresources", credentials)
rspec = foam.geni.lib.getAdvertisement()
if compressed:
zrspec = zlib.compress(rspec)
rspec = base64.b64encode(zrspec)
return rspec
except ExpatError, e:
self._log.error("Error parsing credential strings")
e._foam_logged = True
raise e
示例2: pub_CreateSliver
# 需要导入模块: from foam.geni.db import GeniDB [as 别名]
# 或者: from foam.geni.db.GeniDB import getManifest [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: gapi_CreateSliver
# 需要导入模块: from foam.geni.db import GeniDB [as 别名]
# 或者: from foam.geni.db.GeniDB import getManifest [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
示例4: priv_CreateSliver
# 需要导入模块: from foam.geni.db import GeniDB [as 别名]
# 或者: from foam.geni.db.GeniDB import getManifest [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
示例5: pub_CreateSliver
# 需要导入模块: from foam.geni.db import GeniDB [as 别名]
# 或者: from foam.geni.db.GeniDB import getManifest [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
示例6: pub_CreateSliver
# 需要导入模块: from foam.geni.db import GeniDB [as 别名]
# 或者: from foam.geni.db.GeniDB import getManifest [as 别名]
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
示例7: pub_ListResources
# 需要导入模块: from foam.geni.db import GeniDB [as 别名]
# 或者: from foam.geni.db.GeniDB import getManifest [as 别名]
def pub_ListResources (self, credentials, options):
"""Return information about available resources or resources allocated to a slice
List the resources at this aggregate in an RSpec: may be all resources,
only those available for reservation, or only those already reserved for the given slice.
"""
try:
CredVerifier.checkValid(credentials, [])
# Parse options
compressed = options.get("geni_compressed", False)
urn = options.get("geni_slice_urn", None)
spec_version = options.get("geni_rspec_version")
supported_spec = {'version': '3', 'type': 'GENI'}
if spec_version:
if spec_version != supported_spec:
msg = "RSpec type/version not supported"
propertyList = self.buildPropertyList(GENI_ERROR_CODE.BADVERSION, output=msg)
return propertyList
else:
msg = "Required option geni_rspec_version missing"
propertyList = self.buildPropertyList(GENI_ERROR_CODE.BADARGS, output=msg)
return propertyList
if urn:
CredVerifier.checkValid(credentials, "getsliceresources", urn)
self.recordAction("listresources", credentials, urn)
sliver_urn = GeniDB.getSliverURN(urn)
if sliver_urn is None:
raise Exception("Sliver for slice URN (%s) does not exist" % (urn))
else:
rspec = GeniDB.getManifest(sliver_urn)
else:
self.recordAction("listresources", credentials)
rspec = foam.geni.lib.getAdvertisement()
if compressed:
zrspec = zlib.compress(rspec)
rspec = base64.b64encode(zrspec)
propertyList = self.buildPropertyList(GENI_ERROR_CODE.SUCCESS, value=rspec)
except ExpatError:
msg = "Error parsing credential strings"
propertyList = self.buildPropertyList(GENI_ERROR_CODE.BADARGS, output=msg)
self._log.error(msg)
except UnknownSlice as x:
# Raised by GeniDB.getSliverURN()
msg = "Attempt to list resources on sliver for unknown slice %s" % (urn)
propertyList = self.buildPropertyList(GENI_ERROR_CODE.ERROR, output=msg)
x.log(self._log, msg, logging.INFO)
except xmlrpclib.Fault as x:
# Something thrown via GCF, we'll presume it was something related to credentials
msg = "GCF credential check failure: <%s>" % (x)
propertyList = self.buildPropertyList(GENI_ERROR_CODE.ERROR, output=msg)
self._log.info(msg)
self._log.debug(x, exc_info=True)
except AttributeError as x:
# New GCF problem with user creds that have no gid_caller, probably
msg = "GCF credential check failure: <%s>" % (x)
propertyList = self.buildPropertyList(GENI_ERROR_CODE.ERROR, output=msg)
self._log.info(msg)
self._log.debug(x, exc_info=True)
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