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


Python ObservatoryManagementServiceClient.get_deployment_extension方法代码示例

本文整理汇总了Python中interface.services.sa.iobservatory_management_service.ObservatoryManagementServiceClient.get_deployment_extension方法的典型用法代码示例。如果您正苦于以下问题:Python ObservatoryManagementServiceClient.get_deployment_extension方法的具体用法?Python ObservatoryManagementServiceClient.get_deployment_extension怎么用?Python ObservatoryManagementServiceClient.get_deployment_extension使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在interface.services.sa.iobservatory_management_service.ObservatoryManagementServiceClient的用法示例。


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

示例1: TestDeployment

# 需要导入模块: from interface.services.sa.iobservatory_management_service import ObservatoryManagementServiceClient [as 别名]
# 或者: from interface.services.sa.iobservatory_management_service.ObservatoryManagementServiceClient import get_deployment_extension [as 别名]

#.........这里部分代码省略.........
        for p in range(3):
            m = platform_model_at(p)
            self.RR2.assign_platform_model_to_platform_site_with_has_model(platform_model_id[m], platform_site_id[p])
            self.RR2.assign_platform_model_to_platform_device_with_has_model(platform_model_id[m], platform_device_id[p])
            self.RR2.assign_platform_device_to_platform_device_with_has_device(platform_device_id[p], platform_device_id[3])
            self.RR2.assign_platform_site_to_platform_site_with_has_site(platform_site_id[p], platform_site_id[3])

            for i in range(3):
                m = instrument_model_at(p, i)
                idx = instrument_at(p, i)
                self.RR2.assign_instrument_model_to_instrument_site_with_has_model(instrument_model_id[m], instrument_site_id[idx])
                self.RR2.assign_instrument_model_to_instrument_device_with_has_model(instrument_model_id[m], instrument_device_id[idx])
                self.RR2.assign_instrument_device_to_platform_device_with_has_device(instrument_device_id[idx], platform_device_id[p])
                self.RR2.assign_instrument_site_to_platform_site_with_has_site(instrument_site_id[idx], platform_site_id[p])

        # top level models
        self.RR2.assign_platform_model_to_platform_device_with_has_model(platform_model_id[2], platform_device_id[3])
        self.RR2.assign_platform_model_to_platform_site_with_has_model(platform_model_id[2], platform_site_id[3])



        # verify structure
        for p in range(3):
            parent_id = self.RR2.find_platform_device_id_by_platform_device_using_has_device(platform_device_id[p])
            self.assertEqual(platform_device_id[3], parent_id)

            parent_id = self.RR2.find_platform_site_id_by_platform_site_using_has_site(platform_site_id[p])
            self.assertEqual(platform_site_id[3], parent_id)

        for i in range(len(platform_site_id)):
            self.assertEqual(self.RR2.find_platform_model_of_platform_device_using_has_model(platform_device_id[i]),
                             self.RR2.find_platform_model_of_platform_site_using_has_model(platform_site_id[i]))

        for i in range(len(instrument_site_id)):
            self.assertEqual(self.RR2.find_instrument_model_of_instrument_device_using_has_model(instrument_device_id[i]),
                             self.RR2.find_instrument_model_of_instrument_site_using_has_model(instrument_site_id[i]))


        port_assignments = {}
        for p in range(3):
            port_assignments[platform_device_id[p]] = "platport_%d" % (p+1)
            for i in range(3):
                idx = instrument_at(p, i)
                port_assignments[instrument_device_id[idx]] = "instport_%d" % (idx+1)

        deployment_id = self.RR2.create(any_old(RT.Deployment,
                {"context": deployment_context,
                 "port_assignments": port_assignments}))


        # set up the deployment
        # top level stuff always goes into the deployment
        self.RR2.assign_deployment_to_platform_device_with_has_deployment(deployment_id, platform_device_id[3])
        self.RR2.assign_deployment_to_platform_site_with_has_deployment(deployment_id, platform_site_id[3])

        if OT.CabledInstrumentDeploymentContext == deployment_context_type:
            self.omsclient.activate_deployment(deployment_id)
            self.omsclient.deactivate_deployment(deployment_id)

        if OT.RemotePlatformDeploymentContext != deployment_context_type:
            for p in range(3):
                m = platform_model_at(p)
                self.RR2.assign_deployment_to_platform_device_with_has_deployment(deployment_id, platform_device_id[p])
                self.RR2.assign_deployment_to_platform_site_with_has_deployment(deployment_id, platform_site_id[p])

                for i in range(3):
                    m = instrument_model_at(p, i)
                    idx = instrument_at(p, i)
                    self.RR2.assign_deployment_to_instrument_device_with_has_deployment(deployment_id, instrument_device_id[idx])
                    self.RR2.assign_deployment_to_instrument_site_with_has_deployment(deployment_id, instrument_site_id[idx])

        #verify the deployment
        if OT.RemotePlatformDeploymentContext != deployment_context_type:
            for p in platform_device_id:
                self.assertEqual(deployment_id, self.RR2.find_deployment_id_of_platform_device_using_has_deployment(p))
            for p in platform_site_id:
                self.assertEqual(deployment_id, self.RR2.find_deployment_id_of_platform_site_using_has_deployment(p))
            for i in instrument_device_id:
                self.assertEqual(deployment_id, self.RR2.find_deployment_id_of_instrument_device_using_has_deployment(i))
            for i in instrument_site_id:
                self.assertEqual(deployment_id, self.RR2.find_deployment_id_of_instrument_site_using_has_deployment(i))

        if OT.CabledInstrumentDeploymentContext == deployment_context_type:
            self.assertRaises(BadRequest, self.omsclient.activate_deployment, deployment_id)
        else:
            self.omsclient.activate_deployment(deployment_id)

            # verify proper associations
            for i, d in enumerate(platform_device_id):
                self.assertEqual(d, self.RR2.find_platform_device_id_of_platform_site_using_has_device(platform_site_id[i]))

            for i, d in enumerate(instrument_device_id):
                self.assertEqual(d, self.RR2.find_instrument_device_id_of_instrument_site_using_has_device(instrument_site_id[i]))

        extended_deployment = self.omsclient.get_deployment_extension(deployment_id)
        log.debug('base_3x3_matchups extended_deployment:  %s', extended_deployment)
        self.assertTrue(len(extended_deployment.platform_sites) == len(extended_deployment.platform_devices))
        self.assertTrue(len(extended_deployment.instrument_sites) == len(extended_deployment.instrument_devices))
        self.assertTrue(len(extended_deployment.instrument_devices) == len(extended_deployment.instrument_models))
        self.assertTrue(len(extended_deployment.platform_devices) == len(extended_deployment.platform_models))
开发者ID:jamie-cyber1,项目名称:coi-services,代码行数:104,代码来源:test_deployment.py

示例2: TestDeployment

# 需要导入模块: from interface.services.sa.iobservatory_management_service import ObservatoryManagementServiceClient [as 别名]
# 或者: from interface.services.sa.iobservatory_management_service.ObservatoryManagementServiceClient import get_deployment_extension [as 别名]

#.........这里部分代码省略.........
        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)
        deployment_obj = IonObject(RT.Deployment,
                                   name='TestDeployment2',
                                   description='some new deployment',
                                   context=IonObject(OT.CabledNodeDeploymentContext),
                                   constraint_list=[temporal_bounds])
        deployment_id = self.omsclient.create_deployment(deployment_obj)

        self.omsclient.assign_site_to_deployment(prior_dep_info.platform_site_id, deployment_id)
        self.omsclient.assign_device_to_deployment(prior_dep_info.platform_device_id, deployment_id)

        log.debug("test_create_deployment: created deployment id: %s ", str(deployment_id) )

        ret = DotDict(instrument_device_id=instrument_device_id,
                      platform_device_id=platform_device_id,
                      deployment_id=deployment_id)

        return ret

    #@unittest.skip("targeting")
    def test_activate_deployment_normal(self):

        res = self.base_activate_deployment(make_assigns=True)

        before_activate_instrument_device_obj = self.rrclient.read(res.instrument_device_id)
        self.assertNotEquals(before_activate_instrument_device_obj.lcstate, LCS.DEPLOYED)

        log.debug("activating deployment, expecting success")
        self.omsclient.activate_deployment(res.deployment_id)

        # OOIION-1239: retrieve the extended resource and validate that only two sites are in the list of portals
        extended_deployment = self.omsclient.get_deployment_extension(res.deployment_id)
        self.assertEquals( len(extended_deployment.computed.portals.value), 2)

        def assertGeospatialBoundsEquals(a, b):
            self.assertEquals(a['geospatial_latitude_limit_north'],b['geospatial_latitude_limit_north'])
            self.assertEquals(a['geospatial_latitude_limit_south'],b['geospatial_latitude_limit_south'])
            self.assertEquals(a['geospatial_longitude_limit_west'],b['geospatial_longitude_limit_west'])
            self.assertEquals(a['geospatial_longitude_limit_east'],b['geospatial_longitude_limit_east'])

        def assertGeospatialBoundsNotEquals(a, b):
            self.assertNotEquals(a['geospatial_latitude_limit_north'],b['geospatial_latitude_limit_north'])
            self.assertNotEquals(a['geospatial_latitude_limit_south'],b['geospatial_latitude_limit_south'])
            self.assertNotEquals(a['geospatial_longitude_limit_west'],b['geospatial_longitude_limit_west'])
            self.assertNotEquals(a['geospatial_longitude_limit_east'],b['geospatial_longitude_limit_east'])

        after_activate_instrument_device_obj = self.rrclient.read(res.instrument_device_id)
        assertGeospatialBoundsNotEquals(before_activate_instrument_device_obj.geospatial_bounds,after_activate_instrument_device_obj.geospatial_bounds)

        deployment_obj = self.RR2.read(res.deployment_id)
        self.assertEquals(deployment_obj.lcstate, LCS.DEPLOYED)

        extended_deployment = self.omsclient.get_deployment_extension(res.deployment_id)
        # two sites in this test
        self.assertEquals(len(extended_deployment.computed.portals.value), 2)
        # only one portal instrument
        self.assertEquals(len(extended_deployment.portal_instruments), 1)

        log.debug("deactivatin deployment, expecting success")
        self.omsclient.deactivate_deployment(res.deployment_id)

        after_deactivate_instrument_device_obj = self.rrclient.read(res.instrument_device_id)
        assertGeospatialBoundsNotEquals(after_activate_instrument_device_obj.geospatial_bounds, after_deactivate_instrument_device_obj.geospatial_bounds)
开发者ID:ednad,项目名称:coi-services,代码行数:69,代码来源:test_deployment.py


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