本文整理汇总了Python中interface.services.sa.iobservatory_management_service.ObservatoryManagementServiceClient.assign_instrument_model_to_instrument_site方法的典型用法代码示例。如果您正苦于以下问题:Python ObservatoryManagementServiceClient.assign_instrument_model_to_instrument_site方法的具体用法?Python ObservatoryManagementServiceClient.assign_instrument_model_to_instrument_site怎么用?Python ObservatoryManagementServiceClient.assign_instrument_model_to_instrument_site使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类interface.services.sa.iobservatory_management_service.ObservatoryManagementServiceClient
的用法示例。
在下文中一共展示了ObservatoryManagementServiceClient.assign_instrument_model_to_instrument_site方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestDataProductProvenance
# 需要导入模块: from interface.services.sa.iobservatory_management_service import ObservatoryManagementServiceClient [as 别名]
# 或者: from interface.services.sa.iobservatory_management_service.ObservatoryManagementServiceClient import assign_instrument_model_to_instrument_site [as 别名]
#.........这里部分代码省略.........
for v in res.itervalues():
if 'parent' in v:
parent_count += 1
if 'config' in v:
config_count += 1
#Make sure there are three parents and four configs
self.assertEqual(parent_count, 3)
self.assertEqual(config_count, 4)
@unittest.skip('This test is obsolete with new framework')
def test_get_provenance(self):
#create a deployment with metadata and an initial site and device
instrument_site_obj = IonObject(RT.InstrumentSite,
name='InstrumentSite1',
description='test instrument site')
instrument_site_id = self.omsclient.create_instrument_site(instrument_site_obj, "")
log.debug( 'test_get_provenance: new instrument_site_id id = %s ', str(instrument_site_id))
# Create InstrumentModel
instModel_obj = IonObject(RT.InstrumentModel,
name='SBE37IMModel',
description="SBE37IMModel" )
try:
instModel_id = self.imsclient.create_instrument_model(instModel_obj)
except BadRequest as ex:
self.fail("failed to create new InstrumentModel: %s" %ex)
log.debug( 'test_get_provenance: new InstrumentModel id = %s ', str(instModel_id))
self.omsclient.assign_instrument_model_to_instrument_site(instModel_id, instrument_site_id)
# Create InstrumentAgent
parsed_config = StreamConfiguration(stream_name='parsed', parameter_dictionary_name='ctd_parsed_param_dict' )
instAgent_obj = IonObject(RT.InstrumentAgent,
name='agent007',
description="SBE37IMAgent",
driver_uri=DRV_URI_GOOD,
stream_configurations = [parsed_config] )
try:
instAgent_id = self.imsclient.create_instrument_agent(instAgent_obj)
except BadRequest as ex:
self.fail("failed to create new InstrumentAgent: %s" %ex)
log.debug( 'test_get_provenance:new InstrumentAgent id = %s', instAgent_id)
self.imsclient.assign_instrument_model_to_instrument_agent(instModel_id, instAgent_id)
# Create InstrumentDevice
log.debug('test_get_provenance: Create instrument resource to represent the SBE37 (SA Req: L4-CI-SA-RQ-241) ')
instDevice_obj = IonObject(RT.InstrumentDevice, name='SBE37IMDevice', description="SBE37IMDevice", serial_number="12345" )
try:
instDevice_id = self.imsclient.create_instrument_device(instrument_device=instDevice_obj)
self.imsclient.assign_instrument_model_to_instrument_device(instModel_id, instDevice_id)
except BadRequest as ex:
self.fail("failed to create new InstrumentDevice: %s" %ex)
log.debug("test_get_provenance: new InstrumentDevice id = %s (SA Req: L4-CI-SA-RQ-241) ", instDevice_id)
#-------------------------------
# Create CTD Parsed data product
#-------------------------------
示例2: TestIMSDeployAsPrimaryDevice
# 需要导入模块: from interface.services.sa.iobservatory_management_service import ObservatoryManagementServiceClient [as 别名]
# 或者: from interface.services.sa.iobservatory_management_service.ObservatoryManagementServiceClient import assign_instrument_model_to_instrument_site [as 别名]
#.........这里部分代码省略.........
try:
instModel_id = self.imsclient.create_instrument_model(instModel_obj)
except BadRequest as ex:
self.fail("failed to create new InstrumentModel: %s" % ex)
# -------------------------------
# Create InstrumentAgent
# -------------------------------
instAgent_obj = IonObject(
RT.InstrumentAgent,
name="agent007",
description="SBE37IMAgent",
driver_uri="http://sddevrepo.oceanobservatories.org/releases/seabird_sbe37smb_ooicore-0.0.1-py2.7.egg",
)
try:
instAgent_id = self.imsclient.create_instrument_agent(instAgent_obj)
except BadRequest as ex:
self.fail("failed to create new InstrumentAgent: %s" % ex)
log.debug("new InstrumentAgent id = %s", instAgent_id)
self.imsclient.assign_instrument_model_to_instrument_agent(instModel_id, instAgent_id)
# -------------------------------
# Create Instrument Site
# -------------------------------
instrumentSite_obj = IonObject(RT.InstrumentSite, name="instrumentSite1", description="SBE37IMInstrumentSite")
try:
instrumentSite_id = self.omsclient.create_instrument_site(instrument_site=instrumentSite_obj, parent_id="")
except BadRequest as ex:
self.fail("failed to create new InstrumentSite: %s" % ex)
print "test_deployAsPrimaryDevice: new instrumentSite id = ", instrumentSite_id
self.omsclient.assign_instrument_model_to_instrument_site(instModel_id, instrumentSite_id)
# -------------------------------
# Logical Transform: Output Data Products
# -------------------------------
# Construct temporal and spatial Coordinate Reference System objects
tdom, sdom = time_series_domain()
sdom = sdom.dump()
tdom = tdom.dump()
parsed_pdict_id = self.dataset_management.read_parameter_dictionary_by_name(
"ctd_parsed_param_dict", id_only=True
)
parsed_stream_def_id = self.pubsubclient.create_stream_definition(
name="parsed", parameter_dictionary_id=parsed_pdict_id
)
raw_pdict_id = self.dataset_management.read_parameter_dictionary_by_name("ctd_raw_param_dict", id_only=True)
raw_stream_def_id = self.pubsubclient.create_stream_definition(name="raw", parameter_dictionary_id=raw_pdict_id)
# -------------------------------
# Create Old InstrumentDevice
# -------------------------------
instDevice_obj = IonObject(
RT.InstrumentDevice,
name="SBE37IMDeviceYear1",
description="SBE37IMDevice for the FIRST year of deployment",
serial_number="12345",
)
try:
oldInstDevice_id = self.imsclient.create_instrument_device(instrument_device=instDevice_obj)
示例3: TestDeployment
# 需要导入模块: from interface.services.sa.iobservatory_management_service import ObservatoryManagementServiceClient [as 别名]
# 或者: from interface.services.sa.iobservatory_management_service.ObservatoryManagementServiceClient import assign_instrument_model_to_instrument_site [as 别名]
#.........这里部分代码省略.........
name='PlatformModel1',
description='test platform model')
model_id = self.imsclient.create_platform_model(platform_model__obj)
#-------------------------------------------------------------------------------------
# Assign platform model to platform device and site
#-------------------------------------------------------------------------------------
self.imsclient.assign_platform_model_to_platform_device(model_id, platform_device_id)
self.omsclient.assign_platform_model_to_platform_site(model_id, site_id)
#-------------------------------------------------------------------------------------
# Create instrument site
#-------------------------------------------------------------------------------------
instrument_site_obj = IonObject(RT.InstrumentSite,
name='InstrumentSite1',
description='test instrument site')
instrument_site_id = self.omsclient.create_instrument_site(instrument_site_obj, site_id)
pdict_id = self.dataset_management.read_parameter_dictionary_by_name('ctd_parsed_param_dict', id_only=True)
ctd_stream_def_id = self.psmsclient.create_stream_definition(name='SBE37_CDM', parameter_dictionary_id=pdict_id)
# Construct temporal and spatial Coordinate Reference System objects
tdom, sdom = time_series_domain()
sdom = sdom.dump()
tdom = tdom.dump()
dp_obj = IonObject(RT.DataProduct,
name='Log Data Product',
description='some new dp',
temporal_domain = tdom,
spatial_domain = sdom)
out_log_data_product_id = self.dmpsclient.create_data_product(dp_obj, ctd_stream_def_id)
#----------------------------------------------------------------------------------------------------
# Start the transform (a logical transform) that acts as an instrument site
#----------------------------------------------------------------------------------------------------
self.omsclient.create_site_data_product( site_id= instrument_site_id,
data_product_id = out_log_data_product_id)
#----------------------------------------------------------------------------------------------------
# Create an instrument device
#----------------------------------------------------------------------------------------------------
instrument_device_obj = IonObject(RT.InstrumentDevice,
name='InstrumentDevice1',
description='test instrument device')
instrument_device_id = self.imsclient.create_instrument_device(instrument_device_obj)
self.rrclient.create_association(platform_device_id, PRED.hasDevice, instrument_device_id)
dp_obj = IonObject(RT.DataProduct,
name='Instrument Data Product',
description='some new dp',
temporal_domain = tdom,
spatial_domain = sdom)
inst_data_product_id = self.dmpsclient.create_data_product(dp_obj, ctd_stream_def_id)
#assign data products appropriately
self.damsclient.assign_data_product(input_resource_id=instrument_device_id,
data_product_id=inst_data_product_id)
#----------------------------------------------------------------------------------------------------
# Create an instrument model
#----------------------------------------------------------------------------------------------------
instrument_model_obj = IonObject(RT.InstrumentModel,
name='InstrumentModel1',
description='test instrument model')
instrument_model_id = self.imsclient.create_instrument_model(instrument_model_obj)
self.imsclient.assign_instrument_model_to_instrument_device(instrument_model_id, instrument_device_id)
self.omsclient.assign_instrument_model_to_instrument_site(instrument_model_id, instrument_site_id)
#----------------------------------------------------------------------------------------------------
# Create a deployment object
#----------------------------------------------------------------------------------------------------
start = IonTime(datetime.datetime(2013,1,1))
end = IonTime(datetime.datetime(2014,1,1))
temporal_bounds = IonObject(OT.TemporalBounds, name='planned', start_datetime=start.to_string(), end_datetime=end.to_string())
deployment_obj = IonObject(RT.Deployment,
name='TestDeployment',
description='some new deployment',
constraint_list=[temporal_bounds])
deployment_id = self.omsclient.create_deployment(deployment_obj)
self.omsclient.deploy_instrument_site(instrument_site_id, deployment_id)
self.imsclient.deploy_instrument_device(instrument_device_id, deployment_id)
log.debug("test_create_deployment: created deployment id: %s ", str(deployment_id) )
self.omsclient.activate_deployment(deployment_id)
示例4: TestRegisterAndActivate
# 需要导入模块: from interface.services.sa.iobservatory_management_service import ObservatoryManagementServiceClient [as 别名]
# 或者: from interface.services.sa.iobservatory_management_service.ObservatoryManagementServiceClient import assign_instrument_model_to_instrument_site [as 别名]
#.........这里部分代码省略.........
Create preexisting infrastructure for the cabled test environment:
sites, deployments, models. These are resources that already
exist in the system due to preload or incremental preload updates.
PlatformModel
InstrumentModel
PlatformSite
InstrumentSite
"""
platform_model_attrs = {
'name' : 'LP Jbox',
'description' : 'Node Type: LJ',
'manufacturer' : 'University of Washington',
'platform_type' : 'Cable Node',
'platform_family' : 'Low Power JBox',
'ci_onboard' : False,
'shore_networked' : True
}
instrument_model_attrs = {
'name': 'Diffuse Vent Fluid 3-D Temperature Array (TMPSF-A)',
'description': 'Measures temperatures of diffuse flow across the seafloor',
'reference_designator': 'TMPSFA',
'class_name': 'Temperature seafloor',
'mixed_sampling_mode': True,
'integrated_inductive_modem_available': True,
'internal_battery': True,
'addl': {'comments': '', 'connector': '',
'makemodel_description': 'XR-420',
'input_voltage_range': '',
'interface': '',
'output_description': '',
'class_long_name': 'Temperature_seafloor'},
'ooi_make_model': 'XR-420',
'series_name': 'TMPSF Series A',
'inline_management': True,
'series_id': 'TMPSFA',
'subseries_name': 'TMPSF Series A Sub 01',
'primary_interface': 1,
'manufacturer': 'RBR Global',
'family_name': 'Seafloor Properties',
'class_description': 'Measures temperatures of diffuse flow across the seafloor',
'class_alternate_name': 'Diffuse Vent Fluid 3-D Temperature Array',
'subseries_id': 'TMPSFA01',
'class_id': 'TMPSF',
'family_id': 'SFL',
'has_clock': True
}
platform_site_attrs = {
'name' : 'Cabled LP JBOX Platform Site',
'description' : 'Test Site for a Cabled LP JBOX Platform'
}
instrument_site_attrs = {
'name' : 'Cabled TMPSF Instrument Site',
'description' : 'Test Site for a Cabled TMPSF Instrument'
}
# Create the cabled model preloaded resources.
platform_model = IonObject('PlatformModel', **platform_model_attrs)
self.cabled_platform_model_id = self.ims.create_platform_model(platform_model)
instrument_model = IonObject('InstrumentModel', **instrument_model_attrs)
self.cabled_instrument_model_id = self.ims.create_instrument_model(
instrument_model)
# Create the cabled sites and link them appropriately.
platform_site = IonObject('', **platform_site_attrs)
self.cabled_platform_site_id = self.oms.create_platform_site(platform_site)
self.oms.assign_site_to_site(self.cabled_platform_site_id, self.obs_id)
instrument_site = IonObject('', **instrument_site_attrs)
self.cabled_instrument_site_id = self.oms.create_instrument_site(instrument_site)
self.oms.assign_site_to_site(self.cabled_instrument_site_id, self.cabled_platform_site_id)
# Assign models to available sites.
self.oms.assign_platform_model_to_platform_site(
self.cabled_platform_model_id, self.cabled_platform_site_id)
self.oms.assign_instrument_model_to_instrument_site(
self.cabled_instrument_model_id, self.cabled_instrument_site_id)
def _create_uncabled_resources(self):
"""
Create preexisting infrastructure for the uncabled test environment:
sites, deployments, models.
"""
pass
def test_cabled_device_activation(self):
"""
Test registration and activation of cabled device infrastructure.
"""
pass
def test_uncabled_device_activation(self):
"""
Test registration and activation of uncabled device infrastructure.
"""
pass
示例5: TestDeployment
# 需要导入模块: from interface.services.sa.iobservatory_management_service import ObservatoryManagementServiceClient [as 别名]
# 或者: from interface.services.sa.iobservatory_management_service.ObservatoryManagementServiceClient import assign_instrument_model_to_instrument_site [as 别名]
#.........这里部分代码省略.........
start = IonTime(datetime.datetime(2013,1,1))
end = IonTime(datetime.datetime(2014,1,1))
temporal_bounds = IonObject(OT.TemporalBounds, name='planned', start_datetime=start.to_string(), end_datetime=end.to_string())
deployment_obj = IonObject(RT.Deployment,
name='TestDeployment',
description='some new deployment',
context=IonObject(OT.CabledNodeDeploymentContext),
constraint_list=[temporal_bounds])
deployment_id = self.omsclient.create_deployment(deployment_obj)
log.debug("test_create_deployment: created deployment id: %s ", str(deployment_id) )
ret = DotDict(instrument_site_id=instrument_site_id,
instrument_device_id=instrument_device_id,
instrument_model_id=instrument_model_id,
platform_site_id=platform_site_id,
platform_device_id=platform_device_id,
platform_model_id=platform_model_id,
deployment_id=deployment_id)
return ret
#@unittest.skip("targeting")
def test_activate_deployment_normal(self):
res = self.base_activate_deployment()
log.debug("assigning platform and instrument models")
self.imsclient.assign_platform_model_to_platform_device(res.platform_model_id, res.platform_device_id)
self.imsclient.assign_instrument_model_to_instrument_device(res.instrument_model_id, res.instrument_device_id)
self.omsclient.assign_platform_model_to_platform_site(res.platform_model_id, res.platform_site_id)
self.omsclient.assign_instrument_model_to_instrument_site(res.instrument_model_id, res.instrument_site_id)
log.debug("adding instrument site and device to deployment")
self.omsclient.deploy_instrument_site(res.instrument_site_id, res.deployment_id)
self.imsclient.deploy_instrument_device(res.instrument_device_id, res.deployment_id)
log.debug("adding platform site and device to deployment")
self.omsclient.deploy_platform_site(res.platform_site_id, res.deployment_id)
self.imsclient.deploy_platform_device(res.platform_device_id, res.deployment_id)
log.debug("activating deployment, expecting success")
self.omsclient.activate_deployment(res.deployment_id)
log.debug("deactivatin deployment, expecting success")
self.omsclient.deactivate_deployment(res.deployment_id)
#@unittest.skip("targeting")
def test_activate_deployment_nomodels(self):
res = self.base_activate_deployment()
self.omsclient.deploy_instrument_site(res.instrument_site_id, res.deployment_id)
self.imsclient.deploy_instrument_device(res.instrument_device_id, res.deployment_id)
log.debug("activating deployment without site+device models, expecting fail")
self.assert_deploy_fail(res.deployment_id, NotFound, "Expected 1")
log.debug("assigning instrument site model")
self.omsclient.assign_instrument_model_to_instrument_site(res.instrument_model_id, res.instrument_site_id)
log.debug("activating deployment without device models, expecting fail")
self.assert_deploy_fail(res.deployment_id, NotFound, "Expected 1")
示例6: TestDeployment
# 需要导入模块: from interface.services.sa.iobservatory_management_service import ObservatoryManagementServiceClient [as 别名]
# 或者: from interface.services.sa.iobservatory_management_service.ObservatoryManagementServiceClient import assign_instrument_model_to_instrument_site [as 别名]
#.........这里部分代码省略.........
#----------------------------------------------------------------------------------------------------
start = IonTime(datetime.datetime(2013,1,1))
end = IonTime(datetime.datetime(2014,1,1))
temporal_bounds = IonObject(OT.TemporalBounds, name='planned', start_datetime=start.to_string(), end_datetime=end.to_string())
deployment_obj = IonObject(RT.Deployment,
name='TestDeployment',
description='some new deployment',
constraint_list=[temporal_bounds])
deployment_id = self.omsclient.create_deployment(deployment_obj)
log.debug("test_create_deployment: created deployment id: %s ", str(deployment_id) )
ret = DotDict(instrument_site_id=instrument_site_id,
instrument_device_id=instrument_device_id,
instrument_model_id=instrument_model_id,
platform_site_id=platform_site_id,
platform_device_id=platform_device_id,
platform_model_id=platform_model_id,
deployment_id=deployment_id)
return ret
#@unittest.skip("targeting")
def test_activate_deployment_normal(self):
res = self.base_activate_deployment()
log.debug("assigning platform and instrument models")
self.imsclient.assign_platform_model_to_platform_device(res.platform_model_id, res.platform_device_id)
self.imsclient.assign_instrument_model_to_instrument_device(res.instrument_model_id, res.instrument_device_id)
self.omsclient.assign_platform_model_to_platform_site(res.platform_model_id, res.platform_site_id)
self.omsclient.assign_instrument_model_to_instrument_site(res.instrument_model_id, res.instrument_site_id)
log.debug("adding instrument site and device to deployment")
self.omsclient.deploy_instrument_site(res.instrument_site_id, res.deployment_id)
self.imsclient.deploy_instrument_device(res.instrument_device_id, res.deployment_id)
log.debug("adding platform site and device to deployment")
self.omsclient.deploy_platform_site(res.platform_site_id, res.deployment_id)
self.imsclient.deploy_platform_device(res.platform_device_id, res.deployment_id)
log.debug("activating deployment, expecting success")
self.omsclient.activate_deployment(res.deployment_id)
#@unittest.skip("targeting")
def test_activate_deployment_nomodels(self):
res = self.base_activate_deployment()
self.omsclient.deploy_instrument_site(res.instrument_site_id, res.deployment_id)
self.imsclient.deploy_instrument_device(res.instrument_device_id, res.deployment_id)
log.debug("activating deployment without site+device models, expecting fail")
self.assert_deploy_fail(res.deployment_id, "Expected at least 1 model for InstrumentSite")
log.debug("assigning instrument site model")
self.omsclient.assign_instrument_model_to_instrument_site(res.instrument_model_id, res.instrument_site_id)
log.debug("activating deployment without device models, expecting fail")
self.assert_deploy_fail(res.deployment_id, "Expected 1 model for InstrumentDevice")
#@unittest.skip("targeting")
def test_activate_deployment_nosite(self):
res = self.base_activate_deployment()
log.debug("assigning instrument models")
self.imsclient.assign_instrument_model_to_instrument_device(res.instrument_model_id, res.instrument_device_id)
self.omsclient.assign_instrument_model_to_instrument_site(res.instrument_model_id, res.instrument_site_id)
log.debug("deploying instrument device only")
self.imsclient.deploy_instrument_device(res.instrument_device_id, res.deployment_id)
log.debug("activating deployment without device models, expecting fail")
self.assert_deploy_fail(res.deployment_id, "No sites were found in the deployment")
#@unittest.skip("targeting")
def test_activate_deployment_nodevice(self):
res = self.base_activate_deployment()
log.debug("assigning platform and instrument models")
self.imsclient.assign_instrument_model_to_instrument_device(res.instrument_model_id, res.instrument_device_id)
self.omsclient.assign_instrument_model_to_instrument_site(res.instrument_model_id, res.instrument_site_id)
log.debug("deploying instrument site only")
self.omsclient.deploy_instrument_site(res.instrument_site_id, res.deployment_id)
log.debug("activating deployment without device models, expecting fail")
self.assert_deploy_fail(res.deployment_id, "The set of devices could not be mapped to the set of sites")
def assert_deploy_fail(self, deployment_id, fail_message="did not specify fail_message"):
with self.assertRaises(BadRequest) as cm:
self.omsclient.activate_deployment(deployment_id)
self.assertIn(fail_message, cm.exception.message)
示例7: TestDeployment
# 需要导入模块: from interface.services.sa.iobservatory_management_service import ObservatoryManagementServiceClient [as 别名]
# 或者: from interface.services.sa.iobservatory_management_service.ObservatoryManagementServiceClient import assign_instrument_model_to_instrument_site [as 别名]
#.........这里部分代码省略.........
self.rrclient.create_association(platform_device_id, PRED.hasDevice, instrument_device_id)
pp_obj = IonObject(OT.PlatformPort, reference_designator='GA01SUMO-FI003-01-CTDMO0999', port_type= PortTypeEnum.PAYLOAD, ip_address='1' )
port_assignments = {instrument_device_id : pp_obj}
#----------------------------------------------------------------------------------------------------
# Create an instrument model
instrument_model_obj = IonObject(RT.InstrumentModel,
name='InstrumentModel1',
description='test instrument model')
instrument_model_id = self.imsclient.create_instrument_model(instrument_model_obj)
# Create a deployment object
#----------------------------------------------------------------------------------------------------
start = str(int(time.mktime(datetime.datetime(2013, 1, 1).timetuple())))
end = str(int(time.mktime(datetime.datetime(2020, 1, 1).timetuple())))
temporal_bounds = IonObject(OT.TemporalBounds, name='planned', start_datetime=start, end_datetime=end)
deployment_obj = IonObject(RT.Deployment,
name='TestDeployment',
description='some new deployment',
context=IonObject(OT.CabledNodeDeploymentContext),
port_assignments=port_assignments,
constraint_list=[temporal_bounds])
deployment_id = self.omsclient.create_deployment(deployment_obj)
log.debug("test_create_deployment: created deployment id: %s ", str(deployment_id) )
if make_assigns:
self.imsclient.assign_platform_model_to_platform_device(platform_model_id, platform_device_id)
self.imsclient.assign_instrument_model_to_instrument_device(instrument_model_id, instrument_device_id)
self.omsclient.assign_platform_model_to_platform_site(platform_model_id, platform_site_id)
self.omsclient.assign_instrument_model_to_instrument_site(instrument_model_id, instrument_site_id)
self.omsclient.assign_site_to_deployment(platform_site_id, deployment_id)
self.omsclient.assign_device_to_deployment(platform_device_id, deployment_id)
ret = DotDict(instrument_site_id=instrument_site_id,
instrument_device_id=instrument_device_id,
instrument_model_id=instrument_model_id,
platform_site_id=platform_site_id,
platform_device_id=platform_device_id,
platform_model_id=platform_model_id,
deployment_id=deployment_id)
return ret
def _create_subsequent_deployment(self, prior_dep_info):
platform_device_obj = IonObject(RT.PlatformDevice,
name='PlatformDevice2',
description='test platform device')
platform_device_id = self.imsclient.create_platform_device(platform_device_obj)
instrument_device_obj = IonObject(RT.InstrumentDevice,
name='InstrumentDevice2',
description='test instrument device')
instrument_device_id = self.imsclient.create_instrument_device(instrument_device_obj)
self.rrclient.create_association(platform_device_id, PRED.hasDevice, instrument_device_id)
self.imsclient.assign_platform_model_to_platform_device(prior_dep_info.platform_model_id, platform_device_id)
self.imsclient.assign_instrument_model_to_instrument_device(prior_dep_info.instrument_model_id, instrument_device_id)
start = str(int(time.mktime(datetime.datetime(2013, 6, 1).timetuple())))
end = str(int(time.mktime(datetime.datetime(2020, 6, 1).timetuple())))
temporal_bounds = IonObject(OT.TemporalBounds, name='planned', start_datetime=start, end_datetime=end)
示例8: TestIMSDeployAsPrimaryDevice
# 需要导入模块: from interface.services.sa.iobservatory_management_service import ObservatoryManagementServiceClient [as 别名]
# 或者: from interface.services.sa.iobservatory_management_service.ObservatoryManagementServiceClient import assign_instrument_model_to_instrument_site [as 别名]
#.........这里部分代码省略.........
instModel_id = self.imsclient.create_instrument_model(instModel_obj)
except BadRequest as ex:
self.fail("failed to create new InstrumentModel: %s" % ex)
print "test_deployAsPrimaryDevice: new InstrumentModel id = ", instModel_id
# -------------------------------
# Create InstrumentAgent
# -------------------------------
instAgent_obj = IonObject(
RT.InstrumentAgent,
name="agent007",
description="SBE37IMAgent",
driver_module="ion.agents.instrument.instrument_agent",
driver_class="InstrumentAgent",
)
try:
instAgent_id = self.imsclient.create_instrument_agent(instAgent_obj)
except BadRequest as ex:
self.fail("failed to create new InstrumentAgent: %s" % ex)
print "test_deployAsPrimaryDevice: new InstrumentAgent id = ", instAgent_id
self.imsclient.assign_instrument_model_to_instrument_agent(instModel_id, instAgent_id)
# -------------------------------
# Create Instrument Site
# -------------------------------
instrumentSite_obj = IonObject(RT.InstrumentSite, name="instrumentSite1", description="SBE37IMInstrumentSite")
try:
instrumentSite_id = self.omsclient.create_instrument_site(instrument_site=instrumentSite_obj, parent_id="")
except BadRequest as ex:
self.fail("failed to create new InstrumentSite: %s" % ex)
print "test_deployAsPrimaryDevice: new instrumentSite id = ", instrumentSite_id
self.omsclient.assign_instrument_model_to_instrument_site(instModel_id, instrumentSite_id)
# -------------------------------
# Create Old InstrumentDevice
# -------------------------------
instDevice_obj = IonObject(
RT.InstrumentDevice,
name="SBE37IMDeviceYear1",
description="SBE37IMDevice for the FIRST year of deployment",
serial_number="12345",
)
try:
oldInstDevice_id = self.imsclient.create_instrument_device(instrument_device=instDevice_obj)
self.imsclient.assign_instrument_model_to_instrument_device(instModel_id, oldInstDevice_id)
except BadRequest as ex:
self.fail("failed to create new InstrumentDevice: %s" % ex)
print "test_deployAsPrimaryDevice: new Year 1 InstrumentDevice id = ", oldInstDevice_id
# deploy this device to the logical slot
self.omsclient.deploy_instrument_device_to_instrument_site(oldInstDevice_id, instrumentSite_id)
self.rrclient.execute_lifecycle_transition(oldInstDevice_id, LCE.DEPLOY)
self.rrclient.execute_lifecycle_transition(oldInstDevice_id, LCE.ENABLE)
# set this device as the current primary device
self.omsclient.deploy_as_primary_instrument_device_to_instrument_site(oldInstDevice_id, instrumentSite_id)
# -------------------------------
# Create InstrumentAgentInstance for OldInstrumentDevice to hold configuration information
# cmd_port=5556, evt_port=5557, comms_method="ethernet", comms_device_address=CFG.device.sbe37.host, comms_device_port=CFG.device.sbe37.port,
# -------------------------------
instAgentInstance_obj = IonObject(
示例9: TestIMSDeployAsPrimaryDevice
# 需要导入模块: from interface.services.sa.iobservatory_management_service import ObservatoryManagementServiceClient [as 别名]
# 或者: from interface.services.sa.iobservatory_management_service.ObservatoryManagementServiceClient import assign_instrument_model_to_instrument_site [as 别名]
#.........这里部分代码省略.........
#-------------------------------
instModel_obj = IonObject(RT.InstrumentModel, name='SBE37IMModel', description="SBE37IMModel", model="SBE37IMModel" )
try:
instModel_id = self.imsclient.create_instrument_model(instModel_obj)
except BadRequest as ex:
self.fail("failed to create new InstrumentModel: %s" %ex)
print 'test_deployAsPrimaryDevice: new InstrumentModel id = ', instModel_id
#-------------------------------
# Create InstrumentAgent
#-------------------------------
instAgent_obj = IonObject(RT.InstrumentAgent, name='agent007', description="SBE37IMAgent", driver_module="ion.agents.instrument.instrument_agent", driver_class="InstrumentAgent" )
try:
instAgent_id = self.imsclient.create_instrument_agent(instAgent_obj)
except BadRequest as ex:
self.fail("failed to create new InstrumentAgent: %s" %ex)
print 'test_deployAsPrimaryDevice: new InstrumentAgent id = ', instAgent_id
self.imsclient.assign_instrument_model_to_instrument_agent(instModel_id, instAgent_id)
#-------------------------------
# Create Instrument Site
#-------------------------------
instrumentSite_obj = IonObject(RT.InstrumentSite, name='instrumentSite1', description="SBE37IMInstrumentSite" )
try:
instrumentSite_id = self.omsclient.create_instrument_site(instrument_site=instrumentSite_obj, parent_id='')
except BadRequest as ex:
self.fail("failed to create new InstrumentSite: %s" %ex)
print 'test_deployAsPrimaryDevice: new instrumentSite id = ', instrumentSite_id
self.omsclient.assign_instrument_model_to_instrument_site(instModel_id, instrumentSite_id)
#-------------------------------
# Logical Transform: Output Data Products
#-------------------------------
# create a stream definition for the data from the ctd simulator
ctd_stream_def = SBE37_CDM_stream_definition()
ctd_stream_def_id = self.pubsubclient.create_stream_definition(container=ctd_stream_def)
log.debug("test_deployAsPrimaryDevice: create output parsed data product for Logical Instrument")
craft = CoverageCraft
sdom, tdom = craft.create_domains()
sdom = sdom.dump()
tdom = tdom.dump()
parameter_dictionary = craft.create_parameters()
parameter_dictionary = parameter_dictionary.dump()
ctd_logical_output_dp_obj = IonObject(RT.DataProduct,
name='ctd_parsed_logical',
description='ctd parsed from the logical instrument',
temporal_domain = tdom,
spatial_domain = sdom)
instrument_site_output_dp_id = self.dataproductclient.create_data_product(ctd_logical_output_dp_obj,
ctd_stream_def_id,
parameter_dictionary)
self.dataproductclient.activate_data_product_persistence(data_product_id=instrument_site_output_dp_id)
self.omsclient.create_site_data_product(instrumentSite_id, instrument_site_output_dp_id)
示例10: TestDeployment
# 需要导入模块: from interface.services.sa.iobservatory_management_service import ObservatoryManagementServiceClient [as 别名]
# 或者: from interface.services.sa.iobservatory_management_service.ObservatoryManagementServiceClient import assign_instrument_model_to_instrument_site [as 别名]
#.........这里部分代码省略.........
device_id = self.imsclient.create_platform_device(platform_device__obj)
deployment_obj = IonObject(RT.Deployment, name="TestDeployment", description="some new deployment")
deployment_id = self.omsclient.create_deployment(deployment_obj)
self.omsclient.deploy_platform_site(site_id, deployment_id)
self.imsclient.deploy_platform_device(device_id, deployment_id)
log.debug("test_create_deployment: created deployment id: %s ", str(deployment_id))
# retrieve the deployment objects and check that the assoc site and device are attached
read_deployment_obj = self.omsclient.read_deployment(deployment_id)
log.debug("test_create_deployment: created deployment obj: %s ", str(read_deployment_obj))
site_ids, _ = self.rrclient.find_subjects(RT.PlatformSite, PRED.hasDeployment, deployment_id, True)
self.assertEqual(len(site_ids), 1)
device_ids, _ = self.rrclient.find_subjects(RT.PlatformDevice, PRED.hasDeployment, deployment_id, True)
self.assertEqual(len(device_ids), 1)
# delete the deployment
self.omsclient.delete_deployment(deployment_id)
# now try to get the deleted dp object
try:
deployment_obj = self.omsclient.read_deployment(deployment_id)
except NotFound as ex:
pass
else:
self.fail("deleted deployment was found during read")
# @unittest.skip("targeting")
def test_activate_deployment(self):
# create a deployment with metadata and an initial site and device
platform_site__obj = IonObject(RT.PlatformSite, name="PlatformSite1", description="test platform site")
site_id = self.omsclient.create_platform_site(platform_site__obj)
platform_device_obj = IonObject(RT.PlatformDevice, name="PlatformDevice1", description="test platform device")
platform_device_id = self.imsclient.create_platform_device(platform_device_obj)
platform_model__obj = IonObject(RT.PlatformModel, name="PlatformModel1", description="test platform model")
model_id = self.imsclient.create_platform_model(platform_model__obj)
self.imsclient.assign_platform_model_to_platform_device(model_id, platform_device_id)
self.omsclient.assign_platform_model_to_platform_site(model_id, site_id)
# create a deployment with metadata and an initial site and device
instrument_site_obj = IonObject(RT.InstrumentSite, name="InstrumentSite1", description="test instrument site")
instrument_site_id = self.omsclient.create_instrument_site(instrument_site_obj, site_id)
# assign data products appropriately
# set up stream (this would be preload)
ctd_stream_def = SBE37_CDM_stream_definition()
ctd_stream_def_id = self.psmsclient.create_stream_definition(container=ctd_stream_def)
craft = CoverageCraft
sdom, tdom = craft.create_domains()
sdom = sdom.dump()
tdom = tdom.dump()
parameter_dictionary = craft.create_parameters()
parameter_dictionary = parameter_dictionary.dump()
dp_obj = IonObject(
RT.DataProduct, name="DP1", description="some new dp", temporal_domain=tdom, spatial_domain=sdom
)
log_data_product_id = self.dmpsclient.create_data_product(dp_obj, ctd_stream_def_id, parameter_dictionary)
self.omsclient.create_site_data_product(instrument_site_id, log_data_product_id)
instrument_device_obj = IonObject(
RT.InstrumentDevice, name="InstrumentDevice1", description="test instrument device"
)
instrument_device_id = self.imsclient.create_instrument_device(instrument_device_obj)
self.rrclient.create_association(platform_device_id, PRED.hasDevice, instrument_device_id)
dp_obj = IonObject(
RT.DataProduct, name="DP1", description="some new dp", temporal_domain=tdom, spatial_domain=sdom
)
inst_data_product_id = self.dmpsclient.create_data_product(dp_obj, ctd_stream_def_id, parameter_dictionary)
# assign data products appropriately
self.damsclient.assign_data_product(
input_resource_id=instrument_device_id, data_product_id=inst_data_product_id
)
instrument_model_obj = IonObject(
RT.InstrumentModel, name="InstrumentModel1", description="test instrument model"
)
instrument_model_id = self.imsclient.create_instrument_model(instrument_model_obj)
self.imsclient.assign_instrument_model_to_instrument_device(instrument_model_id, instrument_device_id)
self.omsclient.assign_instrument_model_to_instrument_site(instrument_model_id, instrument_site_id)
# self.rrclient.create_association(instrument_site_id, PRED.hasModel, instrument_model_id)
deployment_obj = IonObject(RT.Deployment, name="TestDeployment", description="some new deployment")
deployment_id = self.omsclient.create_deployment(deployment_obj)
self.omsclient.deploy_instrument_site(instrument_site_id, deployment_id)
self.imsclient.deploy_instrument_device(instrument_device_id, deployment_id)
log.debug("test_create_deployment: created deployment id: %s ", str(deployment_id))
self.omsclient.activate_deployment(deployment_id)
示例11: TestDeployment
# 需要导入模块: from interface.services.sa.iobservatory_management_service import ObservatoryManagementServiceClient [as 别名]
# 或者: from interface.services.sa.iobservatory_management_service.ObservatoryManagementServiceClient import assign_instrument_model_to_instrument_site [as 别名]
class TestDeployment(IonIntegrationTestCase):
def setUp(self):
# Start container
self._start_container()
self.container.start_rel_from_url('res/deploy/r2deploy.yml')
self.rrclient = ResourceRegistryServiceClient(node=self.container.node)
self.omsclient = ObservatoryManagementServiceClient(node=self.container.node)
self.imsclient = InstrumentManagementServiceClient(node=self.container.node)
#@unittest.skip("targeting")
def test_create_deployment(self):
#create a deployment with metadata and an initial site and device
platform_site__obj = IonObject(RT.PlatformSite,
name='PlatformSite1',
description='test platform site')
site_id = self.omsclient.create_platform_site(platform_site__obj)
platform_device__obj = IonObject(RT.PlatformDevice,
name='PlatformDevice1',
description='test platform device')
device_id = self.imsclient.create_platform_device(platform_device__obj)
deployment_obj = IonObject(RT.Deployment,
name='TestDeployment',
description='some new deployment')
deployment_id = self.omsclient.create_deployment(deployment_obj, site_id, device_id)
log.debug("test_create_deployment: created deployment id: %s ", str(deployment_id) )
#retrieve the deployment objects and check that the assoc site and device are attached
read_deployment_obj = self.omsclient.read_deployment(deployment_id)
log.debug("test_create_deployment: created deployment obj: %s ", str(read_deployment_obj) )
site_ids, _ = self.rrclient.find_subjects(RT.PlatformSite, PRED.hasDeployment, deployment_id, True)
self.assertEqual(len(site_ids), 1)
device_ids, _ = self.rrclient.find_subjects(RT.PlatformDevice, PRED.hasDeployment, deployment_id, True)
self.assertEqual(len(device_ids), 1)
#delete the deployment
self.omsclient.delete_deployment(deployment_id)
# now try to get the deleted dp object
try:
deployment_obj = self.omsclient.read_deployment(deployment_id)
except NotFound as ex:
pass
else:
self.fail("deleted deployment was found during read")
#@unittest.skip("targeting")
def test_activate_deployment(self):
#create a deployment with metadata and an initial site and device
platform_site__obj = IonObject(RT.PlatformSite,
name='PlatformSite1',
description='test platform site')
site_id = self.omsclient.create_platform_site(platform_site__obj)
platform_device__obj = IonObject(RT.PlatformDevice,
name='PlatformDevice1',
description='test platform device')
device_id = self.imsclient.create_platform_device(platform_device__obj)
platform_model__obj = IonObject(RT.PlatformModel,
name='PlatformModel1',
description='test platform model')
model_id = self.imsclient.create_platform_model(platform_model__obj)
self.imsclient.assign_platform_model_to_platform_device(model_id, device_id)
self.omsclient.assign_platform_model_to_platform_site(model_id, site_id)
#create a deployment with metadata and an initial site and device
instrument_site__obj = IonObject(RT.InstrumentSite,
name='InstrumentSite1',
description='test instrument site')
instrument_site_id = self.omsclient.create_instrument_site(instrument_site__obj, site_id)
instrument_device__obj = IonObject(RT.InstrumentDevice,
name='InstrumentDevice1',
description='test instrument device')
instrument_device_id = self.imsclient.create_instrument_device(instrument_device__obj)
self.rrclient.create_association(device_id, PRED.hasDevice, instrument_device_id)
instrument_model__obj = IonObject(RT.InstrumentModel,
name='InstrumentModel1',
description='test instrument model')
instrument_model_id = self.imsclient.create_instrument_model(instrument_model__obj)
self.imsclient.assign_instrument_model_to_instrument_device(instrument_model_id, instrument_device_id)
self.omsclient.assign_instrument_model_to_instrument_site(instrument_model_id, instrument_site_id)
#self.rrclient.create_association(instrument_site_id, PRED.hasModel, instrument_model_id)
deployment_obj = IonObject(RT.Deployment,
#.........这里部分代码省略.........
示例12: TestDataProductProvenance
# 需要导入模块: from interface.services.sa.iobservatory_management_service import ObservatoryManagementServiceClient [as 别名]
# 或者: from interface.services.sa.iobservatory_management_service.ObservatoryManagementServiceClient import assign_instrument_model_to_instrument_site [as 别名]
class TestDataProductProvenance(IonIntegrationTestCase):
def setUp(self):
# Start container
#print 'instantiating container'
self._start_container()
self.container.start_rel_from_url('res/deploy/r2deploy.yml')
# Now create client to DataProductManagementService
self.rrclient = ResourceRegistryServiceClient(node=self.container.node)
self.damsclient = DataAcquisitionManagementServiceClient(node=self.container.node)
self.pubsubclient = PubsubManagementServiceClient(node=self.container.node)
self.ingestclient = IngestionManagementServiceClient(node=self.container.node)
self.dpmsclient = DataProductManagementServiceClient(node=self.container.node)
self.dataprocessclient = DataProcessManagementServiceClient(node=self.container.node)
self.imsclient = InstrumentManagementServiceClient(node=self.container.node)
self.omsclient = ObservatoryManagementServiceClient(node=self.container.node)
self.process_dispatcher = ProcessDispatcherServiceClient()
self.dataset_management = DatasetManagementServiceClient()
#@unittest.skip('not ready')
def test_get_provenance(self):
#create a deployment with metadata and an initial site and device
instrument_site_obj = IonObject(RT.InstrumentSite,
name='InstrumentSite1',
description='test instrument site')
instrument_site_id = self.omsclient.create_instrument_site(instrument_site_obj, "")
log.debug( 'test_get_provenance: new instrument_site_id id = %s ', str(instrument_site_id))
# Create InstrumentModel
instModel_obj = IonObject(RT.InstrumentModel,
name='SBE37IMModel',
description="SBE37IMModel",
stream_configuration= {'parsed': 'ctd_parsed_param_dict' } )
try:
instModel_id = self.imsclient.create_instrument_model(instModel_obj)
except BadRequest as ex:
self.fail("failed to create new InstrumentModel: %s" %ex)
log.debug( 'test_get_provenance: new InstrumentModel id = %s ', str(instModel_id))
self.omsclient.assign_instrument_model_to_instrument_site(instModel_id, instrument_site_id)
# Create InstrumentAgent
instAgent_obj = IonObject(RT.InstrumentAgent, name='agent007', description="SBE37IMAgent", driver_module="mi.instrument.seabird.sbe37smb.ooicore.driver", driver_class="SBE37Driver" )
try:
instAgent_id = self.imsclient.create_instrument_agent(instAgent_obj)
except BadRequest as ex:
self.fail("failed to create new InstrumentAgent: %s" %ex)
log.debug( 'test_get_provenance:new InstrumentAgent id = %s', instAgent_id)
self.imsclient.assign_instrument_model_to_instrument_agent(instModel_id, instAgent_id)
# Create InstrumentDevice
log.debug('test_get_provenance: Create instrument resource to represent the SBE37 (SA Req: L4-CI-SA-RQ-241) ')
instDevice_obj = IonObject(RT.InstrumentDevice, name='SBE37IMDevice', description="SBE37IMDevice", serial_number="12345" )
try:
instDevice_id = self.imsclient.create_instrument_device(instrument_device=instDevice_obj)
self.imsclient.assign_instrument_model_to_instrument_device(instModel_id, instDevice_id)
except BadRequest as ex:
self.fail("failed to create new InstrumentDevice: %s" %ex)
log.debug("test_get_provenance: new InstrumentDevice id = %s (SA Req: L4-CI-SA-RQ-241) ", instDevice_id)
#-------------------------------
# Create CTD Parsed data product
#-------------------------------
tdom, sdom = time_series_domain()
sdom = sdom.dump()
tdom = tdom.dump()
pdict_id = self.dataset_management.read_parameter_dictionary_by_name('ctd_parsed_param_dict', id_only=True)
parsed_stream_def_id = self.pubsubclient.create_stream_definition(name='parsed', parameter_dictionary_id=pdict_id)
log.debug( 'test_get_provenance:Creating new CDM data product with a stream definition')
dp_obj = IonObject(RT.DataProduct,
name='the parsed data',
description='ctd stream test',
temporal_domain = tdom,
spatial_domain = sdom)
ctd_parsed_data_product = self.dpmsclient.create_data_product(data_product=dp_obj, stream_definition_id=parsed_stream_def_id)
log.debug( 'new dp_id = %s', ctd_parsed_data_product)
self.damsclient.assign_data_product(input_resource_id=instDevice_id, data_product_id=ctd_parsed_data_product)
self.dpmsclient.activate_data_product_persistence(data_product_id=ctd_parsed_data_product)
#-------------------------------
# create a data product for the site to pass the OMS check.... we need to remove this check
#-------------------------------
dp_obj = IonObject(RT.DataProduct,
#.........这里部分代码省略.........