def __decode_tn_rspec(self, result): (nodes, links) = (None, None) rspec = result.get("value", None) if rspec is None: self.error("Unable to get RSpec value from %s" % (result, )) return (nodes, links) try: tn_rspec = TNRMv3AdvertisementParser(from_string=rspec) self.debug("TNRSpec=%s" % (tn_rspec, )) # validate (result, error) = Commons.validate(tn_rspec.get_rspec()) if not result: self.error("Validation failure: %s" % error) return (nodes, links) self.info("Validation success!") nodes = tn_rspec.nodes() self.info("Nodes(%d)=%s" % ( len(nodes), nodes, )) links = tn_rspec.links() self.info("Links(%d)=%s" % ( len(links), links, )) except Exception as e: self.error("Exception: %s" % str(e)) return (nodes, links)
def __decode_sdn_rspec(self, result): (ofdpids, links) = (None, None) rspec = result.get("value", None) if rspec is None: self.error("Unable to get RSpec value from %s" % (result, )) return (ofdpids, links) try: of_rspec = OFv3AdvertisementParser(from_string=rspec) self.debug("OFRSpec=%s" % (of_rspec, )) # validate (result, error) = Commons.validate(of_rspec.get_rspec()) if not result: self.error("Validation failure: %s" % error) return (ofdpids, links) self.info("Validation success!") ofdpids = of_rspec.datapaths() self.info("OFDataPaths(%d)=%s" % ( len(ofdpids), ofdpids, )) links = of_rspec.links() self.info("Links(%d)=%s" % ( len(links), links, )) except Exception as e: self.error("Exception: %s" % str(e)) return (ofdpids, links)
def __decode_tn_rspec(self, result): (nodes, links) = (None, None) rspec = result.get("value", None) if rspec is None: self.error("Unable to get RSpec value from %s" % (result,)) return (nodes, links) try: tn_rspec = TNRMv3AdvertisementParser(from_string=rspec) self.debug("TNRSpec=%s" % (tn_rspec,)) # validate (result, error) = Commons.validate(tn_rspec.get_rspec()) if not result: self.error("Validation failure: %s" % error) return (nodes, links) self.info("Validation success!") nodes = tn_rspec.nodes() self.info("Nodes(%d)=%s" % (len(nodes), nodes,)) links = tn_rspec.links() self.info("Links(%d)=%s" % (len(links), links,)) except Exception as e: self.error("Exception: %s" % str(e)) return (nodes, links)
def __decode_sdn_rspec(self, result): (ofdpids, links) = (None, None) rspec = result.get("value", None) if rspec is None: self.error("Unable to get RSpec value from %s" % (result,)) return (ofdpids, links) try: of_rspec = OFv3AdvertisementParser(from_string=rspec) self.debug("OFRSpec=%s" % (of_rspec,)) # validate (result, error) = Commons.validate(of_rspec.get_rspec()) if not result: self.error("Validation failure: %s" % error) return (ofdpids, links) self.info("Validation success!") ofdpids = of_rspec.datapaths() self.info("OFDataPaths(%d)=%s" % (len(ofdpids), ofdpids,)) links = of_rspec.links() self.info("Links(%d)=%s" % (len(links), links,)) except Exception as e: self.error("Exception: %s" % str(e)) return (ofdpids, links)
def validate_rspec(rspec): """ Given an RSpec (XML structure), this method validates the structure of the document, according to the GENI resource schemas. @param rspec RSpec defining resources @throws GENIv3GeneralError when RSpec format is invalid """ (result, error) = validate(rspec) if result is not True: m = "RSpec validation failure: %s" % (error, ) raise geni_ex.GENIv3GeneralError(m) logger.info("Validation success!")
def validate_rspec(rspec): """ Given an RSpec (XML structure), this method validates the structure of the document, according to the GENI resource schemas. @param rspec RSpec defining resources @throws GENIv3GeneralError when RSpec format is invalid """ (result, error) = validate(rspec) if result is not True: m = "RSpec validation failure: %s" % (error,) raise geni_ex.GENIv3GeneralError(m) logger.info("Validation success!")
def __manage_ro_resources(self, result, peerID): rspec = result.get("value", None) self.nodes_all = [] self.links_all = [] if rspec is None: self.error("Unable to get RSpec value from %s" % (result, )) return (self.nodes_all, self.links_all) try: ro_rspec = ROv3AdvertisementParser(from_string=rspec) self.debug("RORSpec=%s" % (ro_rspec, )) # validate (result, error) = Commons.validate(ro_rspec.get_rspec()) if not result: self.error("Validation failure: %s" % error) return self.info("Validation success!") self.__manage_ro_resources_com(ro_rspec, peerID) self.__manage_ro_resources_sdn(ro_rspec, peerID) self.__manage_ro_resources_se(ro_rspec, peerID) self.__manage_ro_resources_tn(ro_rspec, peerID) except Exception as e: self.error("Exception: %s" % str(e)) return (self.nodes_all, self.links_all)
def __manage_ro_resources(self, result, peerID): rspec = result.get("value", None) self.nodes_all = [] self.links_all = [] if rspec is None: self.error("Unable to get RSpec value from %s" % (result,)) return (self.nodes_all, self.links_all) try: ro_rspec = ROv3AdvertisementParser(from_string=rspec) self.debug("RORSpec=%s" % (ro_rspec,)) # validate (result, error) = Commons.validate(ro_rspec.get_rspec()) if not result: self.error("Validation failure: %s" % error) return self.info("Validation success!") self.__manage_ro_resources_com(ro_rspec, peerID) self.__manage_ro_resources_sdn(ro_rspec, peerID) self.__manage_ro_resources_se(ro_rspec, peerID) self.__manage_ro_resources_tn(ro_rspec, peerID) except Exception as e: self.error("Exception: %s" % str(e)) return (self.nodes_all, self.links_all)
def in_validate(rspec): (result, error) = validate(rspec) if not result: print "Validation failure: %s" % error else: print "Validation success!"