当前位置: 首页>>代码示例>>Python>>正文


Python GeniDB.getSliverURN方法代码示例

本文整理汇总了Python中foam.geni.db.GeniDB.getSliverURN方法的典型用法代码示例。如果您正苦于以下问题:Python GeniDB.getSliverURN方法的具体用法?Python GeniDB.getSliverURN怎么用?Python GeniDB.getSliverURN使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在foam.geni.db.GeniDB的用法示例。


在下文中一共展示了GeniDB.getSliverURN方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: pub_DeleteSliver

# 需要导入模块: from foam.geni.db import GeniDB [as 别名]
# 或者: from foam.geni.db.GeniDB import getSliverURN [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
开发者ID:HalasNet,项目名称:felix,代码行数:34,代码来源:gapi2.py

示例2: pub_SliverStatus

# 需要导入模块: from foam.geni.db import GeniDB [as 别名]
# 或者: from foam.geni.db.GeniDB import getSliverURN [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
开发者ID:HalasNet,项目名称:felix,代码行数:30,代码来源:gapi2.py

示例3: pub_ListResources

# 需要导入模块: from foam.geni.db import GeniDB [as 别名]
# 或者: from foam.geni.db.GeniDB import getSliverURN [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
开发者ID:HalasNet,项目名称:felix,代码行数:28,代码来源:gapi1.py

示例4: renewSliver

# 需要导入模块: from foam.geni.db import GeniDB [as 别名]
# 或者: from foam.geni.db.GeniDB import getSliverURN [as 别名]
def renewSliver (slice_urn, creds, exptime):
  from foam.geni.db import GeniDB

  sliver_urn = GeniDB.getSliverURN(slice_urn)

  reqexp = dateutil.parser.parse(str(exptime))
  reqexp = _asUTC(reqexp)

  max_expiration = _asUTC(datetime.datetime.utcnow()) + ConfigDB.getConfigItemByKey("geni.max-lease").getValue()

  if reqexp > max_expiration:
    raise BadSliverExpiration(
      "The requested expiration date (%s) is past the allowed maximum expiration (%s)." %
        (reqexp, max_expiration))

  for cred in creds:
    credexp = _asUTC(cred.expiration)
    if reqexp > credexp:
      continue
    else:
      GeniDB.updateSliverExpiration(sliver_urn, reqexp)
      sobj = GeniDB.getSliverObj(sliver_urn)
      sobj.resetExpireEmail()
      sobj.store()
      return sliver_urn

  raise BadSliverExpiration(
      "No credential found whose expiration is greater than or equal to the requested sliver expiration (%s)" %
        (reqexp))
开发者ID:HalasNet,项目名称:felix,代码行数:31,代码来源:lib.py

示例5: pub_Shutdown

# 需要导入模块: from foam.geni.db import GeniDB [as 别名]
# 或者: from foam.geni.db.GeniDB import getSliverURN [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)
开发者ID:HalasNet,项目名称:felix,代码行数:12,代码来源:gapi2.py

示例6: priv_DeleteSliver

# 需要导入模块: from foam.geni.db import GeniDB [as 别名]
# 或者: from foam.geni.db.GeniDB import getSliverURN [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 
开发者ID:HalasNet,项目名称:felix,代码行数:21,代码来源:legacyexpedientapi.py

示例7: pub_DeleteSliver

# 需要导入模块: from foam.geni.db import GeniDB [as 别名]
# 或者: from foam.geni.db.GeniDB import getSliverURN [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
开发者ID:HalasNet,项目名称:felix,代码行数:22,代码来源:gapi1.py

示例8: gapi_DeleteSliver

# 需要导入模块: from foam.geni.db import GeniDB [as 别名]
# 或者: from foam.geni.db.GeniDB import getSliverURN [as 别名]
 def gapi_DeleteSliver(self, slice_urn, credentials, options=None):
   #GENI API imports
   from foam.geni.db import GeniDB, UnknownSlice, UnknownNode
   import foam.geni.approval
   import foam.geni.ofeliaapproval
   import sfa
   try:
     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 
开发者ID:HalasNet,项目名称:felix,代码行数:24,代码来源:admin.py

示例9: pub_change_slice_controller

# 需要导入模块: from foam.geni.db import GeniDB [as 别名]
# 或者: from foam.geni.db.GeniDB import getSliverURN [as 别名]
 def pub_change_slice_controller(self, slice_id, controller_url, **kwargs):
   slice_id   = slice_id.replace(":","_")
   slice_id   = slice_id.replace("name_","nam__")
   '''
   Changes the slice controller url.
   '''
   if slice_id not in self.slice_info_dict:
     self._log.info("Slice is probably not started yet, doing nothing...")
     return ""
     #raise Exception("Something went wrong with the fs recovery")
   #retrieve updated dict as a json file from foam db folder
   filedir = './opt/ofelia/ofam/local/db'
   filename = os.path.join(filedir, 'expedient_slices_info.json')
   if os.path.isfile(filename):
     f = open(filename, 'r')
     self.slice_info_dict = json.load(f)
     f.close()
   else:
     self._log.info("Slice is probably not started yet, doing nothing...")
     return ""
   slice_of_rspec = create_ofv3_rspec(slice_id, self.slice_info_dict[slice_id]['project_name'], 
                                      self.slice_info_dict[slice_id]['project_desc'],
                                      self.slice_info_dict[slice_id]['slice_name'],
                                      self.slice_info_dict[slice_id]['slice_desc'], controller_url,
                                      self.slice_info_dict[slice_id]['owner_email'],
                                      self.slice_info_dict[slice_id]['owner_password'],
                                      self.slice_info_dict[slice_id]['switch_slivers'],
                                      self.create_slice_fs(self.slice_info_dict[slice_id]['switch_slivers']))
   self.slice_info_dict[slice_id]['controller_url'] = controller_url
   slice_urn = "urn:publicid:IDN+openflow:foam:"+ str(THIS_SITE_TAG) +"+slice+" + "id_" + str(slice_id) + "name_" + str(self.slice_info_dict[slice_id]['slice_name'])
   creds = [] #creds are not needed at least for now: to be fixed
   user_info = {}
   user_info["urn"] = "urn:publicid:IDN+openflow:foam"+ str(THIS_SITE_TAG) +"+ch+" + "user+" + str(self.slice_info_dict[slice_id]['owner_email']) #temp hack
   user_info["email"] = str(self.slice_info_dict[slice_id]['owner_email'])
   if GeniDB.sliceExists(slice_urn):
     sliv_urn = GeniDB.getSliverURN(slice_urn)
   else:
     raise Exception("Something went wrong with the fs recovery, slice does not exist!")
   sliver = GeniDB.getSliverObj(sliv_urn) 
   is_allocated_by_FV = GeniDB.getEnabled(sliv_urn)
   was_allocated_by_FV = is_allocated_by_FV
   try:
     #old_exp_shutdown_success = legexpgapi2_apih.pub_Shutdown(slice_urn, creds, [])
     old_exp_shutdown_success = self.priv_DeleteSliver(slice_urn, creds, [])
   except Exception, e:
     import traceback
     traceback.print_exc()
     raise Exception("Exception while trying to shutdown old slice!")
开发者ID:HalasNet,项目名称:felix,代码行数:50,代码来源:legacyexpedientapi.py

示例10: pub_SliverStatus

# 需要导入模块: from foam.geni.db import GeniDB [as 别名]
# 或者: from foam.geni.db.GeniDB import getSliverURN [as 别名]
 def pub_SliverStatus (self, slice_urn, credentials):
   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 Fault("SliverStatus", "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"]
       return result
     return False
   except UnknownSlice, x:
     self._log.info("Attempt to get status on unknown sliver for slice %s" % (slice_urn))
     x._foam_logged = True
     raise x
开发者ID:HalasNet,项目名称:felix,代码行数:24,代码来源:gapi1.py

示例11: pub_ListResources

# 需要导入模块: from foam.geni.db import GeniDB [as 别名]
# 或者: from foam.geni.db.GeniDB import getSliverURN [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
开发者ID:HalasNet,项目名称:felix,代码行数:71,代码来源:gapi2.py

示例12: pub_get_granted_flowspace

# 需要导入模块: from foam.geni.db import GeniDB [as 别名]
# 或者: from foam.geni.db.GeniDB import getSliverURN [as 别名]
  def pub_get_granted_flowspace(self, slice_id, **kwargs):
    '''
    Return FlowVisor Rules for the slice.
    '''
    slice_id   = slice_id.replace(":","_")
    slice_id   = slice_id.replace("name_","nam__")
    def parse_granted_flowspaces(gfs):
      gfs_list=[] 
      for fs in gfs:
        fs_dict = dict(
            flowspace=dict(),
            openflow=dict()
        )
        fs_dict['openflow']=[]
        fs_dict['flowspace']=dict(
                                 mac_src_s=int_to_mac(fs.mac_src_s),
                                 mac_src_e=int_to_mac(fs.mac_src_e),
                                 mac_dst_s=int_to_mac(fs.mac_dst_s),
                                 mac_dst_e=int_to_mac(fs.mac_dst_e),
                                 eth_type_s=fs.eth_type_s,
                                 eth_type_e=fs.eth_type_e,
                                 vlan_id_s=fs.vlan_id_s,
                                 vlan_id_e=fs.vlan_id_e,
                                 ip_src_s=int_to_dotted_ip(fs.ip_src_s),
                                 ip_dst_s=int_to_dotted_ip(fs.ip_dst_s),
                                 ip_src_e=int_to_dotted_ip(fs.ip_src_e),
                                 ip_dst_e=int_to_dotted_ip(fs.ip_dst_e),
                                 ip_proto_s=fs.ip_proto_s,
                                 ip_proto_e=fs.ip_proto_e,
                                 tp_src_s=fs.tp_src_s,
                                 tp_dst_s=fs.tp_dst_s,
                                 tp_src_e=fs.tp_src_e,
                                 tp_dst_e=fs.tp_dst_e,
                             )
        openflow_dict=dict(
                                dpid=fs.dpid, 
                                direction=fs.direction, 
                                port_number_s=fs.port_number_s, 
                                port_number_e=fs.port_number_e, 
                           )
        existing_fs = False
        for prev_dict_list in gfs_list:
          prev_dict = prev_dict_list[0]
          if fs_dict['flowspace'] == prev_dict['flowspace']:
            if openflow_dict not in prev_dict['openflow']:
              prev_dict['openflow'].append(openflow_dict)
            existing_fs = True
            break
        if not existing_fs:
          fs_dict['openflow'].append(openflow_dict) 
          fs_list = [fs_dict]
          gfs_list.append(fs_list)
      
      return gfs_list

    if slice_id in self.slice_info_dict:
        slice_urn = "urn:publicid:IDN+openflow:foam:"+ str(THIS_SITE_TAG) +"+slice+" + "id_" + str(slice_id) + "name_" + str(self.slice_info_dict[slice_id]['slice_name'])
    else:
        return [] 
    if GeniDB.sliceExists(slice_urn):
      sliv_urn = GeniDB.getSliverURN(slice_urn)
    else:
      return []
      #raise Exception(parseFVexception(e))
    sliver = GeniDB.getSliverObj(sliv_urn) 
    is_allocated_by_FV = GeniDB.getEnabled(sliv_urn)
    if is_allocated_by_FV == True:
      #that means that the flow space as requested was allocated
      #so retrieve the fs in the form Expedient understands
      #TODO: check that ecery time this corresponds to the actual flowspec that FOAM has
      #retrieve updated dict as a json file from foam db folder
      filedir = './opt/ofelia/ofam/local/db'
      filename = os.path.join(filedir, 'expedient_slices_info.json')
      if os.path.isfile(filename):
        f = open(filename, 'r')
        self.slice_info_dict = json.load(f)
        f.close()
      else:
        self._log.info("Slice is probably not started yet, doing nothing...")
        return []
      if slice_id not in self.slice_info_dict:
        raise Exception("Something went wrong with the fs recovery")
      all_efs = self.create_slice_fs(self.slice_info_dict[slice_id]['switch_slivers']) 
      gfs = []    
      try:    
        gfs = parse_granted_flowspaces(all_efs)
      except Exception,e:
        import traceback
        traceback.print_exc()
        self._log.exception("FlowSpace for the allocated slice is not returned")
        raise Exception(parseFVexception(e))
      #self._log.info("FlowSpace for the allocated slice is returned")
      #for fs_list in gfs:
      #  fs = fs_list[0]
      #  self._log.info(fs['flowspace'])
      #  self._log.info(fs['openflow'])
      if gfs == []:
        self._log.info("Empty FlowSpace for the allocated slice returned! Need to debug...")
      return gfs
开发者ID:HalasNet,项目名称:felix,代码行数:101,代码来源:legacyexpedientapi.py


注:本文中的foam.geni.db.GeniDB.getSliverURN方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。