本文整理汇总了Python中charmhelpers.contrib.hardening.harden.harden方法的典型用法代码示例。如果您正苦于以下问题:Python harden.harden方法的具体用法?Python harden.harden怎么用?Python harden.harden使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类charmhelpers.contrib.hardening.harden
的用法示例。
在下文中一共展示了harden.harden方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: install_percona_xtradb_cluster
# 需要导入模块: from charmhelpers.contrib.hardening import harden [as 别名]
# 或者: from charmhelpers.contrib.hardening.harden import harden [as 别名]
def install_percona_xtradb_cluster():
'''Attempt PXC install based on seeding of passwords for users'''
if pxc_installed():
log('MySQL already installed, skipping')
return
_root_password = root_password()
_sst_password = sst_password()
if not _root_password or not _sst_password:
log('Passwords not seeded, unable to install MySQL at this'
' point so deferring installation')
return
configure_mysql_root_password(_root_password)
apt_install(determine_packages(), fatal=True)
configure_sstuser(_sst_password)
if config('harden') and 'mysql' in config('harden'):
run_mysql_checks()
示例2: test_harden
# 需要导入模块: from charmhelpers.contrib.hardening import harden [as 别名]
# 或者: from charmhelpers.contrib.hardening.harden import harden [as 别名]
def test_harden(self, mock_host, mock_ssh, mock_mysql, mock_apache):
mock_host.__name__ = 'host'
mock_ssh.__name__ = 'ssh'
mock_mysql.__name__ = 'mysql'
mock_apache.__name__ = 'apache'
@harden.harden(overrides=['ssh', 'mysql'])
def foo(arg1, kwarg1=None):
return "done."
self.assertEqual(foo('anarg', kwarg1='akwarg'), "done.")
self.assertTrue(mock_ssh.called)
self.assertTrue(mock_mysql.called)
self.assertFalse(mock_apache.called)
self.assertFalse(mock_host.called)