Removes Windows dependencies in metadata services
Removes dependencies from utils.windows.x509 in the metadata services.
This commit is contained in:
parent
63f22383aa
commit
146e88dc42
@ -19,7 +19,7 @@ from oslo.config import cfg
|
||||
|
||||
from cloudbaseinit.metadata.services import base
|
||||
from cloudbaseinit.openstack.common import log as logging
|
||||
from cloudbaseinit.utils.windows import x509
|
||||
from cloudbaseinit.utils import x509constants
|
||||
|
||||
opts = [
|
||||
cfg.StrOpt('metadata_base_url', default='http://169.254.169.254/',
|
||||
@ -104,7 +104,7 @@ class BaseOpenStackService(base.BaseMetadataService):
|
||||
# Look if the user_data contains a PEM certificate
|
||||
try:
|
||||
user_data = self.get_user_data()
|
||||
if user_data.startswith(x509.PEM_HEADER):
|
||||
if user_data.startswith(x509constants.PEM_HEADER):
|
||||
cert_data = user_data
|
||||
except base.NotExistingMetadataException:
|
||||
LOG.debug("user_data metadata not present")
|
||||
|
@ -21,7 +21,7 @@ from oslo.config import cfg
|
||||
|
||||
from cloudbaseinit.metadata.services import base
|
||||
from cloudbaseinit.openstack.common import log as logging
|
||||
from cloudbaseinit.utils.windows import x509
|
||||
from cloudbaseinit.utils import x509constants
|
||||
|
||||
opts = [
|
||||
cfg.StrOpt('maas_metadata_url', default=None,
|
||||
@ -121,4 +121,4 @@ class MaaSHttpService(base.BaseMetadataService):
|
||||
def get_client_auth_certs(self):
|
||||
return self._get_list_from_text(
|
||||
self._get_cache_data('%s/meta-data/x509' % self._metadata_version),
|
||||
"%s\n" % x509.PEM_FOOTER)
|
||||
"%s\n" % x509constants.PEM_FOOTER)
|
||||
|
@ -21,6 +21,7 @@ import uuid
|
||||
from ctypes import wintypes
|
||||
|
||||
from cloudbaseinit.utils.windows import cryptoapi
|
||||
from cloudbaseinit.utils import x509constants
|
||||
|
||||
malloc = ctypes.cdll.msvcrt.malloc
|
||||
malloc.restype = ctypes.c_void_p
|
||||
@ -34,9 +35,6 @@ STORE_NAME_MY = "My"
|
||||
STORE_NAME_ROOT = "Root"
|
||||
STORE_NAME_TRUSTED_PEOPLE = "TrustedPeople"
|
||||
|
||||
PEM_HEADER = "-----BEGIN CERTIFICATE-----"
|
||||
PEM_FOOTER = "-----END CERTIFICATE-----"
|
||||
|
||||
|
||||
class CryptoAPICertManager(object):
|
||||
def _get_cert_thumprint(self, cert_context_p):
|
||||
@ -204,11 +202,11 @@ class CryptoAPICertManager(object):
|
||||
|
||||
def _get_cert_base64(self, cert_data):
|
||||
base64_cert_data = cert_data
|
||||
if base64_cert_data.startswith(PEM_HEADER):
|
||||
base64_cert_data = base64_cert_data[len(PEM_HEADER):]
|
||||
if base64_cert_data.endswith(PEM_FOOTER):
|
||||
if base64_cert_data.startswith(x509constants.PEM_HEADER):
|
||||
base64_cert_data = base64_cert_data[len(x509constants.PEM_HEADER):]
|
||||
if base64_cert_data.endswith(x509constants.PEM_FOOTER):
|
||||
base64_cert_data = base64_cert_data[:len(base64_cert_data) -
|
||||
len(PEM_FOOTER)]
|
||||
len(x509constants.PEM_FOOTER)]
|
||||
return base64_cert_data.replace("\n", "")
|
||||
|
||||
def import_cert(self, cert_data, machine_keyset=True,
|
||||
|
16
cloudbaseinit/utils/x509constants.py
Normal file
16
cloudbaseinit/utils/x509constants.py
Normal file
@ -0,0 +1,16 @@
|
||||
# Copyright 2014 Cloudbase Solutions Srl
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
PEM_HEADER = "-----BEGIN CERTIFICATE-----"
|
||||
PEM_FOOTER = "-----END CERTIFICATE-----"
|
Loading…
x
Reference in New Issue
Block a user