コード例 #1
0
    def start(
        self,
        xact,
        component_name,
        parent_instance,
        started_cb,
        started_ctx,
    ):
        """ Creates a query to start a already published component

        Arguments:
            xact - An existing transaction to add the block/query under
            component_name - The published component name to start
            parent_instance - The parent instance name to start the component
            started_cb - A callback which takes a single string parameter
                         representing the component instance_name.
            started_ctx - Context which is passed into the started_cb
        """

        #RIFT-6474: Create a seperate transaction until subtransactions are working
        xact = self._dts_api_h.xact_create(0, None, None)

        vstart = RwVcsYang.VStartInput()
        vstart.component_name = component_name
        vstart.parent_instance = parent_instance

        block = xact.block_create()
        status = block.add_query(
            "/rw-vcs:vstart",  #Query Xpath
            RwDts.QueryAction.RPC,  #Query Action
            0,  #Query Flags
            0,  #Query Correlation ID
            vstart.to_pbcm(),
        )
        if status != RwTypes.RwStatus.SUCCESS:
            raise ComponentInfoDBXactFailed(
                "Failed to add a query to the block")

        status = block.execute_immediate(
            0,  #Block flags
            self._on_instance_started,  #Block callback
            ComponentStartContext(
                component_name,
                parent_instance,
                block,
                started_cb,
                started_ctx,
            ),
        )
        if status != RwTypes.RwStatus.SUCCESS:
            raise ComponentInfoDBXactFailed("Failed to execute the block")

        self._log.debug(
            "Started block on xact(%s) to create a ComponentInfoDB object: %s",
            xact, block)

        #RIFT-6474: Commit seperate transaction until subtransactions are working
        xact.commit()
コード例 #2
0
 def vstop_tasklet(tasklet):
     vstop_input = rwvcs.VStopInput(instance_name=tasklet.instance_name)
     query_iter = yield from self._dts.query_rpc(xpath="/rw-vcs:vstop",
                                                 flags=0,
                                                 msg=vstop_input)
     # VStop "should" only return one response, but we have an iterator.
     # So... lets iterate over the responses.
     for fut_resp in query_iter:
         query_resp = yield from fut_resp
         result = query_resp.result
         self.log.info("vstop returned status %d", result.rw_status)
コード例 #3
0
 def configure_schema(cls):
     schema =  RwYang.Model.load_and_merge_schema(rwvcs.get_schema(), 'librwcal_yang_gen.so', 'Rwcal')
     cls.model = RwYang.Model.create_libncx()
     cls.model.load_schema_ypbc(schema)
     xml = cls.manifest.to_xml_v2(cls.model, 1)
     xml = re.sub('rw-manifest:', '', xml)
     xml = re.sub('<manifest xmlns:rw-manifest="http://riftio.com/ns/riftware-1.0/rw-manifest">', '<?xml version="1.0" ?>\n<manifest xmlns="http://riftio.com/ns/riftware-1.0/rw-manifest" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://riftio.com/ns/riftware-1.0/rw-manifest ./rw-manifest.xsd">', xml)
     xml = '\n'.join(xml.split('\n')[1:]) 
     with open('lptestmanifest.xml', 'w') as f:
        f.write(str(xml))
     f.close()
     return schema
コード例 #4
0
    def stop(self, instance_name):
        """Stop a vcs component

        Arguments:
            instance_name   - Instance name of a started vcs component

        Returns:
            A proto-GI object (rw-vcs.yang)
        """

        vstop_input = RwVcsYang.VStopInput()
        vstop_input.instance_name = instance_name

        response_xml = self.mgmt_proxy.rpc(
            vstop_input.to_xml(yang_model.yang_model))
        response_xml = self.mgmt_proxy.get_GI_compatible_xml(response_xml,
                                                             rpc_name='vstop')

        vstop_output = RwVcsYang.VStopOutput()
        vstop_output.from_xml(yang_model.yang_model, response_xml)

        return vstop_output
コード例 #5
0
    def start(self, component_name, parent_instance):
        """Start a vcs component

        Arguments:
            component_name  - Name of a configured vcs component
            parent_instance - Start component under this instance

        Returns:
            A proto-GI object (rw-vcs.yang)
        """

        vstart_input = RwVcsYang.VStartInput()
        vstart_input.component_name = component_name
        vstart_input.parent_instance = parent_instance

        response_xml = self.mgmt_proxy.rpc(
            vstart_input.to_xml(yang_model.yang_model))
        response_xml = self.mgmt_proxy.get_GI_compatible_xml(response_xml,
                                                             rpc_name='vstart')

        vstart_output = RwVcsYang.VStartOutput()
        vstart_output.from_xml(yang_model.yang_model, response_xml)

        return vstart_output
コード例 #6
0
        def start_component(component_name, parent_instance):
            """VStart a component instance using dts

            Arguments:
                component_name  - name of component to start
                parent_instance - parent of component being spawned

            Returns:
                instance_name of started component
            """
            vstart_input = rwvcs.VStartInput(component_name=component_name,
                                             parent_instance=parent_instance)
            iter_resp = yield from self._dts.query_rpc(xpath="/rw-vcs:vstart",
                                                       flags=0,
                                                       msg=vstart_input)

            # VStart "should" only return one response, but we have an iterator.
            # So... lets iterate over the responses.
            instance = None
            for fut_resp in iter_resp:
                resp = yield from fut_resp
                instance = resp.result.instance_name

            return instance