Resolve bashate and pep8 warnings
This update addresses existing bashate and pep8 warnings in cgcs-patch, patch-alarm, and tsconfig. The bulk of these updates are style and spacing changes, such as whitespace style conventions. Story: 2003371 Task: 24433 Change-Id: I44b26d24788907bac0730a952d70ed4bafb87d90 Signed-off-by: Don Penney <don.penney@windriver.com>
This commit is contained in:
parent
e5afe88d43
commit
ae0314279f
|
@ -13,14 +13,12 @@ SYSTEM_CHANGED_FLAG=/var/run/node_is_patched
|
|||
|
||||
logfile=/var/log/patching.log
|
||||
|
||||
function LOG()
|
||||
{
|
||||
function LOG {
|
||||
logger "$NAME: $*"
|
||||
echo "`date "+%FT%T.%3N"`: $NAME: $*" >> $logfile
|
||||
}
|
||||
|
||||
if [ -f $SYSTEM_CHANGED_FLAG ]
|
||||
then
|
||||
if [ -f $SYSTEM_CHANGED_FLAG ]; then
|
||||
LOG "Node has been patched. Failing goenabled check."
|
||||
exit 1
|
||||
fi
|
||||
|
|
|
@ -49,16 +49,13 @@ start()
|
|||
|
||||
stop()
|
||||
{
|
||||
if [ -f $PATCH_INSTALLING_FILE ]
|
||||
then
|
||||
if [ -f $PATCH_INSTALLING_FILE ]; then
|
||||
echo "Patches are installing. Waiting for install to complete."
|
||||
while [ -f $PATCH_INSTALLING_FILE ]
|
||||
do
|
||||
while [ -f $PATCH_INSTALLING_FILE ]; do
|
||||
# Verify the agent is still running
|
||||
pid=$(cat $PATCH_INSTALLING_FILE)
|
||||
cat /proc/$pid/cmdline 2>/dev/null | grep -q $DAEMON
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Patch agent not running."
|
||||
break
|
||||
fi
|
||||
|
|
|
@ -20,21 +20,17 @@ PATCHING_DIR=/opt/patching
|
|||
|
||||
logfile=/var/log/patching.log
|
||||
|
||||
function LOG()
|
||||
{
|
||||
function LOG {
|
||||
logger "$NAME: $*"
|
||||
echo "`date "+%FT%T.%3N"`: $NAME: $*" >> $logfile
|
||||
}
|
||||
|
||||
function LOG_TO_FILE()
|
||||
{
|
||||
function LOG_TO_FILE {
|
||||
echo "`date "+%FT%T.%3N"`: $NAME: $*" >> $logfile
|
||||
}
|
||||
|
||||
function create_groups()
|
||||
{
|
||||
if [ -f $GROUPS_FILE ]
|
||||
then
|
||||
function create_groups {
|
||||
if [ -f $GROUPS_FILE ]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
|
@ -45,11 +41,9 @@ function create_groups()
|
|||
EOF
|
||||
}
|
||||
|
||||
function do_setup()
|
||||
{
|
||||
function do_setup {
|
||||
# Does the repo exist?
|
||||
if [ ! -d $REPO_DIR ]
|
||||
then
|
||||
if [ ! -d $REPO_DIR ]; then
|
||||
LOG "Creating repo"
|
||||
mkdir -p $REPO_DIR
|
||||
|
||||
|
@ -59,8 +53,7 @@ function do_setup()
|
|||
createrepo -g $GROUPS_FILE $REPO_DIR >> $logfile 2>&1
|
||||
fi
|
||||
|
||||
if [ ! -d $PATCHING_DIR ]
|
||||
then
|
||||
if [ ! -d $PATCHING_DIR ]; then
|
||||
LOG "Creating $PATCHING_DIR"
|
||||
mkdir -p $PATCHING_DIR
|
||||
fi
|
||||
|
@ -68,8 +61,7 @@ function do_setup()
|
|||
# If we can ping the active controller, sync the repos
|
||||
LOG_TO_FILE "ping -c 1 -w 1 controller"
|
||||
ping -c 1 -w 1 controller >> $logfile 2>&1 || ping6 -c 1 -w 1 controller >> $logfile 2>&1
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
if [ $? -ne 0 ]; then
|
||||
LOG "Cannot ping controller. Nothing to do"
|
||||
return 0
|
||||
fi
|
||||
|
|
|
@ -15,15 +15,12 @@ NAME=$(basename $0)
|
|||
|
||||
logfile=/var/log/patching.log
|
||||
|
||||
function LOG_TO_FILE()
|
||||
{
|
||||
function LOG_TO_FILE {
|
||||
echo "`date "+%FT%T.%3N"`: $NAME: $*" >> $logfile
|
||||
}
|
||||
|
||||
function check_for_rr_patch()
|
||||
{
|
||||
if [ -f /var/run/node_is_patched_rr ]
|
||||
then
|
||||
function check_for_rr_patch {
|
||||
if [ -f /var/run/node_is_patched_rr ]; then
|
||||
echo
|
||||
echo "Node has been patched and requires an immediate reboot."
|
||||
echo
|
||||
|
@ -32,14 +29,11 @@ function check_for_rr_patch()
|
|||
fi
|
||||
}
|
||||
|
||||
function check_install_uuid()
|
||||
{
|
||||
function check_install_uuid {
|
||||
# Check whether our installed load matches the active controller
|
||||
CONTROLLER_UUID=`curl -sf http://controller/feed/rel-${SW_VERSION}/install_uuid`
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
if [ "$HOSTNAME" = "controller-1" ]
|
||||
then
|
||||
if [ $? -ne 0 ]; then
|
||||
if [ "$HOSTNAME" = "controller-1" ]; then
|
||||
# If we're on controller-1, controller-0 may not have the install_uuid
|
||||
# matching this release, if we're in an upgrade. If the file doesn't exist,
|
||||
# bypass this check
|
||||
|
@ -51,8 +45,7 @@ function check_install_uuid()
|
|||
return 1
|
||||
fi
|
||||
|
||||
if [ "$INSTALL_UUID" != "$CONTROLLER_UUID" ]
|
||||
then
|
||||
if [ "$INSTALL_UUID" != "$CONTROLLER_UUID" ]; then
|
||||
LOG_TO_FILE "This node is running a different load than the active controller and must be reinstalled"
|
||||
echo "This node is running a different load than the active controller and must be reinstalled"
|
||||
return 1
|
||||
|
@ -69,8 +62,7 @@ if [ -f /etc/platform/installation_failed ] ; then
|
|||
fi
|
||||
|
||||
# Clean up the RPM DB
|
||||
if [ ! -f /var/run/.rpmdb_cleaned ]
|
||||
then
|
||||
if [ ! -f /var/run/.rpmdb_cleaned ]; then
|
||||
LOG_TO_FILE "Cleaning RPM DB"
|
||||
rm -f /var/lib/rpm/__db*
|
||||
touch /var/run/.rpmdb_cleaned
|
||||
|
@ -82,19 +74,16 @@ fi
|
|||
DELAY_SEC=120
|
||||
START=`date +%s`
|
||||
FOUND=0
|
||||
while [ $(date +%s) -lt $(( ${START} + ${DELAY_SEC} )) ]
|
||||
do
|
||||
while [ $(date +%s) -lt $(( ${START} + ${DELAY_SEC} )) ]; do
|
||||
ping -c 1 controller > /dev/null 2>&1 || ping6 -c 1 controller > /dev/null 2>&1
|
||||
if [ $? -eq 0 ]
|
||||
then
|
||||
if [ $? -eq 0 ]; then
|
||||
FOUND=1
|
||||
break
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
|
||||
if [ ${FOUND} -eq 0 ]
|
||||
then
|
||||
if [ ${FOUND} -eq 0 ]; then
|
||||
# 'controller' is not available, just exit
|
||||
LOG_TO_FILE "Unable to contact active controller (controller). Boot will continue."
|
||||
exit 1
|
||||
|
@ -102,8 +91,7 @@ fi
|
|||
|
||||
case "$1" in
|
||||
start)
|
||||
if [ "${system_mode}" = "simplex" ]
|
||||
then
|
||||
if [ "${system_mode}" = "simplex" ]; then
|
||||
# On a simplex CPE, we need to launch the http server first,
|
||||
# before we can do the patch installation
|
||||
LOG_TO_FILE "***** Launching lighttpd *****"
|
||||
|
@ -117,8 +105,7 @@ case "$1" in
|
|||
/etc/init.d/lighttpd stop
|
||||
else
|
||||
check_install_uuid
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
if [ $? -ne 0 ]; then
|
||||
# The INSTALL_UUID doesn't match the active controller, so exit
|
||||
exit 1
|
||||
fi
|
||||
|
|
|
@ -96,6 +96,7 @@ def configure_logging(logtofile=True, level=logging.DEBUG):
|
|||
else:
|
||||
logging.basicConfig(level=level)
|
||||
|
||||
|
||||
def rev_lt(num1, num2):
|
||||
n1w = num1.split('.')
|
||||
n2w = num2.split('.')
|
||||
|
@ -126,6 +127,7 @@ def add_text_tag_to_xml(parent, name, text):
|
|||
tag.text = text
|
||||
return tag
|
||||
|
||||
|
||||
def handle_exception(exc_type, exc_value, exc_traceback):
|
||||
"""
|
||||
Exception handler to log any uncaught exceptions
|
||||
|
@ -134,6 +136,7 @@ def handle_exception(exc_type, exc_value, exc_traceback):
|
|||
exc_info=(exc_type, exc_value, exc_traceback))
|
||||
sys.__excepthook__(exc_type, exc_value, exc_traceback)
|
||||
|
||||
|
||||
def write_xml_file(top, fname):
|
||||
# Generate the file, in a readable format if possible
|
||||
outfile = open(fname, 'w')
|
||||
|
@ -147,6 +150,7 @@ def write_xml_file(top, fname):
|
|||
else:
|
||||
outfile.write(minidom.parseString(rough_xml).toprettyxml(indent=" "))
|
||||
|
||||
|
||||
class PatchRecipeError(Exception):
|
||||
"""Base class for patch recipe exceptions."""
|
||||
|
||||
|
@ -156,26 +160,32 @@ class PatchRecipeError(Exception):
|
|||
def __str__(self):
|
||||
return self.message or ""
|
||||
|
||||
|
||||
class PatchRecipeXMLFail(PatchRecipeError):
|
||||
"""Problem parsing XML of patch recipe."""
|
||||
pass
|
||||
|
||||
|
||||
class PatchBuildFail(PatchRecipeError):
|
||||
"""Problem Compiling the patch."""
|
||||
pass
|
||||
|
||||
|
||||
class PatchPackagingFail(PatchRecipeError):
|
||||
"""Problem assembling the patch."""
|
||||
pass
|
||||
|
||||
|
||||
class PatchPackagingMiss(PatchRecipeError):
|
||||
"""Problem assembling the patch - might be correctable."""
|
||||
pass
|
||||
|
||||
|
||||
class PatchRequirementFail(PatchRecipeError):
|
||||
"""Missing Requirement."""
|
||||
pass
|
||||
|
||||
|
||||
class PatchRecipeCmdFail(PatchRecipeError):
|
||||
"""Shell command Failure."""
|
||||
pass
|
||||
|
@ -377,7 +387,6 @@ class PatchList:
|
|||
xml_path = self._std_local_path(self._std_xml_patch_recipe_name(patch_id))
|
||||
self.add(xml_path, built=True, fix=False)
|
||||
|
||||
|
||||
def get_implicit_requires(self, patch_id, recipies):
|
||||
list = []
|
||||
for r in recipies:
|
||||
|
@ -513,7 +522,6 @@ class PatchList:
|
|||
|
||||
prd.gen_xml(fname=self._std_local_path(self._std_xml_patch_recipe_name(prd.patch_id)))
|
||||
|
||||
|
||||
def build_patches(self):
|
||||
global capture_source_flag
|
||||
# While unbuild patches exist
|
||||
|
@ -635,7 +643,6 @@ class PackageData:
|
|||
raise PatchRecipeXMLFail(msg)
|
||||
sys.exit(2)
|
||||
|
||||
|
||||
def gen_xml(self, e_package):
|
||||
for personality in self.personalities:
|
||||
add_text_tag_to_xml(e_package, 'PERSONALITY', personality)
|
||||
|
@ -784,6 +791,7 @@ class PackageData:
|
|||
raise PatchPackagingFail(msg)
|
||||
sys.exit(2)
|
||||
|
||||
|
||||
class RecipeData:
|
||||
"""
|
||||
Recipe data
|
||||
|
@ -903,6 +911,7 @@ class RecipeData:
|
|||
print "=========== is_prebuilt prebuilt=%s for %s =============" % (self.prebuilt, self.name)
|
||||
return self.prebuilt
|
||||
|
||||
|
||||
class PatchRecipeData:
|
||||
"""
|
||||
Patch recipe data
|
||||
|
@ -951,7 +960,6 @@ class PatchRecipeData:
|
|||
rc = rc2
|
||||
return rc
|
||||
|
||||
|
||||
def set_implicit_requires(self, patch_list):
|
||||
self.auto_requires = patch_list.get_implicit_requires(self.patch_id, self.recipies.keys())
|
||||
|
||||
|
@ -1229,7 +1237,6 @@ class PatchRecipeData:
|
|||
|
||||
return True
|
||||
|
||||
|
||||
def _get_prev_patch_id(self, patch_id):
|
||||
patch_order_file = self.pl._std_local_path(self.pl.order_file)
|
||||
prev_patch_id = None
|
||||
|
@ -1385,17 +1392,18 @@ class PatchRecipeData:
|
|||
issue_cmd("build-pkgs --no-build-info --careful %s" % self.recipies[recipe].name)
|
||||
self.recipies[recipe].build_patch(pf, fatal=True)
|
||||
|
||||
|
||||
local_path = self.pl._std_local_path("")
|
||||
print "=== local_path = %s ===" % local_path
|
||||
pf.gen_patch(outdir=local_path)
|
||||
|
||||
return True
|
||||
|
||||
|
||||
def _tag_build_context():
|
||||
os.chdir(srcdir)
|
||||
issue_cmd("for e in . `wrgit all-core-gits` ; do (cd $e ; git tag v%s) done" % self.patch_id)
|
||||
|
||||
|
||||
def read_build_info():
|
||||
try:
|
||||
build_info_find_cmd = ["find", "std/rpmbuild/RPMS/", "-name", "build-info-[0-9]*.x86_64.rpm"]
|
||||
|
@ -1422,10 +1430,12 @@ def read_build_info():
|
|||
return False
|
||||
return True
|
||||
|
||||
|
||||
def patch_id_to_tag(patch_id):
|
||||
tag = "v%s" % patch_id
|
||||
return tag
|
||||
|
||||
|
||||
def validate_tag(tag):
|
||||
try:
|
||||
cmd = "git tag | grep %s" % tag
|
||||
|
@ -1437,6 +1447,7 @@ def validate_tag(tag):
|
|||
return False
|
||||
return True
|
||||
|
||||
|
||||
def issue_cmd_w_stdout(cmd):
|
||||
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
out = p.communicate()[0]
|
||||
|
@ -1458,6 +1469,7 @@ def issue_cmd(cmd):
|
|||
print msg
|
||||
raise PatchRecipeCmdFail(msg)
|
||||
|
||||
|
||||
def issue_cmd_no_raise(cmd):
|
||||
print "CMD: %s" % cmd
|
||||
rc = subprocess.call(cmd, shell=True)
|
||||
|
@ -1466,11 +1478,13 @@ def issue_cmd_no_raise(cmd):
|
|||
LOG.exception(msg)
|
||||
print msg
|
||||
|
||||
|
||||
def issue_cmd_rc(cmd):
|
||||
print "CMD: %s" % cmd
|
||||
rc = subprocess.call(cmd, shell=True)
|
||||
return rc
|
||||
|
||||
|
||||
def set_capture_source_path():
|
||||
global capture_source_path
|
||||
my_repo = None
|
||||
|
@ -1491,6 +1505,7 @@ def set_capture_source_path():
|
|||
if rc == 0:
|
||||
capture_source_path = new_path
|
||||
|
||||
|
||||
def capture_rpms():
|
||||
for build_type in BUILD_TYPES:
|
||||
src_rpm_dir = "%s/%s/%s" % (workdir, build_type, RPM_DIR)
|
||||
|
@ -1499,12 +1514,14 @@ def capture_rpms():
|
|||
issue_cmd("mkdir -p %s" % dest_rpm_dir)
|
||||
issue_cmd("rsync -avu %s/*.rpm %s" % (src_rpm_dir, dest_rpm_dir))
|
||||
|
||||
|
||||
def modify_patch_usage():
|
||||
msg = "modify_patch [ --obsolete | --released | --development ] [ --sw_version <version> --id <patch_id> | --file <patch_path.patch> ]"
|
||||
LOG.exception(msg)
|
||||
print msg
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def modify_patch():
|
||||
global workdir
|
||||
global temp_rpm_db_dir
|
||||
|
@ -1528,7 +1545,6 @@ def modify_patch():
|
|||
print str(e)
|
||||
modify_patch_usage()
|
||||
|
||||
|
||||
patch_path = None
|
||||
cwd = os.getcwd()
|
||||
|
||||
|
@ -1572,7 +1588,7 @@ def modify_patch():
|
|||
temp_rpm_db_dir = "%s/%s" % (workdir, ".rpmdb")
|
||||
if patch_path is not None:
|
||||
rc = PatchFile.modify_patch(patch_path, "status", new_status)
|
||||
assert(rc == True)
|
||||
assert(rc)
|
||||
print "Patch '%s' has been modified to status '%s'" % (patch_path, new_status)
|
||||
else:
|
||||
if sw_version is None or patch_id is None:
|
||||
|
@ -1588,7 +1604,7 @@ def modify_patch():
|
|||
print "patch_file_name = %s" % patch_file_name
|
||||
print "patch_path = %s" % patch_path
|
||||
rc = PatchFile.modify_patch(patch_path, "status", new_status)
|
||||
assert(rc == True)
|
||||
assert(rc)
|
||||
os.chdir(pl._std_patch_git_path(".."))
|
||||
issue_cmd("git add %s" % patch_path)
|
||||
issue_cmd("git commit -m \"Modify status of patch '%s' to '%s'\"" % (patch_id, new_status))
|
||||
|
@ -1652,7 +1668,7 @@ def modify_patch():
|
|||
human_release = "Titanium Cloud 4"
|
||||
windshare_folder = "Titanium-Cloud-4"
|
||||
|
||||
if sw_version == "18.03" || sw_version == "18.03"
|
||||
if sw_version == "18.03" or sw_version == "18.03":
|
||||
local_dest = "/folk/cgts/rel-ops/%s/patches/" % sw_version
|
||||
deliver_dest = "/folk/prj-wrlinux/release/tis/tis-5/update/ti%s-%s/Titanium-Cloud-5/patches" % (ts, munged_patch_id)
|
||||
human_release = "Titanium Cloud 5"
|
||||
|
@ -1711,6 +1727,7 @@ def query_patch_usage():
|
|||
print msg
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def query_patch():
|
||||
global workdir
|
||||
global temp_rpm_db_dir
|
||||
|
@ -1732,7 +1749,6 @@ def query_patch():
|
|||
print str(e)
|
||||
query_patch_usage()
|
||||
|
||||
|
||||
patch_path = None
|
||||
cwd = os.getcwd()
|
||||
field = None
|
||||
|
@ -1794,6 +1810,7 @@ def make_patch_usage():
|
|||
print msg
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def make_patch():
|
||||
global workdir
|
||||
global temp_rpm_db_dir
|
||||
|
@ -1916,7 +1933,6 @@ def make_patch():
|
|||
print "invalid patch file path: '%s'" % patch
|
||||
make_patch_usage()
|
||||
|
||||
|
||||
if 'MY_REPO' in os.environ:
|
||||
MY_REPO = os.path.normpath(os.path.join(cwd, os.path.expanduser(os.environ['MY_REPO'])))
|
||||
else:
|
||||
|
@ -1991,4 +2007,3 @@ def make_patch():
|
|||
pl.sign_official_patches()
|
||||
# deliver to git repo
|
||||
pl.deliver_official_patch()
|
||||
|
||||
|
|
|
@ -4,4 +4,3 @@ Copyright (c) 2014-2017 Wind River Systems, Inc.
|
|||
SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
"""
|
||||
|
||||
|
|
|
@ -5,12 +5,10 @@ SPDX-License-Identifier: Apache-2.0
|
|||
|
||||
"""
|
||||
|
||||
#from oslo.config import cfg
|
||||
import pecan
|
||||
|
||||
from cgcs_patch.api import config
|
||||
|
||||
#CONF = cfg.CONF
|
||||
|
||||
def get_pecan_config():
|
||||
# Set up the pecan configuration
|
||||
|
|
|
@ -4,4 +4,3 @@ Copyright (c) 2014-2017 Wind River Systems, Inc.
|
|||
SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
"""
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ from cgcs_patch.patch_controller import pc
|
|||
import logging
|
||||
from cgcs_patch.patch_functions import LOG
|
||||
|
||||
|
||||
class PatchAPIController(object):
|
||||
|
||||
@expose('json')
|
||||
|
@ -263,4 +264,3 @@ class RootController(object):
|
|||
|
||||
patch = PatchAPIController()
|
||||
v1 = PatchAPIController()
|
||||
|
||||
|
|
|
@ -4,13 +4,15 @@ Copyright (c) 2014-2017 Wind River Systems, Inc.
|
|||
SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
"""
|
||||
"""Access Control Lists (ACL's) control access the API server."""
|
||||
|
||||
from cgcs_patch.authapi import auth_token
|
||||
|
||||
OPT_GROUP_NAME = 'keystone_authtoken'
|
||||
|
||||
|
||||
"""Access Control Lists (ACL's) control access the API server."""
|
||||
|
||||
|
||||
def install(app, conf, public_routes):
|
||||
"""Install ACL check on application.
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ from sysinv.openstack.common import policy
|
|||
_POLICY_PATH = None
|
||||
_POLICY_CACHE = {}
|
||||
|
||||
|
||||
def reset():
|
||||
global _POLICY_PATH
|
||||
global _POLICY_CACHE
|
||||
|
|
|
@ -163,4 +163,3 @@ class PatchService:
|
|||
LOG.info("Unable to setup sockets. Waiting to retry")
|
||||
time.sleep(5)
|
||||
LOG.info("Multicast address reconfigured")
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ platform_conf_mtime = 0
|
|||
patching_conf_mtime = 0
|
||||
patching_conf = '/etc/patching/patching.conf'
|
||||
|
||||
|
||||
def read_config():
|
||||
global patching_conf_mtime
|
||||
global patching_conf
|
||||
|
@ -122,5 +123,3 @@ def get_mgmt_iface():
|
|||
logging.exception("Failed to read management_interface from config")
|
||||
return None
|
||||
return mgmt_if
|
||||
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ SPDX-License-Identifier: Apache-2.0
|
|||
|
||||
"""
|
||||
|
||||
|
||||
class PatchError(Exception):
|
||||
"""Base class for patching exceptions."""
|
||||
|
||||
|
|
|
@ -699,7 +699,7 @@ def print_query_hosts_result(req):
|
|||
|
||||
for agent in sorted(agents, key=lambda a: a["hostname"]):
|
||||
patch_current_field = "Yes" if agent["patch_current"] else "No"
|
||||
if agent.get("interim_state") == True:
|
||||
if agent.get("interim_state") is True:
|
||||
patch_current_field = "Pending"
|
||||
|
||||
if agent["patch_failed"]:
|
||||
|
@ -862,7 +862,7 @@ def wait_for_install_complete(agent_ip):
|
|||
break
|
||||
|
||||
if state == constants.PATCH_AGENT_STATE_INSTALLING or \
|
||||
interim_state == True:
|
||||
interim_state is True:
|
||||
# Still installing
|
||||
sys.stdout.write(".")
|
||||
sys.stdout.flush()
|
||||
|
|
|
@ -537,7 +537,6 @@ class PatchMessageDropHostReq(messages.PatchMessage):
|
|||
sock.sendto(message, (cfg.controller_mcast_group, cfg.controller_port))
|
||||
|
||||
|
||||
|
||||
class PatchController(PatchService):
|
||||
def __init__(self):
|
||||
PatchService.__init__(self)
|
||||
|
|
|
@ -824,7 +824,8 @@ class PatchFile:
|
|||
# Note: if cert_type requests a formal signature, but the signing key
|
||||
# is not found, we'll instead sign with the 'dev' key and
|
||||
# need_resign_with_formal is set to True.
|
||||
need_resign_with_formal = sign_files(['metadata.tar', 'software.tar'],
|
||||
need_resign_with_formal = sign_files(
|
||||
['metadata.tar', 'software.tar'],
|
||||
detached_signature_file,
|
||||
cert_type=cert_type)
|
||||
|
||||
|
@ -947,11 +948,11 @@ class PatchFile:
|
|||
try:
|
||||
PatchFile.read_patch(abs_patch, metadata_only=True, cert_type=[cert_type_str])
|
||||
except PatchValidationFailure as e:
|
||||
pass;
|
||||
pass
|
||||
else:
|
||||
# Successfully opened the file for reading, and we have discovered the cert_type
|
||||
r["cert"] = cert_type_str
|
||||
break;
|
||||
break
|
||||
|
||||
if "cert" not in r:
|
||||
# If cert is unknown, then file is not yet open for reading.
|
||||
|
|
|
@ -29,6 +29,7 @@ cert_type_dev=[cert_type_dev_str]
|
|||
cert_type_formal = [cert_type_formal_str]
|
||||
cert_type_all = [cert_type_dev_str, cert_type_formal_str]
|
||||
|
||||
|
||||
def verify_hash(data_hash, signature_bytes, certificate_list):
|
||||
"""
|
||||
Checkes that a hash's signature can be validates against an approved
|
||||
|
@ -185,4 +186,3 @@ def verify_files(filenames, signature_file, cert_type=None):
|
|||
else:
|
||||
certificate_list = get_public_certificates_by_type(cert_type=cert_type)
|
||||
return verify_hash(data_hash, signature_bytes, certificate_list)
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ import time
|
|||
|
||||
directory = "/localdisk/designer/jenkins/patch_ids"
|
||||
|
||||
|
||||
def get_unique_id(filename, digits=4):
|
||||
counter = 1
|
||||
path = "%s/%s" % (directory, filename)
|
||||
|
@ -38,6 +39,7 @@ def get_unique_id(filename, digits=4):
|
|||
|
||||
return counter
|
||||
|
||||
|
||||
def get_patch_id(version, prefix="CGCS", digits=4):
|
||||
filename = "%s_%s_patchid" % (prefix, version)
|
||||
id = get_unique_id(filename)
|
||||
|
@ -46,4 +48,3 @@ def get_patch_id(version, prefix="CGCS", digits=4):
|
|||
patch_id_format = "%%s_%%s_PATCH_%%0%dd" % digits
|
||||
patch_id = patch_id_format % (prefix, version, id)
|
||||
return patch_id
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ opts = ['sw_version=', 'prefix=' ]
|
|||
server = 'yow-cgts2-lx.wrs.com'
|
||||
port = 8888
|
||||
|
||||
|
||||
def request_patch_id(sw_version="1.01", prefix="CGCS"):
|
||||
raw_parms = {}
|
||||
raw_parms['sw_version'] = sw_version
|
||||
|
@ -27,6 +28,7 @@ def request_patch_id(sw_version="1.01", prefix="CGCS"):
|
|||
response = urllib2.urlopen(url, params).read()
|
||||
return response
|
||||
|
||||
|
||||
def main():
|
||||
optlist, remainder = getopt.getopt(sys.argv[1:], '', opts)
|
||||
|
||||
|
|
|
@ -11,13 +11,13 @@ import web
|
|||
import patch_id_allocator as pida
|
||||
|
||||
|
||||
|
||||
port = 8888
|
||||
|
||||
urls = (
|
||||
'/get_patch_id', 'get_patch_id',
|
||||
)
|
||||
|
||||
|
||||
class get_patch_id:
|
||||
def GET(self):
|
||||
data = web.input(sw_version=None, prefix="CGCS")
|
||||
|
@ -29,15 +29,16 @@ class get_patch_id:
|
|||
output = pida.get_patch_id(data.sw_version, data.prefix)
|
||||
return output
|
||||
|
||||
|
||||
class MyApplication(web.application):
|
||||
def run(self, port=8080, *middleware):
|
||||
func = self.wsgifunc(*middleware)
|
||||
return web.httpserver.runsimple(func, ('0.0.0.0', port))
|
||||
|
||||
|
||||
def main():
|
||||
app = MyApplication(urls, globals())
|
||||
app.run(port=port)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
|
|
|
@ -8,7 +8,8 @@
|
|||
|
||||
import setuptools
|
||||
|
||||
setuptools.setup(name='cgcs_patch',
|
||||
setuptools.setup(
|
||||
name='cgcs_patch',
|
||||
version='1.0',
|
||||
description='CGCS Patch',
|
||||
packages=setuptools.find_packages(),
|
||||
|
@ -17,4 +18,3 @@ setuptools.setup(name='cgcs_patch',
|
|||
'': ['templates/*'],
|
||||
}
|
||||
)
|
||||
|
||||
|
|
|
@ -28,8 +28,6 @@ from cgcs_patch.constants import ENABLE_DEV_CERTIFICATE_PATCH_IDENTIFIER
|
|||
LOG_FILE = '/var/log/patch-alarms.log'
|
||||
PID_FILE = '/var/run/patch-alarm-manager.pid'
|
||||
|
||||
#logging.basicConfig(filename=LOG_FILE, level=logging.DEBUG)
|
||||
|
||||
|
||||
###################
|
||||
# METHODS
|
||||
|
@ -169,7 +167,6 @@ class PatchAlarmDaemon():
|
|||
|
||||
self.fm_api.set_fault(fault)
|
||||
|
||||
|
||||
def _get_handle_failed_hosts(self):
|
||||
url = "http://%s/patch/query_hosts" % self.api_addr
|
||||
|
||||
|
@ -220,4 +217,3 @@ class PatchAlarmDaemon():
|
|||
entity_instance_id)
|
||||
|
||||
return False
|
||||
|
||||
|
|
|
@ -9,11 +9,11 @@ SPDX-License-Identifier: Apache-2.0
|
|||
|
||||
import setuptools
|
||||
|
||||
setuptools.setup(name='patch_alarm',
|
||||
setuptools.setup(
|
||||
name='patch_alarm',
|
||||
version='1.0.0',
|
||||
description='CEPH alarm',
|
||||
license='Apache-2.0',
|
||||
packages=['patch_alarm'],
|
||||
entry_points={
|
||||
}
|
||||
entry_points={}
|
||||
)
|
||||
|
|
29
tox.ini
29
tox.ini
|
@ -23,36 +23,13 @@ commands =
|
|||
-o \( -name .tox -prune \) \
|
||||
-o -type f -name '*.yaml' \
|
||||
-print0 | xargs -0 yamllint"
|
||||
bash -c "ls cgcs-patch/bin/*.sh | xargs bashate -v {posargs}"
|
||||
bash -c "ls cgcs-patch/bin/*.sh | xargs bashate -v -iE006 {posargs}"
|
||||
|
||||
[pep8]
|
||||
# Temporarily ignoring these warnings
|
||||
# E101 indentation contains mixed spaces and tabs
|
||||
# E116 unexpected indentation (comment)
|
||||
# E121 continuation line under-indented for hanging indent
|
||||
# E122 continuation line missing indentation or outdented
|
||||
# E123 closing bracket does not match indentation of opening bracket
|
||||
# E124 closing bracket does not match visual indentation
|
||||
# E126 continuation line over-indented for hanging indent
|
||||
# E127 continuation line over-indented for visual indent
|
||||
# E128 continuation line under-indented for visual indent
|
||||
# E129 visually indented line with same indent as next logical line
|
||||
# E203 whitespace before ':'
|
||||
# E211 whitespace before '('
|
||||
# E225 missing whitespace around operator
|
||||
# E226 missing whitespace around arithmetic operator
|
||||
# E228 missing whitespace around modulo operator
|
||||
# E231 missing whitespace after ':'
|
||||
# E241 multiple spaces after
|
||||
# E261 at least two spaces before inline comment
|
||||
# E265 block comment should start with '# '
|
||||
# E251 unexpected spaces around keyword / parameter equals
|
||||
# E302 expected 2 blank lines, found 1
|
||||
# E303 too many blank lines
|
||||
# Ignoring these warnings
|
||||
# E501 line too long
|
||||
# E712 comparison to bool should be reworded
|
||||
|
||||
ignore = E101,E116,E121,E123,E122,E124,E126,E127,E128,E129,E203,E211,E225,E226,E228,E231,E241,E251,E261,E265,E302,E303,E501,E712
|
||||
ignore = E501
|
||||
|
||||
[testenv:pep8]
|
||||
usedevelop = False
|
||||
|
|
|
@ -9,11 +9,11 @@ SPDX-License-Identifier: Apache-2.0
|
|||
|
||||
import setuptools
|
||||
|
||||
setuptools.setup(name='tsconfig',
|
||||
setuptools.setup(
|
||||
name='tsconfig',
|
||||
version='1.0.0',
|
||||
description='tsconfig',
|
||||
license='Apache-2.0',
|
||||
packages=['tsconfig'],
|
||||
entry_points={
|
||||
}
|
||||
entry_points={}
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue