本文整理汇总了Python中stratuslab.Util.appendOrReplaceMultilineBlockInFile方法的典型用法代码示例。如果您正苦于以下问题:Python Util.appendOrReplaceMultilineBlockInFile方法的具体用法?Python Util.appendOrReplaceMultilineBlockInFile怎么用?Python Util.appendOrReplaceMultilineBlockInFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类stratuslab.Util
的用法示例。
在下文中一共展示了Util.appendOrReplaceMultilineBlockInFile方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _configureNetworkInterface
# 需要导入模块: from stratuslab import Util [as 别名]
# 或者: from stratuslab.Util import appendOrReplaceMultilineBlockInFile [as 别名]
def _configureNetworkInterface(self, device, ip, netmask):
data = """auto %s
iface %s inet static
address %s
netmask %s
pre-up iptables-restore < %s""" % (device, device, ip, netmask,
self.FILE_FIREWALL_RULES)
Util.appendOrReplaceMultilineBlockInFile(self.FILE_INTERFACES, data)
示例2: _configure
# 需要导入模块: from stratuslab import Util [as 别名]
# 或者: from stratuslab.Util import appendOrReplaceMultilineBlockInFile [as 别名]
def _configure(self):
Util.printStep('Configuring OpenLDAP server')
Util.printStep('Updating sysconfig')
shutil.copyfile(self._sysconfigLdapTemplate, self._sysconfigLdap)
Util.appendOrReplaceInFile(self._sysconfigLdap, 'SLAPD_LDAP=', 'SLAPD_LDAP=yes')
Util.printStep('Setting root account access')
Util.appendOrReplaceMultilineBlockInFile(self._openLdapConfig,
self._accessValue,
start='olcAccess: {0}to *',
until='olcAddContentAcl:')
Util.printStep('(Re-)starting slapd')
cmd = 'service %s restart' % self._serviceName
self._executeExitOnError(cmd)
Util.printStep('Generating test certificate and moving into place')
self._executeExitOnError(self._testCertCmd)
self._executeExitOnError('mkdir -p /etc/openldap/cacerts')
self._executeExitOnError('mv -f cacrt.jks /etc/openldap/cacerts/cacrt.jks')
self._executeExitOnError('mv -f cacrt.pem /etc/openldap/cacerts/cacrt.pem')
self._executeExitOnError('mv -f serverkey.pem /etc/openldap/serverkey.pem')
self._executeExitOnError('mv -f servercrt.pem /etc/openldap/servercrt.pem')
os.chmod('/etc/openldap/serverkey.pem', stat.S_IRUSR | stat.S_IWUSR)
self._executeExitOnError('chown ldap:ldap /etc/openldap/serverkey.pem')
Util.printStep('Updating server config. for generated certs')
cmd = "ldapmodify -Y EXTERNAL -H ldapi:/// -f %s" % self._certConfigLdif
Util.execute(cmd.split(' '))
Util.printStep('Updating client config. for generated certs')
Util.appendOrReplaceInFile(self._ldapClientConfig,
'TLS_CACERT',
'TLS_CACERT /etc/openldap/cacerts/cacrt.pem')
Util.printStep('Creating o=cloud database')
Util.filePutContent(self._completeDatabaseTemplate,
Util.fileGetContent(self._databaseTemplate) % self.__dict__)
cmd = "ldapadd -Y EXTERNAL -H ldapi:/// -f %s" % self._completeDatabaseTemplate
Util.execute(cmd.split(' '))
Util.printStep('Adding cloud database entries')
cmd = "ldapadd -x -H ldaps://%s -D %s -w %s -f %s" % (self._nodename,
self._openLdapAdminDn,
self.openldapPassword,
self._cloudDatabaseSkeleton)
self._executeExitOnError(cmd)
示例3: _addOrReplaceCloudHook
# 需要导入模块: from stratuslab import Util [as 别名]
# 或者: from stratuslab.Util import appendOrReplaceMultilineBlockInFile [as 别名]
def _addOrReplaceCloudHook(self):
data = self._buildAddPortTranslationHook()
Util.appendOrReplaceMultilineBlockInFile(self.cloudConfigFilePath, data)
data = self._buildDeletePortTranslationHook()
Util.appendOrReplaceMultilineBlockInFile(self.cloudConfigFilePath, data)