diff options
author | Ćukasz 'sil2100' Zemczak <lukasz.zemczak@ubuntu.com> | 2017-03-15 10:19:34 +0100 |
---|---|---|
committer | usd-importer <ubuntu-server@lists.ubuntu.com> | 2017-03-17 13:08:24 +0000 |
commit | 83be006e288c58a46f5b76c29b6886c1f417d88c (patch) | |
tree | 91ba57e843714c232b5af5ab8dc6f3322ff7841e /azurelinuxagent/common/protocol/hostplugin.py | |
parent | d064ab0bffd429382ea4fafeb144784d403848bd (diff) | |
download | vyos-walinuxagent-83be006e288c58a46f5b76c29b6886c1f417d88c.tar.gz vyos-walinuxagent-83be006e288c58a46f5b76c29b6886c1f417d88c.zip |
Import patches-unapplied version 2.2.6-0ubuntu1 to ubuntu/zesty-proposed
Imported using git-ubuntu import.
Changelog parent: d064ab0bffd429382ea4fafeb144784d403848bd
New changelog entries:
* New upstream release (LP: #1661750).
* debian/control:
- Change the maintainer to Ubuntu Developers (LP: #1657528).
- Add the dependency of isc-dhcp-client as our maintainer scripts assume
it's installed.
- Add trailing commas to dependencies, add whitespaces.
* Rename ephemeral-disk-warning.sh to ephemeral-disk-warning (lintian error).
* debian/docs:
- Remove LICENSE.txt as it's redundant.
* debian/postinst:
- Stop checking for update-initramfs existence using the absolute path, use
the 'command' command instead to make lintian happy.
* Remove debian/patches/disable-auto-update.patch:
- We now ship with auto-updates enabled (LP: #1650522).
* debian/maintscript:
- Add a maintscript to rename the old logrotate file on upgrade from an
ancient version of walinuxagent (LP: #1673152).
Diffstat (limited to 'azurelinuxagent/common/protocol/hostplugin.py')
-rw-r--r-- | azurelinuxagent/common/protocol/hostplugin.py | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/azurelinuxagent/common/protocol/hostplugin.py b/azurelinuxagent/common/protocol/hostplugin.py index e83dd4b..bdae56e 100644 --- a/azurelinuxagent/common/protocol/hostplugin.py +++ b/azurelinuxagent/common/protocol/hostplugin.py @@ -16,7 +16,6 @@ # # Requires Python 2.4+ and Openssl 1.0+ # - from azurelinuxagent.common.protocol.wire import * from azurelinuxagent.common.utils import textutil @@ -32,6 +31,7 @@ HEADER_HOST_CONFIG_NAME = "x-ms-host-config-name" HEADER_ARTIFACT_LOCATION = "x-ms-artifact-location" HEADER_ARTIFACT_MANIFEST_LOCATION = "x-ms-artifact-manifest-location" + class HostPluginProtocol(object): def __init__(self, endpoint, container_id, role_config_name): if endpoint is None: @@ -41,6 +41,7 @@ class HostPluginProtocol(object): self.api_versions = None self.endpoint = endpoint self.container_id = container_id + self.deployment_id = None self.role_config_name = role_config_name self.manifest_uri = None @@ -49,6 +50,11 @@ class HostPluginProtocol(object): self.api_versions = self.get_api_versions() self.is_available = API_VERSION in self.api_versions self.is_initialized = True + + from azurelinuxagent.common.event import add_event, WALAEventOperation + add_event(name="WALA", + op=WALAEventOperation.InitializeHostPlugin, + is_success=self.is_available) return self.is_available def get_api_versions(self): @@ -74,10 +80,10 @@ class HostPluginProtocol(object): def get_artifact_request(self, artifact_url, artifact_manifest_url=None): if not self.ensure_initialized(): logger.error("host plugin channel is not available") - return + return None, None if textutil.is_str_none_or_whitespace(artifact_url): logger.error("no extension artifact url was provided") - return + return None, None url = URI_FORMAT_GET_EXTENSION_ARTIFACT.format(self.endpoint, HOST_PLUGIN_PORT) @@ -121,7 +127,10 @@ class HostPluginProtocol(object): 'content': status}, sort_keys=True) response = restutil.http_put(url, data=data, headers=headers) if response.status != httpclient.OK: - logger.error("PUT failed [{0}]", response.status) + logger.warn("PUT {0} [{1}: {2}]", + url, + response.status, + response.reason) else: logger.verbose("Successfully uploaded status to host plugin") except Exception as e: @@ -140,18 +149,20 @@ class HostPluginProtocol(object): if not self.ensure_initialized(): logger.error("host plugin channel is not available") return - if content is None or self.goal_state.container_id is None or self.goal_state.deployment_id is None: + if content is None \ + or self.container_id is None \ + or self.deployment_id is None: logger.error( "invalid arguments passed: " "[{0}], [{1}], [{2}]".format( content, - self.goal_state.container_id, - self.goal_state.deployment_id)) + self.container_id, + self.deployment_id)) return url = URI_FORMAT_PUT_LOG.format(self.endpoint, HOST_PLUGIN_PORT) - headers = {"x-ms-vmagentlog-deploymentid": self.goal_state.deployment_id, - "x-ms-vmagentlog-containerid": self.goal_state.container_id} + headers = {"x-ms-vmagentlog-deploymentid": self.deployment_id, + "x-ms-vmagentlog-containerid": self.container_id} logger.info("put VM log at [{0}]".format(url)) try: response = restutil.http_put(url, content, headers) |