# Copyright (c) 2017 VMware, Inc.  All rights reserved.
# -- VMware Confidential

import logging

logger = logging.getLogger(__name__)

from l10n import msgMetadata as _T, localizedString as _

import simpleXml


def getChanges():
    return _(_T("rhttpproxy.patch1.summary",
                "Unset the 'vmacore/ssl/protocols' config option."))


def doPatching(ctx):
    logger.info("Patch01: being executed {0}".format(ctx))

    configXml = "/etc/vmware-rhttpproxy/config.xml"

    with open(configXml, "r+", encoding="utf-8-sig") as f:
        root = simpleXml.Parse(f.read())
        simpleXml.UnsetPath(root, "vmacore/ssl/protocols")

        f.seek(0)
        f.write(simpleXml.Serialize(root))
        f.truncate()
