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


Python network_util.NetworkUtil类代码示例

本文整理汇总了Python中ion.agents.platform.util.network_util.NetworkUtil的典型用法代码示例。如果您正苦于以下问题:Python NetworkUtil类的具体用法?Python NetworkUtil怎么用?Python NetworkUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: setUp

    def setUp(self):
        self.DVR_CONFIG = {
            'oms_uri':    self._dispatch_simulator('launchsimulator'),
            'attributes': {},
            'ports':      {}
        }
        log.debug("DVR_CONFIG['oms_uri'] = %s", self.DVR_CONFIG['oms_uri'])

        yaml_filename = 'ion/agents/platform/rsn/simulator/network.yml'
        log.debug("retrieving network definition from %s", yaml_filename)
        network_definition = NetworkUtil.deserialize_network_definition(file(yaml_filename))

        if log.isEnabledFor(logging.DEBUG):
            network_definition_ser = NetworkUtil.serialize_network_definition(network_definition)
            log.debug("NetworkDefinition serialization:\n%s", network_definition_ser)

        platform_id = self.PLATFORM_ID
        pnode = network_definition.pnodes[platform_id]

        def evt_recv(driver_event):
            log.debug('GOT driver_event=%s', str(driver_event))

        self._plat_driver = RSNPlatformDriver(pnode, evt_recv, Mock(), Mock())
        res_state = self._plat_driver.get_resource_state()
        self.assertEqual(res_state, RSNPlatformDriverState.UNCONFIGURED)
开发者ID:ednad,项目名称:coi-services,代码行数:25,代码来源:test_rsn_platform_driver.py

示例2: test_serialization_deserialization

    def test_serialization_deserialization(self):
        # create NetworkDefinition object by de-serializing the simulated network:
        ndef = NetworkUtil.deserialize_network_definition(
                file('ion/agents/platform/rsn/simulator/network.yml'))

        # serialize object to string
        serialization = NetworkUtil.serialize_network_definition(ndef)

        # recreate object by de-serializing the string:
        ndef2 = NetworkUtil.deserialize_network_definition(serialization)

        # verify the objects are equal:
        self.assertEquals(ndef.diff(ndef2), None)
开发者ID:blazetopher,项目名称:coi-services,代码行数:13,代码来源:test_network_util.py

示例3: setUp

    def setUp(self):

        DVR_CONFIG['oms_uri'] = self._dispatch_simulator(oms_uri)
        log.debug("DVR_CONFIG['oms_uri'] = %s", DVR_CONFIG['oms_uri'])

        yaml_filename = 'ion/agents/platform/rsn/simulator/network.yml'
        log.debug("retrieving network definition from %s", yaml_filename)
        network_definition = NetworkUtil.deserialize_network_definition(file(yaml_filename))

        if log.isEnabledFor(logging.DEBUG):
            network_definition_ser = NetworkUtil.serialize_network_definition(network_definition)
            log.debug("NetworkDefinition serialization:\n%s", network_definition_ser)

        platform_id = self.PLATFORM_ID
        pnode = network_definition.pnodes[platform_id]
        self._plat_driver = RSNPlatformDriver(pnode, self.evt_recv)
开发者ID:StevenMyerson,项目名称:marine-integrations,代码行数:16,代码来源:test_rsn_platform_driver.py

示例4: setUp

    def setUp(self):
        self._start_container()

        self.container.start_rel_from_url('res/deploy/r2deploy.yml')

        self.RR   = ResourceRegistryServiceClient(node=self.container.node)
        self.IMS  = InstrumentManagementServiceClient(node=self.container.node)
        self.DAMS = DataAcquisitionManagementServiceClient(node=self.container.node)
        self.DP   = DataProductManagementServiceClient(node=self.container.node)
        self.PSC  = PubsubManagementServiceClient(node=self.container.node)
        self.PDC  = ProcessDispatcherServiceClient(node=self.container.node)
        self.DSC  = DatasetManagementServiceClient()
        self.IDS  = IdentityManagementServiceClient(node=self.container.node)
        self.RR2  = EnhancedResourceRegistryClient(self.RR)


        # Use the network definition provided by RSN OMS directly.
        rsn_oms = CIOMSClientFactory.create_instance(DVR_CONFIG['oms_uri'])
        self._network_definition = RsnOmsUtil.build_network_definition(rsn_oms)
        # get serialized version for the configuration:
        self._network_definition_ser = NetworkUtil.serialize_network_definition(self._network_definition)
        if log.isEnabledFor(logging.TRACE):
            log.trace("NetworkDefinition serialization:\n%s", self._network_definition_ser)


        self._async_data_result = AsyncResult()
        self._data_subscribers = []
        self._samples_received = []
        self.addCleanup(self._stop_data_subscribers)

        self._async_event_result = AsyncResult()
        self._event_subscribers = []
        self._events_received = []
        self.addCleanup(self._stop_event_subscribers)
        self._start_event_subscriber()
开发者ID:newbrough,项目名称:coi-services,代码行数:35,代码来源:test_platform_launch.py

示例5: test_compute_checksum

    def test_compute_checksum(self):
        # create NetworkDefinition object by de-serializing the simulated network:
        ndef = NetworkUtil.deserialize_network_definition(file("ion/agents/platform/rsn/simulator/network.yml"))

        checksum = ndef.compute_checksum()
        if log.isEnabledFor(logging.DEBUG):
            log.debug("NetworkDefinition checksum = %s", checksum)
开发者ID:pkediyal,项目名称:coi-services,代码行数:7,代码来源:test_network_util.py

示例6: __init__

    def __init__(self, pnode, evt_recv):
        """
        Creates a PlatformDriver instance.

        @param pnode     Root PlatformNode defining the platform network rooted at
                         this platform.
        @param evt_recv  Listener of events generated by this driver
        """
        assert pnode, "pnode must be given"
        assert evt_recv, "evt_recv parameter must be given"

        self._pnode = pnode
        self._send_event = evt_recv

        self._platform_id = self._pnode.platform_id
        if self._pnode.parent:
            self._parent_platform_id = self._pnode.parent.platform_id
        else:
            self._parent_platform_id = None

        self._platform_attributes = \
            dict((a.attr_id, a.defn) for a in self._pnode.attrs.itervalues())

        if log.isEnabledFor(logging.DEBUG):
            log.debug("%r: PlatformDriver constructor called: pnode:\n%s\n"
                      "_platform_attributes=%s",
                      self._platform_id,
                      NetworkUtil._dump_pnode(self._pnode, include_subplatforms=False),
                      self._platform_attributes)

        self._driver_config = None

        # construct FSM and start it with initial state UNCONFIGURED:
        self._construct_fsm()
        self._fsm.start(PlatformDriverState.UNCONFIGURED)
开发者ID:newbrough,项目名称:coi-services,代码行数:35,代码来源:platform_driver.py

示例7: gen_diagrams

 def gen_diagrams(name, pnode):
     yml_name = '%s.yml' % name
     file(yml_name, 'w').write(NetworkUtil._gen_yaml(pnode))
     dot_name = '%s.dot' % name
     pml_name = '%s.puml' % name
     file(dot_name, 'w').write(NetworkUtil._gen_diagram(pnode, style="dot"))
     file(pml_name, 'w').write(NetworkUtil._gen_diagram(pnode, style="plantuml"))
     print "topology =\n%s" % NetworkUtil._dump_pnode(pnode, only_topology=True)
     try:
         dot_cmd = 'dot -Tpng %s.dot -o %s.png' % (name,name)
         open_cmd = 'open %s.png' % name
         import subprocess
         subprocess.call(dot_cmd.split())
         subprocess.call(open_cmd.split())
     except Exception, e:
         print "error generating diagrams: %s" % str(e)
开发者ID:blazetopher,项目名称:coi-services,代码行数:16,代码来源:oms_simple.py

示例8: test_build_network_definition

    def test_build_network_definition(self):
        ndef = RsnOmsUtil.build_network_definition(self._rsn_oms)

        if log.isEnabledFor(logging.TRACE):
            # serialize object to string
            serialization = NetworkUtil.serialize_network_definition(ndef)
            log.trace("NetworkDefinition serialization:\n%s", serialization)

        if not isinstance(self._rsn_oms, CIOMSSimulator):
            # OK, no more tests if we are not using the embedded simulator
            return

        # Else: do some verifications against network.yml (the spec used by
        # the simulator):

        self.assertTrue("UPS" in ndef.platform_types)

        pnode = ndef.root

        self.assertEqual(pnode.platform_id, "ShoreStation")
        self.assertTrue("ShoreStation_attr_1" in pnode.attrs)
        self.assertTrue("ShoreStation_port_1" in pnode.ports)

        sub_pnodes = pnode.subplatforms
        self.assertTrue("L3-UPS1" in sub_pnodes)
        self.assertTrue("Node1A" in sub_pnodes)
        self.assertTrue("input_voltage" in sub_pnodes["Node1A"].attrs)
        self.assertTrue("Node1A_port_1" in sub_pnodes["Node1A"].ports)
开发者ID:blazetopher,项目名称:coi-services,代码行数:28,代码来源:test_oms_util.py

示例9: setUpClass

    def setUpClass(cls):
        HelperTestMixin.setUpClass()

        # Use the network definition provided by RSN OMS directly.
        rsn_oms = CIOMSClientFactory.create_instance(DVR_CONFIG["oms_uri"])
        network_definition = RsnOmsUtil.build_network_definition(rsn_oms)
        network_definition_ser = NetworkUtil.serialize_network_definition(network_definition)
        if log.isEnabledFor(logging.DEBUG):
            log.debug("NetworkDefinition serialization:\n%s", network_definition_ser)

        cls.PLATFORM_CONFIG = {
            "platform_id": cls.PLATFORM_ID,
            "driver_config": DVR_CONFIG,
            "network_definition": network_definition_ser,
        }

        NetworkUtil._gen_open_diagram(network_definition.pnodes[cls.PLATFORM_ID])
开发者ID:newbrough,项目名称:coi-services,代码行数:17,代码来源:test_platform_agent_with_oms.py

示例10: setUp

    def setUp(self):
        self._start_container()

        self.container.start_rel_from_url('res/deploy/r2deploy.yml')

        self.RR   = ResourceRegistryServiceClient(node=self.container.node)
        self.IMS  = InstrumentManagementServiceClient(node=self.container.node)
        self.DAMS = DataAcquisitionManagementServiceClient(node=self.container.node)
        self.DP   = DataProductManagementServiceClient(node=self.container.node)
        self.PSC  = PubsubManagementServiceClient(node=self.container.node)
        self.PDC  = ProcessDispatcherServiceClient(node=self.container.node)
        self.DSC  = DatasetManagementServiceClient()
        self.IDS  = IdentityManagementServiceClient(node=self.container.node)
        self.RR2  = EnhancedResourceRegistryClient(self.RR)

        self.org_id = self.RR2.create(any_old(RT.Org))
        log.debug("Org created: %s", self.org_id)

        # Use the network definition provided by RSN OMS directly.
        rsn_oms = CIOMSClientFactory.create_instance(DVR_CONFIG['oms_uri'])
        self._network_definition = RsnOmsUtil.build_network_definition(rsn_oms)
        CIOMSClientFactory.destroy_instance(rsn_oms)

        # get serialized version for the configuration:
        self._network_definition_ser = NetworkUtil.serialize_network_definition(self._network_definition)
        log.trace("NetworkDefinition serialization:\n%s", self._network_definition_ser)

        # set attributes for the platforms:
        self._platform_attributes = {}
        for platform_id in self._network_definition.pnodes:
            pnode = self._network_definition.pnodes[platform_id]
            dic = dict((attr.attr_id, attr.defn) for attr in pnode.attrs.itervalues())
            self._platform_attributes[platform_id] = dic
        log.trace("_platform_attributes: %s", self._platform_attributes)

        # set ports for the platforms:
        self._platform_ports = {}
        for platform_id in self._network_definition.pnodes:
            pnode = self._network_definition.pnodes[platform_id]
            dic = {}
            for port_id, port in pnode.ports.iteritems():
                dic[port_id] = dict(port_id=port_id,
                                    network=port.network)
            self._platform_ports[platform_id] = dic
        log.trace("_platform_ports: %s", self._platform_attributes)

        self._async_data_result = AsyncResult()
        self._data_subscribers = []
        self._samples_received = []
        self.addCleanup(self._stop_data_subscribers)

        self._async_event_result = AsyncResult()
        self._event_subscribers = []
        self._events_received = []
        self.addCleanup(self._stop_event_subscribers)
        self._start_event_subscriber()
开发者ID:mbarry02,项目名称:coi-services,代码行数:56,代码来源:base_test_platform_agent_with_rsn.py

示例11: __init__

    def __init__(self, pnode, event_callback,
                 create_event_subscriber, destroy_event_subscriber):
        """
        Creates a PlatformDriver instance.

        @param pnode           Root PlatformNode defining the platform network
                               rooted at this platform.
        @param event_callback  Callback to notify platform agent about events
                               generated by this driver.
                               This is captured in self._send_event for this
                               class and subclasses to call as needed.

        @param create_event_subscriber
        @param destroy_event_subscriber
                 functions to create/destroy any needed EventSubscriber's,
                 in particular regarding the Managed Endpoint API.
        """

        #
        # NOTE the "pnode" parameter may be not very "standard" but it is the
        # current convenient mechanism that captures the overall definition
        # of the corresponding platform (most of which coming from configuration)
        #

        self._pnode = pnode
        self._send_event = event_callback

        self._create_event_subscriber = create_event_subscriber
        self._destroy_event_subscriber = destroy_event_subscriber

        self._platform_id = self._pnode.platform_id
        if self._pnode.parent:
            self._parent_platform_id = self._pnode.parent.platform_id
        else:
            self._parent_platform_id = None

        self._platform_attributes = \
            dict((a.attr_id, a.defn) for a in self._pnode.attrs.itervalues())

        if log.isEnabledFor(logging.DEBUG):
            log.debug("%r: PlatformDriver constructor called: pnode:\n%s\n"
                      "_platform_attributes=%s",
                      self._platform_id,
                      NetworkUtil._dump_pnode(self._pnode, include_subplatforms=False),
                      self._platform_attributes)

        self._driver_config = None
        self._resource_schema = {}
        
        # The parameter dictionary.
        self._param_dict = {}

        # construct FSM and start it with initial state UNCONFIGURED:
        self._construct_fsm()
        self._fsm.start(PlatformDriverState.UNCONFIGURED)
开发者ID:StevenMyerson,项目名称:marine-integrations,代码行数:55,代码来源:platform_driver.py

示例12: test_create_network_definition_from_ci_config_bad

    def test_create_network_definition_from_ci_config_bad(self):

        CFG = DotDict({
            'device_type' : "bad_device_type",
        })

        # device_type
        with self.assertRaises(NetworkDefinitionException):
            NetworkUtil.create_network_definition_from_ci_config(CFG)

        CFG = DotDict({
            'device_type' : "PlatformDevice",
        })

        # missing platform_id
        with self.assertRaises(NetworkDefinitionException):
            NetworkUtil.create_network_definition_from_ci_config(CFG)

        CFG = DotDict({
            'device_type' : "PlatformDevice",

            'platform_config': {
                'platform_id': 'Node1D'
            },
        })

        # missing driver_config
        with self.assertRaises(NetworkDefinitionException):
            NetworkUtil.create_network_definition_from_ci_config(CFG)
开发者ID:ednad,项目名称:coi-services,代码行数:29,代码来源:test_network_util.py

示例13: __init__

    def __init__(self, yaml_filename='ion/agents/platform/rsn/simulator/network.yml'):
        self._ndef = NetworkUtil.deserialize_network_definition(file(yaml_filename))
        self._platform_types = self._ndef.platform_types
        self._pnodes = self._ndef.pnodes

        # registered event listeners: {url: reg_time, ...},
        # where reg_time is the NTP time of (latest) registration.
        # NOTE: for simplicity, we don't keep info about unregistered listeners
        self._reg_event_listeners = {}

        self._event_notifier = EventNotifier()
        # EventGenerator only kept while there are listeners registered
        self._event_generator = None
开发者ID:MauriceManning,项目名称:coi-services,代码行数:13,代码来源:oms_simulator.py

示例14: setUp

    def setUp(self):

        # Use the network definition provided by RSN OMS directly.
        rsn_oms = CIOMSClientFactory.create_instance(DVR_CONFIG['oms_uri'])
        network_definition = RsnOmsUtil.build_network_definition(rsn_oms)

        if log.isEnabledFor(logging.DEBUG):
            network_definition_ser = NetworkUtil.serialize_network_definition(network_definition)
            log.debug("NetworkDefinition serialization:\n%s", network_definition_ser)

        platform_id = self.PLATFORM_ID
        pnode = network_definition.pnodes[platform_id]
        self._plat_driver = RSNPlatformDriver(pnode, self.evt_recv)
开发者ID:blazetopher,项目名称:coi-services,代码行数:13,代码来源:test_oms_platform_driver.py

示例15: __init__

    def __init__(self, pnode, event_callback):
        """
        Creates a PlatformDriver instance.

        @param pnode           Root PlatformNode defining the platform network
                               rooted at this platform.
        @param event_callback  Listener of events generated by this driver
        """

        #
        # NOTE the "pnode" parameter may be not very "standard" but it is the
        # current convenient mechanism that captures the overall definition
        # of the corresponding platform (most of which coming from configuration)
        #

        assert pnode, "pnode must be given"
        assert event_callback, "event_callback parameter must be given"

        self._pnode = pnode
        self._send_event = event_callback

        self._platform_id = self._pnode.platform_id
        if self._pnode.parent:
            self._parent_platform_id = self._pnode.parent.platform_id
        else:
            self._parent_platform_id = None

        self._platform_attributes = \
            dict((a.attr_id, a.defn) for a in self._pnode.attrs.itervalues())

        if log.isEnabledFor(logging.DEBUG):
            log.debug("%r: PlatformDriver constructor called: pnode:\n%s\n"
                      "_platform_attributes=%s",
                      self._platform_id,
                      NetworkUtil._dump_pnode(self._pnode, include_subplatforms=False),
                      self._platform_attributes)

        self._driver_config = None
        self._resource_schema = {}
        
        # The parameter dictionary.
        self._param_dict = {}

        # construct FSM and start it with initial state UNCONFIGURED:
        self._construct_fsm()
        self._fsm.start(PlatformDriverState.UNCONFIGURED)
开发者ID:MauriceManning,项目名称:coi-services,代码行数:46,代码来源:platform_driver.py


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