本文整理汇总了Python中stratuslab.Util.execute方法的典型用法代码示例。如果您正苦于以下问题:Python Util.execute方法的具体用法?Python Util.execute怎么用?Python Util.execute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类stratuslab.Util
的用法示例。
在下文中一共展示了Util.execute方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _execute
# 需要导入模块: from stratuslab import Util [as 别名]
# 或者: from stratuslab.Util import execute [as 别名]
def _execute(self, command):
if self.verboseLevel <= Util.VERBOSE_LEVEL_NORMAL:
devNull = open(os.path.devnull, 'w')
ret = Util.execute(command, stdout=devNull, stderr=devNull)
devNull.close()
else:
ret = Util.execute(command)
return ret
示例2: _configure
# 需要导入模块: from stratuslab import Util [as 别名]
# 或者: from stratuslab.Util import execute [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: _executeExitOnError
# 需要导入模块: from stratuslab import Util [as 别名]
# 或者: from stratuslab.Util import execute [as 别名]
def _executeExitOnError(self, cmd_str):
rc, output = Util.execute(cmd_str.split(' '),
withOutput=True,
verboseLevel=self.verboseLevel,
verboseThreshold=Util.VERBOSE_LEVEL_DETAILED)
if rc != 0:
printError('Failed running: %s\n%s' % (cmd_str, output))
示例4: validate
# 需要导入模块: from stratuslab import Util [as 别名]
# 或者: from stratuslab.Util import execute [as 别名]
def validate(self):
jarLocation = self._findJar()
javaMainArgs = ' ' + self.manifestFile
cmd = os.path.join('java -cp %s %s' % (jarLocation, 'eu.stratuslab.marketplace.metadata.CheckMetadata'))
cmd += javaMainArgs
self._printCalling(cmd)
return Util.execute(cmd.split(' '))
示例5: testExecuteWithOutput
# 需要导入模块: from stratuslab import Util [as 别名]
# 或者: from stratuslab.Util import execute [as 别名]
def testExecuteWithOutput(self):
output = Util.execute('ls -l'.split(), withOutput=True)
self.assertEqual(type(output), tuple)
self.assertEqual(len(output), 2)
self.assertTrue(isinstance(output[1], basestring))
assert len(output[1]) >= 1
示例6: _sign
# 需要导入模块: from stratuslab import Util [as 别名]
# 或者: from stratuslab.Util import execute [as 别名]
def _sign(self):
jarLocation = self._findJar()
self.printDetail('Signature jar file: %s' % jarLocation)
javaMainArgs = ' ' + self.manifestFile + ' ' + self.tempManifestFile + \
' ' + self.p12Certificate + ' ' + self.p12Password + \
' ' + self.email
cmd = os.path.join('java -cp %s %s' % (jarLocation, 'eu.stratuslab.marketplace.metadata.SignMetadata'))
cmd += javaMainArgs
self._printCalling(cmd)
return Util.execute(cmd.split(' '),withOutput=True)
示例7: _installPackages
# 需要导入模块: from stratuslab import Util [as 别名]
# 或者: from stratuslab.Util import execute [as 别名]
def _installPackages(self):
Util.printStep('Setting up Couchbase yum repository')
cmd = 'curl --output %s %s' % (self._repofile, self._repourl)
self._executeExitOnError(cmd)
Util.printStep('Removing Couchbase python client')
try:
cmd = 'pip uninstall -y couchbase'
rc, output = Util.execute(cmd.split(' '),
withOutput=True,
verboseLevel=self.verboseLevel,
verboseThreshold=Util.VERBOSE_LEVEL_DETAILED)
if rc != 0:
Util.printInfo('Couchbase python client NOT removed')
else:
Util.printInfo('Couchbase python client removed')
except:
Util.printInfo("Couchbase python client NOT removed")
Util.printStep('Removing Couchbase C client')
cmd = 'yum erase -y %s' % ' '.join(self._pkgs)
self._executeExitOnError(cmd)
Util.printStep('Installing Couchbase C client')
cmd = 'yum install -y %s' % ' '.join(self._pkgs)
self._executeExitOnError(cmd)
Util.printStep('Installing Couchbase python client dependencies')
cmd = 'yum install -y %s' % ' '.join(self._deps)
self._executeExitOnError(cmd)
Util.printStep('Upgrading pip for Couchbase python client')
cmd = 'pip install --upgrade pip'
self._executeExitOnError(cmd)
Util.printStep('Installing Couchbase python client')
cmd = 'pip install couchbase'
self._executeExitOnError(cmd)
示例8: _installPackages
# 需要导入模块: from stratuslab import Util [as 别名]
# 或者: from stratuslab.Util import execute [as 别名]
def _installPackages(self):
Util.printStep("Setting up Couchbase yum repository")
cmd = "curl --output %s %s" % (self._repofile, self._repourl)
self._executeExitOnError(cmd)
Util.printStep("Removing Couchbase python client")
try:
cmd = "pip uninstall -y couchbase"
rc, output = Util.execute(
cmd.split(" "),
withOutput=True,
verboseLevel=self.verboseLevel,
verboseThreshold=Util.VERBOSE_LEVEL_DETAILED,
)
if rc != 0:
Util.printInfo("Couchbase python client NOT removed")
else:
Util.printInfo("Couchbase python client removed")
except:
Util.printInfo("Couchbase python client NOT removed")
Util.printStep("Removing Couchbase C client")
cmd = "yum erase -y %s" % " ".join(self._pkgs)
self._executeExitOnError(cmd)
Util.printStep("Installing Couchbase C client")
cmd = "yum install -y %s" % " ".join(self._pkgs)
self._executeExitOnError(cmd)
Util.printStep("Installing Couchbase python client dependencies")
cmd = "yum install -y %s" % " ".join(self._deps)
self._executeExitOnError(cmd)
Util.printStep("Installing Couchbase python client")
cmd = "pip install couchbase"
self._executeExitOnError(cmd)
示例9: _localCleanUp
# 需要导入模块: from stratuslab import Util [as 别名]
# 或者: from stratuslab.Util import execute [as 别名]
def _localCleanUp(self):
Util.execute(['rm', '-rf', self.manifestLocalFileName])
示例10: _restartService
# 需要导入模块: from stratuslab import Util [as 别名]
# 或者: from stratuslab.Util import execute [as 别名]
def _restartService(self):
Util.printStep('Adding %s to chkconfig and restarting' % self._serviceName)
cmd = 'chkconfig --add %s' % self._serviceName
Util.execute(cmd.split(' '))
cmd = 'service %s restart' % self._serviceName
Util.execute(cmd.split(' '))
示例11: _getVnetInfoXml
# 需要导入模块: from stratuslab import Util [as 别名]
# 或者: from stratuslab.Util import execute [as 别名]
def _getVnetInfoXml(vnet_name):
rc, output = Util.execute(["onevnet", "show", "--xml", vnet_name], withOutput=True)
if rc != 0:
raise ExecutionException("Couldn't get network info for network '%s'." % vnet_name)
return output
示例12: _restartService
# 需要导入模块: from stratuslab import Util [as 别名]
# 或者: from stratuslab.Util import execute [as 别名]
def _restartService(self, service):
Util.printStep("Adding registration service to chkconfig and restarting")
cmd = 'chkconfig --add %s' % service
Util.execute(cmd.split(' '))
cmd = 'service %s restart' % service
Util.execute(cmd.split(' '))