def create_snapshot(self, req):
        cmd = jsonobject.loads(req[http.REQUEST_BODY])
        spath = self._normalize_install_path(cmd.snapshotPath)

        do_create = True
        image_name, sp_name = spath.split('@')
        if cmd.skipOnExisting:
            snaps = lichbd.lichbd_snap_list(image_name)
            for s in snaps:
                do_create = False

        if do_create:
            lichbd.lichbd_snap_create(spath)

        rsp = CreateSnapshotRsp()
        rsp.size = self._get_file_size(image_name)
        self._set_capacity_to_response(rsp)
        return jsonobject.dumps(rsp)
    def create_snapshot(self, req):
        cmd = jsonobject.loads(req[http.REQUEST_BODY])
        spath = self._normalize_install_path(cmd.snapshotPath)

        do_create = True
        image_name, sp_name = spath.split('@')
        if cmd.skipOnExisting:
            snaps = lichbd.lichbd_snap_list(image_name)
            for s in snaps:
                do_create = False

        if do_create:
            lichbd.lichbd_snap_create(spath)

        rsp = CreateSnapshotRsp()
        rsp.size = self._get_file_size(image_name)
        self._set_capacity_to_response(rsp)
        return jsonobject.dumps(rsp)
    def rollback_snapshot(self, req):
        cmd = jsonobject.loads(req[http.REQUEST_BODY])
        spath = self._normalize_install_path(cmd.snapshotPath)

        image = spath.split("@")[0]
        snap =  spath.split("@")[1]
        snaps = lichbd.lichbd_snap_list(image)
        afters = snaps[(snaps.index(snap) + 1):]

        rsp = AgentResponse()

        if (len(afters) > 0):
            afters.reverse()
            rsp.success = False
            rsp.error = 'If you want to rollback the current snapshot, please delete all the later snapshots manually.[%s]' % (afters)
        else:
            lichbd.lichbd_snap_rollback(spath)
            self._set_capacity_to_response(rsp)

        return jsonobject.dumps(rsp)
    def rollback_snapshot(self, req):
        cmd = jsonobject.loads(req[http.REQUEST_BODY])
        spath = self._normalize_install_path(cmd.snapshotPath)

        image = spath.split("@")[0]
        snap =  spath.split("@")[1]
        snaps = lichbd.lichbd_snap_list(image)
        afters = snaps[(snaps.index(snap) + 1):]

        rsp = AgentResponse()

        if (len(afters) > 0):
            afters.reverse()
            rsp.success = False
            rsp.error = 'need del snapshots: %s, only can rollback to last one' % (afters)
        else:
            lichbd.lichbd_snap_rollback(spath)
            self._set_capacity_to_response(rsp)

        return jsonobject.dumps(rsp)
    def rollback_snapshot(self, req):
        cmd = jsonobject.loads(req[http.REQUEST_BODY])
        spath = self._normalize_install_path(cmd.snapshotPath)

        image = spath.split("@")[0]
        snap =  spath.split("@")[1]
        snaps = lichbd.lichbd_snap_list(image)
        afters = snaps[(snaps.index(snap) + 1):]

        rsp = AgentResponse()

        if (len(afters) > 0):
            afters.reverse()
            rsp.success = False
            rsp.error = 'If you want to rollback the current snapshot, please delete all the later snapshots manually.[%s]' % (afters)
        else:
            lichbd.lichbd_snap_rollback(spath)
            self._set_capacity_to_response(rsp)

        return jsonobject.dumps(rsp)