Ejemplo n.º 1
0
 def setUp(self):
     self.log = structlog.get_logger()
     self.log.debug("do setup")
     self.device_id = '1'
     self._image_dnld = ImageDownload()
     self._image_dnld.id = '1'
     self._image_dnld.name = 'switchd_1012'
     # self._image_dnld.name = 'xgsont_4.4.4.006.img'
     self._image_dnld.url = 'http://192.168.100.222:9090/load/4.4.4.006.img'
     self._image_dnld.crc = 0
     self._image_dnld.local_dir = '/home/lcui/work/tmp'
     self._image_dnld.state = ImageDownload.DOWNLOAD_SUCCEEDED # ImageDownload.DOWNLOAD_UNKNOWN
     self._end_image_busy_try = 2
     self._act_image_busy_try = 0
     # self.image_file = '/home/lcui/work/tmp/v_change.txt'
     self.reactor = EPollReactor()
     self.defer = Deferred()
     self.adapter_agent = MockAdapterAgent(self.defer)
     self.defer.addCallback(self.cb_after_send_omci)
     pb2_dev = Device(id='1')
     self.adapter_agent.add_device(pb2_dev)
     self.core = self.adapter_agent.core
     self.omci_agent = OpenOMCIAgent(self.core, clock=self.reactor)
     self.device = self.omci_agent.add_device(self.device_id, self.adapter_agent)
     self.omci_agent.start()
     self.omci_agent.database.add('1')
     self.omci_agent.database.set('1', SoftwareImage.class_id, 0, {"is_committed": 1, "is_active": 1, "is_valid": 1})
     self.omci_agent.database.set('1', SoftwareImage.class_id, 1, {"is_committed": 0, "is_active": 0, "is_valid": 1})
Ejemplo n.º 2
0
    def revert_image_update(self, device, request, **kwargs):
        d = Device()
        if device:
            device.Unpack(d)
        else:
            return False, Error(code=ErrorCode.INVALID_PARAMETERS,
                                reason="device-invalid")
        img = ImageDownload()
        if request:
            request.Unpack(img)
        else:
            return False, Error(code=ErrorCode.INVALID_PARAMETERS,
                                reason="port-no-invalid")

        return True, self.adapter.revert_image_update(device, request)