summaryrefslogtreecommitdiff
path: root/azurelinuxagent/common/protocol/hostplugin.py
diff options
context:
space:
mode:
authorƁukasz 'sil2100' Zemczak <lukasz.zemczak@ubuntu.com>2017-07-03 13:44:00 +0200
committerusd-importer <ubuntu-server@lists.ubuntu.com>2017-07-03 12:23:41 +0000
commit70c0ea1ac879b2e1cba0a8edb1f3fbe82652413b (patch)
treef168bb289117feb1c0d5b2c73604b44e85b064e2 /azurelinuxagent/common/protocol/hostplugin.py
parent68754fe67f1b3da2e6ca45885641941b3229698a (diff)
parent63aafec1b1a480947da7d5579c3ffc66b8fe5bdb (diff)
downloadvyos-walinuxagent-70c0ea1ac879b2e1cba0a8edb1f3fbe82652413b.tar.gz
vyos-walinuxagent-70c0ea1ac879b2e1cba0a8edb1f3fbe82652413b.zip
Import patches-applied version 2.2.14-0ubuntu1 to applied/ubuntu/artful-proposed
Imported using git-ubuntu import. Changelog parent: 68754fe67f1b3da2e6ca45885641941b3229698a Unapplied parent: 63aafec1b1a480947da7d5579c3ffc66b8fe5bdb New changelog entries: * New upstream release (LP: #1701350). * debian/copyright: - Refreshed copyright content.
Diffstat (limited to 'azurelinuxagent/common/protocol/hostplugin.py')
-rw-r--r--azurelinuxagent/common/protocol/hostplugin.py37
1 files changed, 25 insertions, 12 deletions
diff --git a/azurelinuxagent/common/protocol/hostplugin.py b/azurelinuxagent/common/protocol/hostplugin.py
index 464fd35..9af8a97 100644
--- a/azurelinuxagent/common/protocol/hostplugin.py
+++ b/azurelinuxagent/common/protocol/hostplugin.py
@@ -70,7 +70,7 @@ class HostPluginProtocol(object):
if not self.is_initialized:
self.api_versions = self.get_api_versions()
self.is_available = API_VERSION in self.api_versions
- self.is_initialized = True
+ self.is_initialized = self.is_available
from azurelinuxagent.common.event import WALAEventOperation, report_event
report_event(WALAEventOperation.InitializeHostPlugin,
is_success=self.is_available)
@@ -143,7 +143,9 @@ class HostPluginProtocol(object):
headers = {"x-ms-vmagentlog-deploymentid": self.deployment_id,
"x-ms-vmagentlog-containerid": self.container_id}
- logger.info("HostGAPlugin: Put VM log to [{0}]".format(url))
+ logger.periodic(
+ logger.EVERY_FIFTEEN_MINUTES,
+ "HostGAPlugin: Put VM log to [{0}]".format(url))
try:
response = restutil.http_put(url, content, headers)
if response.status != httpclient.OK:
@@ -175,7 +177,7 @@ class HostPluginProtocol(object):
self._put_page_blob_status(sas_url, status_blob)
if not HostPluginProtocol.is_default_channel():
- logger.info("HostGAPlugin: Setting host plugin as default channel")
+ logger.verbose("HostGAPlugin: Setting host plugin as default channel")
HostPluginProtocol.set_default_channel(True)
except Exception as e:
message = "HostGAPlugin: Exception Put VM status: {0}, {1}".format(e, traceback.format_exc())
@@ -288,12 +290,23 @@ class HostPluginProtocol(object):
@staticmethod
def read_response_error(response):
- if response is None:
- return ''
- body = remove_bom(response.read())
- if PY_VERSION_MAJOR < 3 and body is not None:
- body = ustr(body, encoding='utf-8')
- return "{0}, {1}, {2}".format(
- response.status,
- response.reason,
- body)
+ result = ''
+ if response is not None:
+ try:
+ body = remove_bom(response.read())
+ result = "[{0}: {1}] {2}".format(response.status,
+ response.reason,
+ body)
+
+ # this result string is passed upstream to several methods
+ # which do a raise HttpError() or a format() of some kind;
+ # as a result it cannot have any unicode characters
+ if PY_VERSION_MAJOR < 3:
+ result = ustr(result, encoding='ascii', errors='ignore')
+ else:
+ result = result\
+ .encode(encoding='ascii', errors='ignore')\
+ .decode(encoding='ascii', errors='ignore')
+ except Exception:
+ logger.warn(traceback.format_exc())
+ return result