本文整理匯總了Python中charmhelpers.contrib.openstack.templating.OSConfigRenderer方法的典型用法代碼示例。如果您正苦於以下問題:Python templating.OSConfigRenderer方法的具體用法?Python templating.OSConfigRenderer怎麽用?Python templating.OSConfigRenderer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類charmhelpers.contrib.openstack.templating
的用法示例。
在下文中一共展示了templating.OSConfigRenderer方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_register_configs
# 需要導入模塊: from charmhelpers.contrib.openstack import templating [as 別名]
# 或者: from charmhelpers.contrib.openstack.templating import OSConfigRenderer [as 別名]
def test_register_configs(self):
class _mock_OSConfigRenderer():
def __init__(self, templates_dir=None, openstack_release=None):
self.configs = []
self.ctxts = []
def register(self, config, ctxt):
self.configs.append(config)
self.ctxts.append(ctxt)
self.os_release.return_value = 'trusty'
templating.OSConfigRenderer.side_effect = _mock_OSConfigRenderer
_regconfs = nutils.register_configs()
confs = [nutils.PG_CONF,
nutils.PG_HN_CONF,
nutils.PG_HS_CONF,
nutils.PG_IFCS_CONF,
nutils.OPS_CONF]
self.assertItemsEqual(_regconfs.configs, confs)
示例2: assess_status_func
# 需要導入模塊: from charmhelpers.contrib.openstack import templating [as 別名]
# 或者: from charmhelpers.contrib.openstack.templating import OSConfigRenderer [as 別名]
def assess_status_func(configs, check_services=None):
"""Helper function to create the function that will assess_status() for
the unit.
Uses charmhelpers.contrib.openstack.utils.make_assess_status_func() to
create the appropriate status function and then returns it.
Used directly by assess_status() and also for pausing and resuming
the unit.
NOTE(ajkavanagh) ports are not checked due to race hazards with services
that don't behave sychronously w.r.t their service scripts. e.g.
apache2.
@param configs: a templating.OSConfigRenderer() object
@param check_services: a list of services to check. If None, then
services() is used instead. To not check services pass an empty list.
@return f() -> None : a function that assesses the unit's workload status
"""
if check_services is None:
check_services = services()
required_interfaces = {}
if relation_ids('identity-service'):
required_interfaces['identity'] = ['identity-service']
return make_assess_status_func(
configs, required_interfaces,
charm_func=customer_check_assess_status,
services=check_services, ports=None)
示例3: register_configs
# 需要導入模塊: from charmhelpers.contrib.openstack import templating [as 別名]
# 或者: from charmhelpers.contrib.openstack.templating import OSConfigRenderer [as 別名]
def register_configs():
release = os_release('heat-common')
configs = templating.OSConfigRenderer(templates_dir=TEMPLATES,
openstack_release=release)
confs = [HEAT_CONF, HEAT_API_PASTE, HAPROXY_CONF, ADMIN_OPENRC]
for conf in confs:
configs.register(conf, CONFIG_FILES[conf]['contexts'])
if os.path.exists('/etc/apache2/conf-available'):
configs.register(HTTPS_APACHE_24_CONF,
CONFIG_FILES[HTTPS_APACHE_24_CONF]['contexts'])
else:
configs.register(HTTPS_APACHE_CONF,
CONFIG_FILES[HTTPS_APACHE_CONF]['contexts'])
if enable_memcache(release=release):
configs.register(MEMCACHED_CONF,
CONFIG_FILES[MEMCACHED_CONF]['hook_contexts'])
return configs
示例4: assess_status_func
# 需要導入模塊: from charmhelpers.contrib.openstack import templating [as 別名]
# 或者: from charmhelpers.contrib.openstack.templating import OSConfigRenderer [as 別名]
def assess_status_func(configs):
"""Helper function to create the function that will assess_status() for
the unit.
Uses charmhelpers.contrib.openstack.utils.make_assess_status_func() to
create the appropriate status function and then returns it.
Used directly by assess_status() and also for pausing and resuming
the unit.
NOTE: REQUIRED_INTERFACES is augmented with the optional interfaces
depending on the current config before being passed to the
make_assess_status_func() function.
@param configs: a templating.OSConfigRenderer() object
@return f() -> None : a function that assesses the unit's workload status
"""
required_interfaces = REQUIRED_INTERFACES.copy()
required_interfaces.update(get_optional_interfaces())
return make_assess_status_func(
configs, required_interfaces,
charm_func=check_optional_relations,
services=services(),
ports=determine_ports())
示例5: assess_status_func
# 需要導入模塊: from charmhelpers.contrib.openstack import templating [as 別名]
# 或者: from charmhelpers.contrib.openstack.templating import OSConfigRenderer [as 別名]
def assess_status_func(configs):
"""Helper function to create the function that will assess_status() for
the unit.
Uses charmhelpers.contrib.openstack.utils.make_assess_status_func() to
create the appropriate status function and then returns it.
Used directly by assess_status() and also for pausing and resuming
the unit.
NOTE: REQUIRED_INTERFACES is augmented with the optional interfaces
depending on the current config before being passed to the
make_assess_status_func() function.
NOTE(ajkavanagh) ports are not checked due to race hazards with services
that don't behave sychronously w.r.t their service scripts. e.g.
apache2.
@param configs: a templating.OSConfigRenderer() object
@return f() -> None : a function that assesses the unit's workload status
"""
required_interfaces = REQUIRED_INTERFACES.copy()
required_interfaces.update(get_optional_interfaces())
return make_assess_status_func(
configs, required_interfaces,
charm_func=check_optional_relations,
services=services(), ports=None)
示例6: register_configs
# 需要導入模塊: from charmhelpers.contrib.openstack import templating [as 別名]
# 或者: from charmhelpers.contrib.openstack.templating import OSConfigRenderer [as 別名]
def register_configs():
'''
Returns an OSTemplateRenderer object with all required configs registered.
'''
release = os_release('nova-common')
configs = templating.OSConfigRenderer(templates_dir=TEMPLATES,
openstack_release=release)
if relation_ids('ceph'):
# Add charm ceph configuration to resources and
# ensure directory actually exists
mkdir(os.path.dirname(ceph_config_file()))
mkdir(os.path.dirname(CEPH_CONF))
# Install ceph config as an alternative for co-location with
# ceph and ceph-osd charms - nova-compute ceph.conf will be
# lower priority that both of these but thats OK
if not os.path.exists(ceph_config_file()):
# touch file for pre-templated generation
open(ceph_config_file(), 'w').close()
install_alternative(os.path.basename(CEPH_CONF),
CEPH_CONF, ceph_config_file())
for cfg, d in resource_map().items():
configs.register(cfg, d['contexts'])
return configs
示例7: assess_status_func
# 需要導入模塊: from charmhelpers.contrib.openstack import templating [as 別名]
# 或者: from charmhelpers.contrib.openstack.templating import OSConfigRenderer [as 別名]
def assess_status_func(configs):
"""Helper function to create the function that will assess_status() for
the unit.
Uses charmhelpers.contrib.openstack.utils.make_assess_status_func() to
create the appropriate status function and then returns it.
Used directly by assess_status() and also for pausing and resuming
the unit.
NOTE(ajkavanagh) ports are not checked due to race hazards with services
that don't behave sychronously w.r.t their service scripts. e.g.
apache2.
@param configs: a templating.OSConfigRenderer() object
@return f() -> None : a function that assesses the unit's workload status
"""
required_interfaces = REQUIRED_INTERFACES.copy()
required_interfaces.update(get_optional_relations())
return make_assess_status_func(
configs, required_interfaces,
services=services(), ports=None)
示例8: test_register_configs
# 需要導入模塊: from charmhelpers.contrib.openstack import templating [as 別名]
# 或者: from charmhelpers.contrib.openstack.templating import OSConfigRenderer [as 別名]
def test_register_configs(self, mock_path_exists):
self.os_release.return_value = 'havana'
mock_path_exists.return_value = False
class _mock_OSConfigRenderer():
def __init__(self, templates_dir=None, openstack_release=None):
self.configs = []
self.ctxts = []
def register(self, config, ctxt):
self.configs.append(config)
self.ctxts.append(ctxt)
templating.OSConfigRenderer.side_effect = _mock_OSConfigRenderer
_regconfs = nutils.register_configs()
confs = ['/etc/neutron/neutron.conf',
'/etc/neutron/api-paste.ini',
'/etc/default/neutron-server',
'/etc/neutron/plugins/ml2/ml2_conf.ini',
'/etc/apache2/sites-available/openstack_https_frontend',
'/etc/haproxy/haproxy.cfg']
self.assertEqual(sorted(_regconfs.configs), sorted(confs))
示例9: assess_status_func
# 需要導入模塊: from charmhelpers.contrib.openstack import templating [as 別名]
# 或者: from charmhelpers.contrib.openstack.templating import OSConfigRenderer [as 別名]
def assess_status_func(configs):
"""Helper function to create the function that will assess_status() for
the unit.
Uses charmhelpers.contrib.openstack.utils.make_assess_status_func() to
create the appropriate status function and then returns it.
Used directly by assess_status() and also for pausing and resuming
the unit.
NOTE: REQUIRED_INTERFACES is augmented with the optional interfaces
depending on the current config before being passed to the
make_assess_status_func() function.
NOTE(ajkavanagh) ports are not checked due to race hazards with services
that don't behave sychronously w.r.t their service scripts. e.g.
apache2.
@param configs: a templating.OSConfigRenderer() object
@return f() -> None : a function that assesses the unit's workload status
"""
required_interfaces = REQUIRED_INTERFACES.copy()
required_interfaces.update(get_optional_interfaces())
return make_assess_status_func(
configs, required_interfaces,
charm_func=check_optional_relations,
services=services(), ports=None)
示例10: do_openstack_upgrade
# 需要導入模塊: from charmhelpers.contrib.openstack import templating [as 別名]
# 或者: from charmhelpers.contrib.openstack.templating import OSConfigRenderer [as 別名]
def do_openstack_upgrade(configs):
"""
Perform an upgrade. Takes care of upgrading packages, rewriting
configs, database migrations and potentially any other post-upgrade
actions.
:param configs: The charms main OSConfigRenderer object.
"""
new_src = config('openstack-origin')
new_os_rel = get_os_codename_install_source(new_src)
log('Performing OpenStack upgrade to %s.' % (new_os_rel))
configure_installation_source(new_src)
dpkg_opts = [
'--option', 'Dpkg::Options::=--force-confnew',
'--option', 'Dpkg::Options::=--force-confdef',
]
apt_update(fatal=True)
apt_upgrade(options=dpkg_opts, fatal=True, dist=True)
reset_os_release()
apt_install(determine_packages(), fatal=True)
# set CONFIGS to load templates from new release
configs.set_release(openstack_release=new_os_rel)
示例11: assess_status_func
# 需要導入模塊: from charmhelpers.contrib.openstack import templating [as 別名]
# 或者: from charmhelpers.contrib.openstack.templating import OSConfigRenderer [as 別名]
def assess_status_func(configs):
"""Helper function to create the function that will assess_status() for
the unit.
Uses charmhelpers.contrib.openstack.utils.make_assess_status_func() to
create the appropriate status function and then returns it.
Used directly by assess_status() and also for pausing and resuming
the unit.
NOTE(ajkavanagh) ports are not checked due to race hazards with services
that don't behave sychronously w.r.t their service scripts. e.g.
apache2.
@param configs: a templating.OSConfigRenderer() object
@return f() -> None : a function that assesses the unit's workload status
"""
return make_assess_status_func(
configs, REQUIRED_INTERFACES,
services=services(), ports=None)
示例12: test_register_configs
# 需要導入模塊: from charmhelpers.contrib.openstack import templating [as 別名]
# 或者: from charmhelpers.contrib.openstack.templating import OSConfigRenderer [as 別名]
def test_register_configs(self, _use_dvr):
class _mock_OSConfigRenderer():
def __init__(self, templates_dir=None, openstack_release=None):
self.configs = []
self.ctxts = []
def register(self, config, ctxt):
self.configs.append(config)
self.ctxts.append(ctxt)
_use_dvr.return_value = False
self.os_release.return_value = 'icehouse'
self.lsb_release.return_value = {'DISTRIB_CODENAME': 'precise'}
templating.OSConfigRenderer.side_effect = _mock_OSConfigRenderer
_regconfs = nutils.register_configs()
confs = ['/etc/neutron/neutron.conf',
'/etc/neutron/plugins/ml2/ml2_conf.ini',
'/etc/default/openvswitch-switch',
'/etc/init/os-charm-phy-nic-mtu.conf']
self.assertEqual(_regconfs.configs, confs)
示例13: test_register_configs_mitaka
# 需要導入模塊: from charmhelpers.contrib.openstack import templating [as 別名]
# 或者: from charmhelpers.contrib.openstack.templating import OSConfigRenderer [as 別名]
def test_register_configs_mitaka(self, _use_dvr):
class _mock_OSConfigRenderer():
def __init__(self, templates_dir=None, openstack_release=None):
self.configs = []
self.ctxts = []
def register(self, config, ctxt):
self.configs.append(config)
self.ctxts.append(ctxt)
_use_dvr.return_value = False
self.os_release.return_value = 'mitaka'
self.lsb_release.return_value = {'DISTRIB_CODENAME': 'trusty'}
templating.OSConfigRenderer.side_effect = _mock_OSConfigRenderer
_regconfs = nutils.register_configs()
confs = ['/etc/neutron/neutron.conf',
'/etc/neutron/plugins/ml2/openvswitch_agent.ini',
'/etc/default/openvswitch-switch',
'/etc/init/os-charm-phy-nic-mtu.conf']
self.assertEqual(_regconfs.configs, confs)
示例14: assess_status_func
# 需要導入模塊: from charmhelpers.contrib.openstack import templating [as 別名]
# 或者: from charmhelpers.contrib.openstack.templating import OSConfigRenderer [as 別名]
def assess_status_func(configs):
"""Helper function to create the function that will assess_status() for
the unit.
Uses charmhelpers.contrib.openstack.utils.make_assess_status_func() to
create the appropriate status function and then returns it.
Used directly by assess_status() and also for pausing and resuming
the unit.
Note that required_interfaces is augmented with neutron-plugin-api if the
nova_metadata is enabled.
NOTE(ajkavanagh) ports are not checked due to race hazards with services
that don't behave sychronously w.r.t their service scripts. e.g.
apache2.
@param configs: a templating.OSConfigRenderer() object
@return f() -> None : a function that assesses the unit's workload status
"""
required_interfaces = REQUIRED_INTERFACES.copy()
if enable_nova_metadata():
required_interfaces['neutron-plugin-api'] = ['neutron-plugin-api']
return make_assess_status_func(
configs, required_interfaces,
services=services(), ports=None)
示例15: test_register_configs
# 需要導入模塊: from charmhelpers.contrib.openstack import templating [as 別名]
# 或者: from charmhelpers.contrib.openstack.templating import OSConfigRenderer [as 別名]
def test_register_configs(self):
class _mock_OSConfigRenderer():
def __init__(self, templates_dir=None, openstack_release=None):
self.configs = []
self.ctxts = []
def register(self, config, ctxt):
self.configs.append(config)
self.ctxts.append(ctxt)
self.os_release.return_value = 'trusty'
templating.OSConfigRenderer.side_effect = _mock_OSConfigRenderer
_regconfs = nutils.register_configs()
confs = ['/etc/sudoers.d/neutron_sudoers',
'/etc/neutron/plugins/plumgrid/plumlib.ini',
'/etc/neutron/plugins/plumgrid/pgrc']
self.assertItemsEqual(_regconfs.configs, confs)