コード例 #1
0
ファイル: delegate_v3.py プロジェクト: dana-i2cat/felix
    def list_resources(self,
                       client_cert,
                       credentials,
                       geni_available,
                       inner_call=False):
        """
        Shows a list with the slivers managed or seen by the resource manager.

        @param client_cert client certificate (X509)
        @param credentials client credential(s), provided by the ClearingHouse
            and generated after the certificates
        @param geni_available flag to describe which slivers are expected
            to be shown
                * geni_available = True : only available (non-allocated,
                                          non-provisioned) will be shown
                * geni_available = False : every slivers will be shown
        @return rspec RSpec document containing a list of the slivers,
            formatted in accordance to GENI schemas
        """
        logger.info("geni_available=%s", geni_available)
        logger.info("inner_call=%s", inner_call)

        sl = "http://www.geni.net/resources/rspec/3/ad.xsd"
        rspec = ROAdvertisementFormatter(schema_location=sl)

        try:
            rspec = ROUtils.generate_list_resources(rspec, \
                geni_available, self._interdomain_available_to_user, inner_call)
        except Exception as e:
            raise geni_ex.GENIv3GeneralError(str(e))

        logger.debug("ROAdvertisementFormatter=%s" % (rspec, ))
        CommonUtils.validate_rspec(rspec.get_rspec())
        return "%s" % rspec
コード例 #2
0
ファイル: delegate_v3.py プロジェクト: HalasNet/felix
    def list_resources(self, client_cert, credentials, geni_available, inner_call=False):
        """
        Shows a list with the slivers managed or seen by the resource manager.

        @param client_cert client certificate (X509)
        @param credentials client credential(s), provided by the ClearingHouse
            and generated after the certificates
        @param geni_available flag to describe which slivers are expected
            to be shown
                * geni_available = True : only available (non-allocated,
                                          non-provisioned) will be shown
                * geni_available = False : every slivers will be shown
        @return rspec RSpec document containing a list of the slivers,
            formatted in accordance to GENI schemas
        """
        logger.info("geni_available=%s", geni_available)
        logger.info("inner_call=%s", inner_call)

        sl = "http://www.geni.net/resources/rspec/3/ad.xsd"
        rspec = ROAdvertisementFormatter(schema_location=sl)

        try:
            rspec = ROUtils.generate_list_resources(rspec, \
                geni_available, self._interdomain_available_to_user, inner_call)
        except Exception as e:
            raise geni_ex.GENIv3GeneralError(str(e))

        logger.debug("ROAdvertisementFormatter=%s" % (rspec,))
        CommonUtils.validate_rspec(rspec.get_rspec())
        return "%s" % rspec
コード例 #3
0
ファイル: delegate_v3.py プロジェクト: dana-i2cat/felix
    def provision(self, urns, client_cert, credentials, best_effort, end_time,
                  geni_users):
        """Documentation see [geniv3rpc] GENIv3DelegateBase.
        {geni_users} is relevant here."""
        ro_manifest, ro_slivers = ROManifestFormatter(), []
        client_urn = CommonUtils.fetch_user_name_from_geni_users(geni_users)

        slice_urn = db_sync_manager.get_slice_urn(urns)
        slice_monitor = None
        try:
            slice_monitor = SliceMonitoring()
            slice_monitor.add_topology(slice_urn, SliceMonitoring.PROVISIONED,
                                       client_urn)
        except Exception as e:
            logger.warning(
                "Delegate could not send Provision trigger" +
                " to MS. Details: %s", (e, ))

        route = db_sync_manager.get_slice_routing_keys(urns)
        logger.debug("Route=%s" % (route, ))

        for r, v in route.iteritems():
            peer = db_sync_manager.get_configured_peer_by_routing_key(r)
            logger.debug("peer=%s" % (peer, ))
            if peer.get("type") == self._allowed_peers.get("PEER_CRM"):
                com_m_info, com_slivers = COMUtils().manage_provision(
                    peer, v, credentials, best_effort, end_time, geni_users)

                logger.debug("com_m=%s, com_s=%s" % (
                    com_m_info,
                    com_slivers,
                ))
                for n in com_m_info.get("nodes"):
                    ro_manifest.com_node(n)

                ro_slivers.extend(com_slivers)
                # introduce slice-monitoring info for C resources
                try:
                    slice_monitor.add_c_resources(slice_urn,
                                                  com_m_info.get("nodes"))
                except Exception as e:
                    logger.warning(
                        "Delegate could not monitor COM resources" +
                        " upon Provision. Details: %s", (e, ))

            elif peer.get("type") == self._allowed_peers.get("PEER_SDNRM"):
                of_m_info, of_slivers = SDNUtils().manage_provision(
                    peer, v, credentials, best_effort, end_time, geni_users)

                logger.debug("of_m=%s, of_s=%s" % (
                    of_m_info,
                    of_slivers,
                ))
                for s in of_m_info.get("slivers"):
                    ro_manifest.of_sliver(s)

                ro_slivers.extend(of_slivers)
                # introduce slice-monitoring info for SDN resources
                try:
                    slice_monitor.add_sdn_resources(slice_urn,
                                                    of_m_info.get("slivers"))
                except Exception as e:
                    logger.warning(
                        "Delegate could not monitor SDN resources" +
                        " upon Provision. Details: %s", (e, ))

            elif peer.get("type") == self._allowed_peers.get("PEER_TNRM"):
                tn_m_info, tn_slivers = TNUtils().manage_provision(
                    peer, v, credentials, best_effort, end_time, geni_users)

                logger.debug("tn_m=%s, tn_s=%s" % (
                    tn_m_info,
                    tn_slivers,
                ))
                for n in tn_m_info.get("nodes"):
                    ro_manifest.tn_node(n)
                for l in tn_m_info.get("links"):
                    ro_manifest.tn_link(l)

                ro_slivers.extend(tn_slivers)
                # introduce slice-monitoring info for TN resources
                try:
                    slice_monitor.add_tn_resources(slice_urn,
                                                   tn_m_info.get("nodes"),
                                                   tn_m_info.get("links"),
                                                   peer)
                except Exception as e:
                    logger.warning(
                        "Delegate could not monitor TN resources" +
                        " upon Provision. Details: %s", (e, ))

            elif peer.get("type") == self._allowed_peers.get("PEER_SERM"):
                se_m_info, se_slivers = SEUtils().manage_provision(
                    peer, v, credentials, best_effort, end_time, geni_users)

                logger.debug("se_m=%s, se_s=%s" % (
                    se_m_info,
                    se_slivers,
                ))
                for n in se_m_info.get("nodes"):
                    ro_manifest.se_node(n)
                for l in se_m_info.get("links"):
                    ro_manifest.se_link(l)

                ro_slivers.extend(se_slivers)
                # introduce slice-monitoring info for SE resources
                try:
                    slice_monitor.add_se_resources(slice_urn,
                                                   se_m_info.get("nodes"),
                                                   se_m_info.get("links"))
                except Exception as e:
                    logger.warning(
                        "Delegate could not monitor SE resources" +
                        " upon Provision. Details: %s", (e, ))

            elif peer.get("type") == self._allowed_peers.get("PEER_RO"):
                ro_m_info, ro_slivers_ro = ROUtils().manage_provision(
                    peer, v, credentials, best_effort, end_time, geni_users)

                logger.debug("ro_m=%s, ro_s=%s" % (
                    ro_m_info,
                    ro_slivers,
                ))
                ro_manifest = ROUtils.generate_describe_manifest(
                    ro_manifest, ro_m_info)

                ro_slivers.extend(ro_slivers_ro)
                # introduce slice-monitoring info for ALL the resource types!
                try:
                    slice_monitor.add_c_resources(slice_urn,
                                                  ro_m_info.get("com_nodes"))
                    slice_monitor.add_sdn_resources(
                        slice_urn, ro_m_info.get("sdn_slivers"))
                    slice_monitor.add_tn_resources(slice_urn,
                                                   ro_m_info.get("tn_nodes"),
                                                   ro_m_info.get("tn_links"),
                                                   peer)
                    slice_monitor.add_se_resources(slice_urn,
                                                   ro_m_info.get("se_nodes"),
                                                   ro_m_info.get("se_links"))
                except Exception as e:
                    logger.warning(
                        "Delegate could not monitor RO resources" +
                        " upon Provision. Details: %s", (e, ))

        # send slice-monitoring info to the monitoring system
        try:
            # Before sending the slice info, we need to add some "virtual"
            # links (island-to-island)!
            slice_monitor.add_island_to_island_links(slice_urn)
            slice_monitor.send()
            # add slice_monitoring object to the slice table
            db_sync_manager.store_slice_monitoring_info(
                slice_urn, slice_monitor.serialize())
        except Exception as e:
            logger.warning(
                "Delegate could not send (store) slice monitoring" +
                " information upon Provision. Details: %s", (e, ))

        logger.debug("RO-ManifestFormatter=%s" % (ro_manifest, ))

        # In order to prevent data conversion error, we manipulate the
        # geni-expires parameter. At least 1 parameter should be not null!
        valid_geni_expires = None
        for s in ro_slivers:
            if s["geni_expires"] is not None:
                valid_geni_expires = s["geni_expires"]
                break
        ro_slivers = CommonUtils.convert_sliver_dates_to_datetime(
            ro_slivers, valid_geni_expires)
        return ("%s" % ro_manifest, ro_slivers)
コード例 #4
0
ファイル: delegate_v3.py プロジェクト: dana-i2cat/felix
    def describe(self, urns, client_cert, credentials):
        """Documentation see [geniv3rpc] GENIv3DelegateBase."""

        ro_manifest, ro_slivers, last_slice = ROManifestFormatter(), [], ""

        route = db_sync_manager.get_slice_routing_keys(urns)
        logger.debug("Route=%s" % (route, ))

        for r, v in route.iteritems():
            peer = db_sync_manager.get_configured_peer_by_routing_key(r)
            logger.debug("peer=%s" % (peer, ))
            if peer.get("type") == self._allowed_peers.get("PEER_SDNRM"):
                of_m_info, last_slice, of_slivers =\
                    SDNUtils().manage_describe(peer, v, credentials)

                logger.debug("of_m=%s, of_s=%s, urn=%s" %
                             (of_m_info, of_slivers, last_slice))
                for s in of_m_info.get("slivers"):
                    ro_manifest.of_sliver(s)

                ro_slivers.extend(of_slivers)

            elif peer.get("type") == self._allowed_peers.get("PEER_TNRM"):
                tn_m_info, last_slice, tn_slivers =\
                    TNUtils().manage_describe(peer, v, credentials)

                logger.debug("tn_m=%s, tn_s=%s, urn=%s" %
                             (tn_m_info, tn_slivers, last_slice))
                for n in tn_m_info.get("nodes"):
                    ro_manifest.tn_node(n)
                for l in tn_m_info.get("links"):
                    ro_manifest.tn_link(l)

                ro_slivers.extend(tn_slivers)

            elif peer.get("type") == self._allowed_peers.get("PEER_SERM"):
                se_m_info, last_slice, se_slivers =\
                    SEUtils().manage_describe(peer, v, credentials)

                logger.debug("se_m=%s, se_s=%s, urn=%s" %
                             (se_m_info, se_slivers, last_slice))
                for n in se_m_info.get("nodes"):
                    ro_manifest.se_node(n)
                for l in se_m_info.get("links"):
                    ro_manifest.se_link(l)

                ro_slivers.extend(se_slivers)

            elif peer.get("type") == self._allowed_peers.get("PEER_CRM"):
                com_m_info, last_slice, com_slivers =\
                    COMUtils().manage_describe(peer, v, credentials)

                logger.debug("com_m=%s, com_s=%s, urn=%s" %
                             (com_m_info, com_slivers, last_slice))
                for n in com_m_info.get("nodes"):
                    ro_manifest.com_node(n)
                ro_slivers.extend(com_slivers)

            elif peer.get("type") == self._allowed_peers.get("PEER_RO"):
                ro_m_info, last_slice, ro_slivers_ro =\
                    ROUtils().manage_describe(peer, v, credentials)

                logger.debug("ro_m=%s, ro_s=%s, urn=%s" %
                             (ro_m_info, ro_slivers, last_slice))
                ro_manifest = ROUtils.generate_describe_manifest(
                    ro_manifest, ro_m_info)
                ro_slivers.extend(ro_slivers_ro)

        logger.debug("RO-ManifestFormatter=%s" % (ro_manifest, ))
        logger.debug("RO-Slivers(%d)=%s" % (
            len(ro_slivers),
            ro_slivers,
        ))
        ro_slivers = CommonUtils.convert_sliver_dates_to_datetime(ro_slivers)

        return {
            "geni_rspec": "%s" % ro_manifest,
            "geni_urn": last_slice,
            "geni_slivers": ro_slivers
        }
コード例 #5
0
ファイル: delegate_v3.py プロジェクト: HalasNet/felix
    def provision(self, urns, client_cert, credentials, best_effort, end_time,
                  geni_users):
        """Documentation see [geniv3rpc] GENIv3DelegateBase.
        {geni_users} is relevant here."""
        ro_manifest, ro_slivers = ROManifestFormatter(), []
        client_urn = CommonUtils.fetch_user_name_from_geni_users(geni_users)

        slice_urn = db_sync_manager.get_slice_urn(urns)
        slice_monitor = None
        try:
            slice_monitor = SliceMonitoring()
            slice_monitor.add_topology(slice_urn, SliceMonitoring.PROVISIONED,
                                       client_urn)
        except Exception as e:
            logger.warning("Delegate could not send Provision trigger" +
                           " to MS. Details: %s", (e,))

        route = db_sync_manager.get_slice_routing_keys(urns)
        logger.debug("Route=%s" % (route,))

        for r, v in route.iteritems():
            peer = db_sync_manager.get_configured_peer_by_routing_key(r)
            logger.debug("peer=%s" % (peer,))
            if peer.get("type") == self._allowed_peers.get("PEER_CRM"):
                com_m_info, com_slivers = COMUtils().manage_provision(
                    peer, v, credentials, best_effort, end_time, geni_users)

                logger.debug("com_m=%s, com_s=%s" % (com_m_info, com_slivers,))
                for n in com_m_info.get("nodes"):
                    ro_manifest.com_node(n)

                ro_slivers.extend(com_slivers)
                # introduce slice-monitoring info for C resources
                try:
                    slice_monitor.add_c_resources(
                        slice_urn, com_m_info.get("nodes"))
                except Exception as e:
                    logger.warning("Delegate could not monitor COM resources" +
                                   " upon Provision. Details: %s", (e,))

            elif peer.get("type") == self._allowed_peers.get("PEER_SDNRM"):
                of_m_info, of_slivers = SDNUtils().manage_provision(
                    peer, v, credentials, best_effort, end_time, geni_users)

                logger.debug("of_m=%s, of_s=%s" % (of_m_info, of_slivers,))
                for s in of_m_info.get("slivers"):
                    ro_manifest.of_sliver(s)

                ro_slivers.extend(of_slivers)
                # introduce slice-monitoring info for SDN resources
                try:
                    slice_monitor.add_sdn_resources(
                        slice_urn, of_m_info.get("slivers"))
                except Exception as e:
                    logger.warning("Delegate could not monitor SDN resources" +
                                   " upon Provision. Details: %s", (e,))

            elif peer.get("type") == self._allowed_peers.get("PEER_TNRM"):
                tn_m_info, tn_slivers = TNUtils().manage_provision(
                    peer, v, credentials, best_effort, end_time, geni_users)

                logger.debug("tn_m=%s, tn_s=%s" % (tn_m_info, tn_slivers,))
                for n in tn_m_info.get("nodes"):
                    ro_manifest.tn_node(n)
                for l in tn_m_info.get("links"):
                    ro_manifest.tn_link(l)

                ro_slivers.extend(tn_slivers)
                # introduce slice-monitoring info for TN resources
                try:
                    slice_monitor.add_tn_resources(
                        slice_urn, tn_m_info.get("nodes"),
                        tn_m_info.get("links"), peer)
                except Exception as e:
                    logger.warning("Delegate could not monitor TN resources" +
                                   " upon Provision. Details: %s", (e,))

            elif peer.get("type") == self._allowed_peers.get("PEER_SERM"):
                se_m_info, se_slivers = SEUtils().manage_provision(
                    peer, v, credentials, best_effort, end_time, geni_users)

                logger.debug("se_m=%s, se_s=%s" % (se_m_info, se_slivers,))
                for n in se_m_info.get("nodes"):
                    ro_manifest.se_node(n)
                for l in se_m_info.get("links"):
                    ro_manifest.se_link(l)

                ro_slivers.extend(se_slivers)
                # introduce slice-monitoring info for SE resources
                try:
                    slice_monitor.add_se_resources(
                        slice_urn, se_m_info.get("nodes"),
                        se_m_info.get("links"))
                except Exception as e:
                    logger.warning("Delegate could not monitor SE resources" +
                                   " upon Provision. Details: %s", (e,))

            elif peer.get("type") == self._allowed_peers.get("PEER_RO"):
                ro_m_info, ro_slivers_ro = ROUtils().manage_provision(
                    peer, v, credentials, best_effort, end_time, geni_users)

                logger.debug("ro_m=%s, ro_s=%s" % (ro_m_info, ro_slivers,))
                ro_manifest = ROUtils.generate_describe_manifest(
                    ro_manifest, ro_m_info)

                ro_slivers.extend(ro_slivers_ro)
                # introduce slice-monitoring info for ALL the resource types!
                try:
                    slice_monitor.add_c_resources(
                        slice_urn, ro_m_info.get("com_nodes"))
                    slice_monitor.add_sdn_resources(
                        slice_urn, ro_m_info.get("sdn_slivers"))
                    slice_monitor.add_tn_resources(
                        slice_urn, ro_m_info.get("tn_nodes"),
                        ro_m_info.get("tn_links"), peer)
                    slice_monitor.add_se_resources(
                        slice_urn, ro_m_info.get("se_nodes"),
                        ro_m_info.get("se_links"))
                except Exception as e:
                    logger.warning("Delegate could not monitor RO resources" +
                                   " upon Provision. Details: %s", (e,))

        # send slice-monitoring info to the monitoring system
        try:
            # Before sending the slice info, we need to add some "virtual"
            # links (island-to-island)!
            slice_monitor.add_island_to_island_links(slice_urn)
            slice_monitor.send()
            # add slice_monitoring object to the slice table
            db_sync_manager.store_slice_monitoring_info(
                slice_urn, slice_monitor.serialize())
        except Exception as e:
            logger.warning("Delegate could not send (store) slice monitoring" +
                           " information upon Provision. Details: %s", (e,))

        logger.debug("RO-ManifestFormatter=%s" % (ro_manifest,))

        # In order to prevent data conversion error, we manipulate the
        # geni-expires parameter. At least 1 parameter should be not null!
        valid_geni_expires = None
        for s in ro_slivers:
            if s["geni_expires"] is not None:
                valid_geni_expires = s["geni_expires"]
                break
        ro_slivers = CommonUtils.convert_sliver_dates_to_datetime(
            ro_slivers, valid_geni_expires)
        return ("%s" % ro_manifest, ro_slivers)
コード例 #6
0
ファイル: delegate_v3.py プロジェクト: HalasNet/felix
    def describe(self, urns, client_cert, credentials):
        """Documentation see [geniv3rpc] GENIv3DelegateBase."""

        ro_manifest, ro_slivers, last_slice = ROManifestFormatter(), [], ""

        route = db_sync_manager.get_slice_routing_keys(urns)
        logger.debug("Route=%s" % (route,))

        for r, v in route.iteritems():
            peer = db_sync_manager.get_configured_peer_by_routing_key(r)
            logger.debug("peer=%s" % (peer,))
            if peer.get("type") == self._allowed_peers.get("PEER_SDNRM"):
                of_m_info, last_slice, of_slivers =\
                    SDNUtils().manage_describe(peer, v, credentials)

                logger.debug("of_m=%s, of_s=%s, urn=%s" %
                             (of_m_info, of_slivers, last_slice))
                for s in of_m_info.get("slivers"):
                    ro_manifest.of_sliver(s)

                ro_slivers.extend(of_slivers)

            elif peer.get("type") == self._allowed_peers.get("PEER_TNRM"):
                tn_m_info, last_slice, tn_slivers =\
                    TNUtils().manage_describe(peer, v, credentials)

                logger.debug("tn_m=%s, tn_s=%s, urn=%s" %
                             (tn_m_info, tn_slivers, last_slice))
                for n in tn_m_info.get("nodes"):
                    ro_manifest.tn_node(n)
                for l in tn_m_info.get("links"):
                    ro_manifest.tn_link(l)

                ro_slivers.extend(tn_slivers)

            elif peer.get("type") == self._allowed_peers.get("PEER_SERM"):
                se_m_info, last_slice, se_slivers =\
                    SEUtils().manage_describe(peer, v, credentials)

                logger.debug("se_m=%s, se_s=%s, urn=%s" %
                             (se_m_info, se_slivers, last_slice))
                for n in se_m_info.get("nodes"):
                    ro_manifest.se_node(n)
                for l in se_m_info.get("links"):
                    ro_manifest.se_link(l)

                ro_slivers.extend(se_slivers)

            elif peer.get("type") == self._allowed_peers.get("PEER_CRM"):
                com_m_info, last_slice, com_slivers =\
                    COMUtils().manage_describe(peer, v, credentials)

                logger.debug("com_m=%s, com_s=%s, urn=%s" %
                             (com_m_info, com_slivers, last_slice))
                for n in com_m_info.get("nodes"):
                    ro_manifest.com_node(n)
                ro_slivers.extend(com_slivers)

            elif peer.get("type") == self._allowed_peers.get("PEER_RO"):
                ro_m_info, last_slice, ro_slivers_ro =\
                    ROUtils().manage_describe(peer, v, credentials)

                logger.debug("ro_m=%s, ro_s=%s, urn=%s" %
                             (ro_m_info, ro_slivers, last_slice))
                ro_manifest = ROUtils.generate_describe_manifest(
                    ro_manifest, ro_m_info)
                ro_slivers.extend(ro_slivers_ro)

        logger.debug("RO-ManifestFormatter=%s" % (ro_manifest,))
        logger.debug("RO-Slivers(%d)=%s" % (len(ro_slivers), ro_slivers,))
        ro_slivers = CommonUtils.convert_sliver_dates_to_datetime(ro_slivers)

        return {"geni_rspec": "%s" % ro_manifest,
                "geni_urn": last_slice,
                "geni_slivers": ro_slivers}