本文整理汇总了Python中ion.agents.platform.rsn.oms_client_factory.CIOMSClientFactory类的典型用法代码示例。如果您正苦于以下问题:Python CIOMSClientFactory类的具体用法?Python CIOMSClientFactory怎么用?Python CIOMSClientFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CIOMSClientFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: disconnect
def disconnect(self):
"""
Stops event dispatch and destroys the CIOMSClient instance.
"""
self._stop_event_dispatch()
CIOMSClientFactory.destroy_instance(self._rsn_oms)
self._rsn_oms = None
log.debug("%r: CIOMSClient instance destroyed", self._platform_id)
示例2: 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()
示例3: 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)
CIOMSClientFactory.destroy_instance(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)
示例4: _register_oms_listener
def _register_oms_listener(self):
#load the paramaters and the param dicts necesssary for the VEL3D
log.debug( "---------- connect_to_oms ---------- ")
log.debug("oms_uri = %s", OMS_URI)
self.oms = CIOMSClientFactory.create_instance(OMS_URI)
#buddha url
url = "http://10.22.88.168:5000/ion-service/oms_event"
log.info("test_oms_events_receive:setup http url %s", url)
result = self.oms.event.register_event_listener(url)
log.debug("_register_oms_listener register_event_listener result %s", result)
#-------------------------------------------------------------------------------------
# Set up the subscriber to catch the alert event
#-------------------------------------------------------------------------------------
def callback_for_alert(event, *args, **kwargs):
log.debug("caught an OMSDeviceStatusEvent: %s", event)
self.catch_alert.put(event)
self.event_subscriber = EventSubscriber(event_type='OMSDeviceStatusEvent',
callback=callback_for_alert)
self.event_subscriber.start()
self.addCleanup(self.event_subscriber.stop)
result = self.oms.event.generate_test_event({'platform_id': 'fake_platform_id', 'message': "fake event triggered from CI using OMS' generate_test_event", 'severity': '3', 'group ': 'power'})
log.debug("_register_oms_listener generate_test_event result %s", result)
示例5: disconnect
def disconnect(self, recursion=None):
"""
Stops event dispatch and destroys the CIOMSClient instance.
"""
self._stop_event_dispatch()
# power off all ports with connected devices
if recursion:
for port in self._active_ports:
log.debug('disconnect power port: %s', port)
self.turn_off_port(port)
CIOMSClientFactory.destroy_instance(self._rsn_oms)
self._rsn_oms = None
log.debug("%r: CIOMSClient instance destroyed", self._platform_id)
示例6: _launch_simulator
def _launch_simulator(self):
if self._oms_uri == "launchsimulator":
self.addCleanup(CIOMSClientFactory.stop_launched_simulator)
log.debug("launch_simulator inactivity: %s", self._inactivity_period)
return CIOMSClientFactory.launch_simulator(self._inactivity_period)
else:
return self._oms_uri
示例7: launch
def launch(self):
"""
Launches the simulator process as indicated by _COMMAND.
@return (rsn_oms, uri) A pair with the CIOMSSimulator instance and the
associated URI to establish connection with it.
"""
log.debug("[OMSim] Launching: %s", _COMMAND)
self._process = self._spawn(_COMMAND)
if not self._process or not self.poll():
msg = "[OMSim] Failed to launch simulator: %s" % _COMMAND
log.error(msg)
raise Exception(msg)
log.debug("[OMSim] process started, pid: %s", self.getpid())
# give it some time to start up
sleep(5)
# get URI:
uri = None
with open("logs/rsn_oms_simulator.yml", buffering=1) as f:
# we expect one of the first few lines to be of the form:
# rsn_oms_simulator_uri=xxxx
# where xxxx is the uri -- see oms_simulator_server.
while uri is None:
line = f.readline()
if line.index("rsn_oms_simulator_uri=") == 0:
uri = line[len("rsn_oms_simulator_uri="):].strip()
self._rsn_oms = CIOMSClientFactory.create_instance(uri)
return self._rsn_oms, uri
示例8: 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()
示例9: connect
def connect(self, recursion=None):
"""
Creates an CIOMSClient instance, does a ping to verify connection,
and starts event dispatch.
"""
# create CIOMSClient:
oms_uri = self._driver_config['oms_uri']
log.debug("%r: creating CIOMSClient instance with oms_uri=%r",
self._platform_id, oms_uri)
self._rsn_oms = CIOMSClientFactory.create_instance(oms_uri)
log.debug("%r: CIOMSClient instance created: %s",
self._platform_id, self._rsn_oms)
# ping to verify connection:
self.ping()
# start event dispatch:
self._start_event_dispatch()
# TODO(OOIION-1495) review the following. Commented out for the moment.
# Note, per the CI-OMS spec ports need to be turned OFF to then proceed
# with connecting instruments. So we need to determine whether we
# want to turn all ports ON in this "connect driver" operation,
# and then add the logic to turn a port OFF before connecting
# instruments, and then ON again; or, just do the OFF/ON logic in the
# connect_instrument and disconnect_instrument operations,
# but not here.
"""
示例10: test_oms_events_receive
def test_oms_events_receive(self):
log.debug("oms_uri = %s", OMS_URI)
self.oms = CIOMSClientFactory.create_instance(OMS_URI)
#CI url
#url = "http://128.54.26.120:5000/ion-service/oms_event"
#buddha url
url = "http://128.54.29.48:5000/ion-service/oms_event"
log.info("test_oms_events_receive:setup http url %s", url)
result = self.oms.event.register_event_listener(url)
log.info("test_oms_events_receive:setup register_event_listener result %s", result)
#-------------------------------------------------------------------------------------
# Set up the subscriber to catch the alert event
#-------------------------------------------------------------------------------------
def callback_for_alert(event, *args, **kwargs):
log.debug("caught an OMSDeviceStatusEvent: %s", event)
self.catch_alert.put(event)
self.event_subscriber = EventSubscriber(event_type='OMSDeviceStatusEvent',
callback=callback_for_alert)
self.event_subscriber.start()
self.addCleanup(self.event_subscriber.stop)
#test the listener
result = self.oms.event.generate_test_event({'platform_id': 'fake_platform_id1', 'message': "fake event triggered from CI using OMS' generate_test_event", 'severity': '3', 'group ': 'power'})
log.info("test_oms_events_receive:setup generate_test_event result %s", result)
result = self.oms.event.generate_test_event({'platform_id': 'fake_platform_id2', 'message': "fake event triggered from CI using OMS' generate_test_event", 'severity': '3', 'group ': 'power'})
log.info("test_oms_events_receive:setup generate_test_event result %s", result)
result = self.oms.event.generate_test_event({'platform_id': 'fake_platform_id3', 'message': "fake event triggered from CI using OMS' generate_test_event", 'severity': '3', 'group ': 'power'})
log.info("test_oms_events_receive:setup generate_test_event result %s", result)
oms_event_counter = 0
runtime = 0
starttime = time.time()
caught_events = []
#catch several events to get some samples from OMS
while oms_event_counter < 10 and runtime < 60 :
a = self.catch_alert.get(timeout=60)
caught_events.append(a)
oms_event_counter += 1
runtime = time.time() - starttime
result = self.oms.event.unregister_event_listener(url)
log.debug("unregister_event_listener result: %s", result)
self.assertTrue(oms_event_counter > 0)
示例11: setUp
def setUp(self):
oms_uri = os.getenv('OMS', "launchsimulator")
oms_uri = self._dispatch_simulator(oms_uri)
log.debug("oms_uri = %s", oms_uri)
self.oms = CIOMSClientFactory.create_instance(oms_uri)
def done():
CIOMSClientFactory.destroy_instance(self.oms)
self.addCleanup(done)
示例12: disconnect
def disconnect(self, recursion=None):
"""
Stops event dispatch and destroys the CIOMSClient instance.
"""
self._stop_event_dispatch()
# TODO(OOIION-1495) review the following. Only change is the use
# of self._pnode.ports instead of self._active_ports,
# while we address the "active ports" concept mentioned above.
# BTW, is it OK to turn off ports in this "disconnect driver" operation?
# power off all ports with connected devices
if recursion:
for port in self._pnode.ports:
log.debug('disconnect power port: %s', port)
self.turn_off_port(port)
CIOMSClientFactory.destroy_instance(self._rsn_oms)
self._rsn_oms = None
log.debug("%r: CIOMSClient instance destroyed", self._platform_id)
示例13: connect
def connect(self):
"""
Creates an CIOMSClient instance and does a ping.
"""
oms_uri = self._driver_config['oms_uri']
log.debug("%r: creating CIOMSClient instance with oms_uri=%r",
self._platform_id, oms_uri)
self._rsn_oms = CIOMSClientFactory.create_instance(oms_uri)
log.debug("%r: CIOMSClient instance created: %s",
self._platform_id, self._rsn_oms)
self.ping()
示例14: setUp
def setUp(self):
oms_uri = os.getenv('OMS', "launchsimulator")
oms_uri = self._dispatch_simulator(oms_uri)
log.debug("oms_uri = %s", oms_uri)
self.oms = CIOMSClientFactory.create_instance(oms_uri)
OmsTestMixin.start_http_server()
def done():
CIOMSClientFactory.destroy_instance(self.oms)
event_notifications = OmsTestMixin.stop_http_server()
log.info("event_notifications = %s" % str(event_notifications))
self.addCleanup(done)
示例15: _simulator_disable
def _simulator_disable(self):
"""
Disables the simulator to cause the effect of having lost the connection.
"""
if self._oms_uri == "launchsimulator":
rsn_oms = CIOMSClientFactory.get_rsn_oms_for_launched_simulator()
self.assertIsNotNone(rsn_oms, "the simulator must have been " "launched and be running")
rsn_oms.x_disable()
elif self._oms_uri == "embsimulator":
CIOMSSimulator.x_disable()
else:
self.fail("_simulator_disable does not work for: %s" % self._oms_uri)