当前位置: 首页>>代码示例>>Python>>正文


Python context.ApacheSSLContext方法代码示例

本文整理汇总了Python中charmhelpers.contrib.openstack.context.ApacheSSLContext方法的典型用法代码示例。如果您正苦于以下问题:Python context.ApacheSSLContext方法的具体用法?Python context.ApacheSSLContext怎么用?Python context.ApacheSSLContext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在charmhelpers.contrib.openstack.context的用法示例。


在下文中一共展示了context.ApacheSSLContext方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __call__

# 需要导入模块: from charmhelpers.contrib.openstack import context [as 别名]
# 或者: from charmhelpers.contrib.openstack.context import ApacheSSLContext [as 别名]
def __call__(self):
        # late import to work around circular dependency
        from keystone_utils import (
            determine_ports,
            update_hash_from_path,
        )

        ssl_paths = [CA_CERT_PATH, self.ssl_dir]

        self.external_ports = determine_ports()
        before = hashlib.sha256()
        for path in ssl_paths:
            update_hash_from_path(before, path)

        ret = super(ApacheSSLContext, self).__call__()

        after = hashlib.sha256()
        for path in ssl_paths:
            update_hash_from_path(after, path)

        # Ensure that apache2 is restarted if these change
        if before.hexdigest() != after.hexdigest():
            service_restart('apache2')

        return ret 
开发者ID:openstack,项目名称:charm-keystone,代码行数:27,代码来源:keystone_context.py

示例2: test_https_configure_cert

# 需要导入模块: from charmhelpers.contrib.openstack import context [as 别名]
# 或者: from charmhelpers.contrib.openstack.context import ApacheSSLContext [as 别名]
def test_https_configure_cert(self):
        '''Test apache2 properly installs certs and keys to disk'''
        self.get_cert.return_value = ('SSL_CERT', 'SSL_KEY')
        self.b64decode.side_effect = [b'SSL_CERT', b'SSL_KEY']
        apache = context.ApacheSSLContext()
        apache.service_namespace = 'cinder'
        apache.configure_cert('test-cn')
        # appropriate directories are created.
        self.mkdir.assert_called_with(path='/etc/apache2/ssl/cinder')
        # appropriate files are written.
        files = [call(path='/etc/apache2/ssl/cinder/cert_test-cn',
                      content=b'SSL_CERT'),
                 call(path='/etc/apache2/ssl/cinder/key_test-cn',
                      content=b'SSL_KEY')]
        self.write_file.assert_has_calls(files)
        # appropriate bits are b64decoded.
        decode = [call('SSL_CERT'), call('SSL_KEY')]
        self.assertEquals(decode, self.b64decode.call_args_list) 
开发者ID:juju,项目名称:charm-helpers,代码行数:20,代码来源:test_os_contexts.py

示例3: test_https_configure_cert_deprecated

# 需要导入模块: from charmhelpers.contrib.openstack import context [as 别名]
# 或者: from charmhelpers.contrib.openstack.context import ApacheSSLContext [as 别名]
def test_https_configure_cert_deprecated(self):
        '''Test apache2 properly installs certs and keys to disk'''
        self.get_cert.return_value = ('SSL_CERT', 'SSL_KEY')
        self.b64decode.side_effect = ['SSL_CERT', 'SSL_KEY']
        apache = context.ApacheSSLContext()
        apache.service_namespace = 'cinder'
        apache.configure_cert()
        # appropriate directories are created.
        self.mkdir.assert_called_with(path='/etc/apache2/ssl/cinder')
        # appropriate files are written.
        files = [call(path='/etc/apache2/ssl/cinder/cert',
                      content='SSL_CERT'),
                 call(path='/etc/apache2/ssl/cinder/key',
                      content='SSL_KEY')]
        self.write_file.assert_has_calls(files)
        # appropriate bits are b64decoded.
        decode = [call('SSL_CERT'), call('SSL_KEY')]
        self.assertEquals(decode, self.b64decode.call_args_list) 
开发者ID:juju,项目名称:charm-helpers,代码行数:20,代码来源:test_os_contexts.py

示例4: test_apache_get_addresses_no_network_config

# 需要导入模块: from charmhelpers.contrib.openstack import context [as 别名]
# 或者: from charmhelpers.contrib.openstack.context import ApacheSSLContext [as 别名]
def test_apache_get_addresses_no_network_config(self):
        self.config.side_effect = fake_config({
            'os-internal-network': None,
            'os-admin-network': None,
            'os-public-network': None
        })
        self.resolve_address.return_value = '10.5.1.50'
        self.unit_get.return_value = '10.5.1.50'

        apache = context.ApacheSSLContext()
        apache.external_ports = '8776'

        addresses = apache.get_network_addresses()
        expected = [('10.5.1.50', '10.5.1.50')]

        self.assertEqual(addresses, expected)

        self.get_address_in_network.assert_not_called()
        self.resolve_address.assert_has_calls([
            call(context.INTERNAL),
            call(context.ADMIN),
            call(context.PUBLIC)
        ]) 
开发者ID:juju,项目名称:charm-helpers,代码行数:25,代码来源:test_os_contexts.py

示例5: test_apache_get_addresses_network_spaces

# 需要导入模块: from charmhelpers.contrib.openstack import context [as 别名]
# 或者: from charmhelpers.contrib.openstack.context import ApacheSSLContext [as 别名]
def test_apache_get_addresses_network_spaces(self):
        self.config.side_effect = fake_config({
            'os-internal-network': None,
            'os-admin-network': None,
            'os-public-network': None
        })
        self.network_get_primary_address.side_effect = None
        self.network_get_primary_address.return_value = '10.5.2.50'
        self.resolve_address.return_value = '10.5.2.100'
        self.unit_get.return_value = '10.5.1.50'

        apache = context.ApacheSSLContext()
        apache.external_ports = '8776'

        addresses = apache.get_network_addresses()
        expected = [('10.5.2.50', '10.5.2.100')]

        self.assertEqual(addresses, expected)

        self.get_address_in_network.assert_not_called()
        self.resolve_address.assert_has_calls([
            call(context.INTERNAL),
            call(context.ADMIN),
            call(context.PUBLIC)
        ]) 
开发者ID:juju,项目名称:charm-helpers,代码行数:27,代码来源:test_os_contexts.py

示例6: __call__

# 需要导入模块: from charmhelpers.contrib.openstack import context [as 别名]
# 或者: from charmhelpers.contrib.openstack.context import ApacheSSLContext [as 别名]
def __call__(self):
        # late import to work around circular dependency
        from neutron_api_utils import determine_ports
        self.external_ports = determine_ports()
        return super(ApacheSSLContext, self).__call__() 
开发者ID:openstack,项目名称:charm-neutron-api,代码行数:7,代码来源:neutron_api_context.py

示例7: __call__

# 需要导入模块: from charmhelpers.contrib.openstack import context [as 别名]
# 或者: from charmhelpers.contrib.openstack.context import ApacheSSLContext [as 别名]
def __call__(self):
        self.external_ports = [config('port')]
        return super(ApacheSSLContext, self).__call__() 
开发者ID:openstack,项目名称:charm-ceph-radosgw,代码行数:5,代码来源:ceph_radosgw_context.py

示例8: __call__

# 需要导入模块: from charmhelpers.contrib.openstack import context [as 别名]
# 或者: from charmhelpers.contrib.openstack.context import ApacheSSLContext [as 别名]
def __call__(self):
        # late import to work around circular dependency
        from keystone_utils import (
            determine_ports,
            update_hash_from_path,
        )

        ssl_paths = [CA_CERT_PATH,
                     os.path.join('/etc/apache2/ssl/',
                                  self.service_namespace)]

        self.external_ports = determine_ports()
        before = hashlib.sha256()
        for path in ssl_paths:
            update_hash_from_path(before, path)

        ret = super(ApacheSSLContext, self).__call__()

        after = hashlib.sha256()
        for path in ssl_paths:
            update_hash_from_path(after, path)

        # Ensure that apache2 is restarted if these change
        if before.hexdigest() != after.hexdigest():
            service_restart('apache2')

        return ret 
开发者ID:konono,项目名称:equlipse,代码行数:29,代码来源:keystone_context.py

示例9: test_https_context_with_no_https

# 需要导入模块: from charmhelpers.contrib.openstack import context [as 别名]
# 或者: from charmhelpers.contrib.openstack.context import ApacheSSLContext [as 别名]
def test_https_context_with_no_https(self):
        '''Test apache2 https when no https data available'''
        apache = context.ApacheSSLContext()
        self.https.return_value = False
        self.assertEquals({}, apache()) 
开发者ID:juju,项目名称:charm-helpers,代码行数:7,代码来源:test_os_contexts.py

示例10: _https_context_setup

# 需要导入模块: from charmhelpers.contrib.openstack import context [as 别名]
# 或者: from charmhelpers.contrib.openstack.context import ApacheSSLContext [as 别名]
def _https_context_setup(self):
        '''
        Helper for test_https_context* tests.

        '''
        self.https.return_value = True
        self.determine_api_port.return_value = 8756
        self.determine_apache_port.return_value = 8766

        apache = context.ApacheSSLContext()
        apache.configure_cert = MagicMock()
        apache.enable_modules = MagicMock()
        apache.configure_ca = MagicMock()
        apache.canonical_names = MagicMock()
        apache.canonical_names.return_value = [
            '10.5.1.1',
            '10.5.2.1',
            '10.5.3.1',
        ]
        apache.get_network_addresses = MagicMock()
        apache.get_network_addresses.return_value = [
            ('10.5.1.100', '10.5.1.1'),
            ('10.5.2.100', '10.5.2.1'),
            ('10.5.3.100', '10.5.3.1'),
        ]
        apache.external_ports = '8776'
        apache.service_namespace = 'cinder'

        ex = {
            'namespace': 'cinder',
            'endpoints': [('10.5.1.100', '10.5.1.1', 8766, 8756),
                          ('10.5.2.100', '10.5.2.1', 8766, 8756),
                          ('10.5.3.100', '10.5.3.1', 8766, 8756)],
            'ext_ports': [8766]
        }

        return apache, ex 
开发者ID:juju,项目名称:charm-helpers,代码行数:39,代码来源:test_os_contexts.py

示例11: test_https_context_loads_correct_apache_mods

# 需要导入模块: from charmhelpers.contrib.openstack import context [as 别名]
# 或者: from charmhelpers.contrib.openstack.context import ApacheSSLContext [as 别名]
def test_https_context_loads_correct_apache_mods(self):
        '''Test apache2 context also loads required apache modules'''
        apache = context.ApacheSSLContext()
        apache.enable_modules()
        ex_cmd = ['a2enmod', 'ssl', 'proxy', 'proxy_http', 'headers']
        self.check_call.assert_called_with(ex_cmd) 
开发者ID:juju,项目名称:charm-helpers,代码行数:8,代码来源:test_os_contexts.py

示例12: test_apache_get_addresses_with_network_config

# 需要导入模块: from charmhelpers.contrib.openstack import context [as 别名]
# 或者: from charmhelpers.contrib.openstack.context import ApacheSSLContext [as 别名]
def test_apache_get_addresses_with_network_config(self):
        self.config.side_effect = fake_config({
            'os-internal-network': '10.5.1.0/24',
            'os-admin-network': '10.5.2.0/24',
            'os-public-network': '10.5.3.0/24',
        })
        _base_addresses = ['10.5.1.100',
                           '10.5.2.100',
                           '10.5.3.100']
        self.get_address_in_network.side_effect = _base_addresses
        self.resolve_address.side_effect = _base_addresses
        self.unit_get.return_value = '10.5.1.50'

        apache = context.ApacheSSLContext()

        addresses = apache.get_network_addresses()
        expected = [('10.5.1.100', '10.5.1.100'),
                    ('10.5.2.100', '10.5.2.100'),
                    ('10.5.3.100', '10.5.3.100')]
        self.assertEqual(addresses, expected)

        calls = [call('10.5.1.0/24', '10.5.1.50'),
                 call('10.5.2.0/24', '10.5.1.50'),
                 call('10.5.3.0/24', '10.5.1.50')]
        self.get_address_in_network.assert_has_calls(calls)
        self.resolve_address.assert_has_calls([
            call(context.INTERNAL),
            call(context.ADMIN),
            call(context.PUBLIC)
        ]) 
开发者ID:juju,项目名称:charm-helpers,代码行数:32,代码来源:test_os_contexts.py


注:本文中的charmhelpers.contrib.openstack.context.ApacheSSLContext方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。