本文整理匯總了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)