Пример #1
0
    def deserialize(self, xml_output):
        cluster = ('configDump/cluster'.split(r'/'), self.parse)
        control_dir = ('configDump/cluster/PlexControlDirector'.split(r'/'), self._create_control_director)
        port = ('configDump/ports/port'.split(r'/'), self._create_port)
        disk = ('configDump/disks/disk'.split(r'/'), self._create_disk)
        device = ('configDump/top-level-devices/device'.split(r'/'), self._create_top_level_device)
        extent = ('configDump/extents/extent'.split(r'/'), self._create_extent)
        virtual_volume = ('configDump/virtual-volumes/volume'.split(r'/'), self._create_virtual_volume)
        initiator = ('configDump/initiators/initiator'.split(r'/'), self._create_initiator)
        storage_view = ('configDump/views/view'.split(r'/'), self._create_storage_view)
        meta_volume = ('configDump/system-volumes/meta-volumes/meta-volume'.split(r'/'), self._create_meta_volume)
        logging_volume = ('configDump.system-volumes/logging-volumes/logging-volume'.split(r'/'), self._create_logging_volume)

        self.current_director, self.current_port, self.current_disk = None, None, None
        self.current_device, self.current_extent, self.current_volume = None, None, None
        self.current_initiator, self.current_view, self.current_meta_volume = None, None, None
        self.current_logging_volume = None

        start_funcs = (cluster, control_dir, port, disk, device, extent, virtual_volume, 
                       initiator, storage_view, meta_volume, logging_volume)
        end_funcs = (disk, device) 
        z_xml_iterparser.iterparse(xml_output, {'start': start_funcs,
                                                'end': end_funcs})
        
        self._append_last_object()
Пример #2
0
    def _get_objects(self, symcli_cmd, interested_path, StorageObject, object_container, output_file):
        output = subprocess.Popen(symcli_cmd, 
                                  stdout=subprocess.PIPE,
                                  stderr=subprocess.PIPE).communicate()
        if output[1].strip():
            logging.error('Failed to execute %s for (%s) platform (%s) with error - (%s)' %(symcli_cmd, self.sid, self.platform(), output[1]))
            return -1
        
        output_file.write('%s:\n%s\n' %(symcli_cmd, output[0]))
        self.current_object = None 
        interested_path = interested_path.split('/')
        def _create_object(evt, elem, current_path):
            if evt == 'start' and len(current_path) == len(interested_path) and current_path == interested_path:
                self.current_object = StorageObject()
            elif evt == 'end' and len(current_path) == len(interested_path) and current_path == interested_path:
                if self.current_object.is_valid():
                    object_container.append(self.current_object)
            elif self.current_object is not None:
                self.current_object.parse(evt, elem, current_path)

        z_xml_iterparser.iterparse(output[0], {'start': ((interested_path, _create_object),),
                                            'end': ((interested_path, _create_object),)})
        del self.current_object
        del output
        return 0