def get_components(self): """ Get the list of component_info objects Returns: A list of ComponentInfo proto-GI objects (rw-base.yang) """ vcs_info = RwBaseYang.VcsInfo() response_xml = self.mgmt_proxy.get_from_xpath('/vcs/info') response_xml = response_xml[response_xml.index('<data'):] self.model.load_schema_ypbc(RwBaseYang.get_schema()) try: vcs_info.from_xml_v2(self.model, response_xml) except Exception as e: raise ComponentInfoError( "Could not convert tasklet info XML response: {}".format( str(e))) components = vcs_info.components.component_info if not components: raise ComponentInfoError( "No components returned from VcsInfo request.") return components
def start(self): self.log.setLevel(logging.DEBUG) super(ExampleTasklet, self).start() self._dts = rift.tasklets.DTS( self.tasklet_info, rwbase.get_schema(), self.loop, self.on_dts_state_change)
def get_vcs_resource(self): """Get the vcs resource container object Returns: A proto-GI object (rw-base.yang) """ vcs_resource = RwBaseYang.VcsResource() response_xml = self.mgmt_proxy.get_from_xpath('/vcs') vcs_resource.from_xml(yang_model.yang_model, response_xml) return vcs_resource
def create_component(instance_name, component_type, parent_name=None, children_names=None): component = RwBaseYang.ComponentInfo() component.instance_name = instance_name component.component_type = component_type if parent_name is not None: component.rwcomponent_parent = parent_name if children_names is not None: component.rwcomponent_children = children_names return component
def print(self, xml): info = rwbase.VcsInstance() try: info.from_xml_v2(self._model, xml) except glib.Error: return for instance in info.instance: print(instance.instance_name, "Admin-Stop:", instance.admin_stop) for child in instance.child_n: print(" child: instance-name: %s component-type: %s admin-command: %s state: %s config-ready:%d" %(child.instance_name, child.component_type, child.admin_command, child.publish_state.state, child.publish_state.config_ready)) print()
def __new__(cls, *args, **kwds): if cls._rwbase_model is None: cls._rwbase_model = rwyang.Model.create_libncx() cls._rwbase_model.load_schema_ypbc(rwbase.get_schema()) if cls._rwdebug_model is None: cls._rwdebug_model = rwyang.Model.create_libncx() cls._rwdebug_model.load_schema_ypbc(rwdebug.get_schema()) if cls._rwmsg_model is None: cls._rwmsg_model = rwyang.Model.create_libncx() cls._rwmsg_model.load_schema_ypbc(rwmsg.get_schema()) if cls._rwmemlog_model is None: cls._rwmemlog_model = rwyang.Model.create_libncx() cls._rwmemlog_model.load_schema_ypbc(rwmemlog.get_schema()) return super(PrettyPrinter, cls).__new__(cls, *args, **kwds)
def __init__(self, log, loop, launchpad, vm_pool_mgr, network_pool_mgr): self._log = log self._loop = loop self._launchpad = launchpad self._vm_pool_mgr = vm_pool_mgr self._network_pool_mgr = network_pool_mgr self._manager = None self._model = RwYang.Model.create_libncx() self._model.load_schema_ypbc(RwCloudYang.get_schema()) self._model.load_schema_ypbc(RwBaseYang.get_schema()) self._model.load_schema_ypbc(RwResourceMgrYang.get_schema()) self._model.load_schema_ypbc(RwNsmYang.get_schema()) self._model.load_schema_ypbc(RwConmanYang.get_schema()) self._model.load_schema_ypbc(RwLaunchpadYang.get_schema()) self._cloud_account = None
def print(self, xml): info = rwbase.VcsInfo() info.from_xml_v2(self._model, xml) root = None components = {} for component in info.components.component_info: if component.rwcomponent_parent is None: root = component components[component.instance_name] = component if root is None: raise ValueError('No root component found in the tasklet info tree') # Workaround RIFT-6621 - Keep track of the components we've already printed. printed = [] self.print_components(root, printed, components)
def get_components(self): """ Get the list of component_info objects Returns: A list of ComponentInfo proto-GI objects (rw-base.yang) """ vcs_info = RwBaseYang.VcsInfo() response_xml = self.mgmt_proxy.get_from_xpath('/vcs/info') response_xml = response_xml[response_xml.index('<data'):] self.model.load_schema_ypbc(RwBaseYang.get_schema()) try: vcs_info.from_xml_v2(self.model, response_xml) except Exception as e: raise ComponentInfoError("Could not convert tasklet info XML response: {}".format(str(e))) components = vcs_info.components.component_info if not components: raise ComponentInfoError("No components returned from VcsInfo request.") return components