diff --git a/cloudbaseinit/metadata/services/base.py b/cloudbaseinit/metadata/services/base.py index bfd32e99..82854755 100644 --- a/cloudbaseinit/metadata/services/base.py +++ b/cloudbaseinit/metadata/services/base.py @@ -68,8 +68,7 @@ class BaseMetadataService(object): raise NotImplementedError() def post_password(self, enc_password_b64, version='latest'): - path = posixpath.normpath(posixpath.join(path, - 'openstack', + path = posixpath.normpath(posixpath.join('openstack', version, 'password')) return self._post_data(path, enc_password_b64) diff --git a/cloudbaseinit/metadata/services/httpservice.py b/cloudbaseinit/metadata/services/httpservice.py index 474c57c6..e70504ff 100644 --- a/cloudbaseinit/metadata/services/httpservice.py +++ b/cloudbaseinit/metadata/services/httpservice.py @@ -15,7 +15,6 @@ # under the License. import posixpath -import urllib import urllib2 from cloudbaseinit.metadata.services.base import * @@ -47,25 +46,25 @@ class HttpService(BaseMetadataService): try: return urllib2.urlopen(req) except urllib2.HTTPError as ex: - if ex.code == 404: + if ex.code == 404: raise NotExistingMetadataException() else: - raise ex - + raise ex + def _get_data(self, path): norm_path = posixpath.join(CONF.metadata_base_url, path) LOG.debug('Getting metadata from: %(norm_path)s' % locals()) req = urllib2.Request(norm_path) response = self._get_response(req) return response.read() - + def _post_data(self, path, data): norm_path = posixpath.join(CONF.metadata_base_url, path) LOG.debug('Posting metadata to: %(norm_path)s' % locals()) - req = urllib2.Request(norm_path, data=urllib.urlencode(data)) + req = urllib2.Request(norm_path, data=data) self._get_response(req) return True - + def post_password(self, enc_password_b64, version='latest'): try: return super(HttpService, self).post_password(enc_password_b64, @@ -76,6 +75,5 @@ class HttpService(BaseMetadataService): return False else: raise ex - - - \ No newline at end of file + + diff --git a/cloudbaseinit/utils/crypt.py b/cloudbaseinit/utils/crypt.py index 60db31f1..c2d8552b 100644 --- a/cloudbaseinit/utils/crypt.py +++ b/cloudbaseinit/utils/crypt.py @@ -21,11 +21,11 @@ import struct import sys if sys.platform == "win32": - openssl_lib_name = "libeay32" + openssl_lib_path = "libeay32.dll" else: - openssl_lib_name = "ssl" + openssl_lib_path = ctypes.util.find_library("ssl") -openssl = ctypes.CDLL(ctypes.util.find_library(openssl_lib_name)) +openssl = ctypes.CDLL(openssl_lib_path) clib = ctypes.CDLL(ctypes.util.find_library("c")) class RSA(ctypes.Structure): @@ -140,8 +140,8 @@ class CryptManager(object): def load_ssh_rsa_public_key(self, ssh_pub_key): ssh_rsa_prefix = "ssh-rsa " - i = ssh_pub_key.rindex(' ') - b64_pub_key = ssh_pub_key[len(ssh_rsa_prefix):i] + s = ssh_pub_key[len(ssh_rsa_prefix):] + b64_pub_key = s[:s.index(' ')] pub_key = base64.b64decode(b64_pub_key)