
The original cgcs-patch is rpm based which requires a complete re-write to work on ostree/dpkg systems like Debian. The code has been forked, since the older Centos env and python2.7 are end-of-life. Forking the code allows all new development to not require re-testing on Centos. The debian folder under cgcs-patch has been moved under sw-patch Renaming and refactoring will be done in later commits. pylint is un-clamped in order to work on python3.9 Some minor pylint suppressions have been added. Test Plan: Verify that this builds on Debian Verify that the ISO installs the new content on Debian without breaking packages that import cgcs_patch. Verify patching service runs on Debian Co-Authored-By: Jessica Castelino <jessica.castelino@windriver.com> Story: 2009101 Task: 43076 Signed-off-by: Al Bailey <al.bailey@windriver.com> Change-Id: I3f1bca749404053bae63d4bcc9fb2477cf909fcd
65 lines
1.8 KiB
Python
65 lines
1.8 KiB
Python
"""
|
|
Copyright (c) 2014-2017 Wind River Systems, Inc.
|
|
|
|
SPDX-License-Identifier: Apache-2.0
|
|
|
|
"""
|
|
|
|
from cgcs_patch.patch_functions import LOG
|
|
|
|
PATCHMSG_UNKNOWN = 0
|
|
PATCHMSG_HELLO = 1
|
|
PATCHMSG_HELLO_ACK = 2
|
|
PATCHMSG_SYNC_REQ = 3
|
|
PATCHMSG_SYNC_COMPLETE = 4
|
|
PATCHMSG_HELLO_AGENT = 5
|
|
PATCHMSG_HELLO_AGENT_ACK = 6
|
|
PATCHMSG_QUERY_DETAILED = 7
|
|
PATCHMSG_QUERY_DETAILED_RESP = 8
|
|
PATCHMSG_AGENT_INSTALL_REQ = 9
|
|
PATCHMSG_AGENT_INSTALL_RESP = 10
|
|
PATCHMSG_DROP_HOST_REQ = 11
|
|
|
|
PATCHMSG_STR = {
|
|
PATCHMSG_UNKNOWN: "unknown",
|
|
PATCHMSG_HELLO: "hello",
|
|
PATCHMSG_HELLO_ACK: "hello-ack",
|
|
PATCHMSG_SYNC_REQ: "sync-req",
|
|
PATCHMSG_SYNC_COMPLETE: "sync-complete",
|
|
PATCHMSG_HELLO_AGENT: "hello-agent",
|
|
PATCHMSG_HELLO_AGENT_ACK: "hello-agent-ack",
|
|
PATCHMSG_QUERY_DETAILED: "query-detailed",
|
|
PATCHMSG_QUERY_DETAILED_RESP: "query-detailed-resp",
|
|
PATCHMSG_AGENT_INSTALL_REQ: "agent-install-req",
|
|
PATCHMSG_AGENT_INSTALL_RESP: "agent-install-resp",
|
|
PATCHMSG_DROP_HOST_REQ: "drop-host-req",
|
|
}
|
|
|
|
|
|
class PatchMessage(object):
|
|
def __init__(self, msgtype=PATCHMSG_UNKNOWN):
|
|
self.msgtype = msgtype
|
|
self.msgversion = 1
|
|
self.message = {}
|
|
|
|
def decode(self, data):
|
|
if 'msgtype' in data:
|
|
self.msgtype = data['msgtype']
|
|
if 'msgversion' in data:
|
|
self.msgversion = data['msgversion']
|
|
|
|
def encode(self):
|
|
self.message['msgtype'] = self.msgtype
|
|
self.message['msgversion'] = self.msgversion
|
|
|
|
def data(self):
|
|
return {'msgtype': self.msgtype}
|
|
|
|
def msgtype_str(self):
|
|
if self.msgtype in PATCHMSG_STR:
|
|
return PATCHMSG_STR[self.msgtype]
|
|
return "invalid-type"
|
|
|
|
def handle(self, sock, addr): # pylint: disable=unused-argument
|
|
LOG.info("Unhandled message type: %s", self.msgtype)
|