本文整理汇总了Python中stratuslab.Util.printError方法的典型用法代码示例。如果您正苦于以下问题:Python Util.printError方法的具体用法?Python Util.printError怎么用?Python Util.printError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类stratuslab.Util
的用法示例。
在下文中一共展示了Util.printError方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _lcmStateToString
# 需要导入模块: from stratuslab import Util [as 别名]
# 或者: from stratuslab.Util import printError [as 别名]
def _lcmStateToString(self):
lcm = self._lcmStateAsInt()
if (lcm is not None) and (lcm >= 0) and (lcm < len(self.lcmStateDefintion)):
return self.lcmStateDefintion[lcm]
else:
Util.printError('Invalid state: %s' % lcm, exit=False)
return self.invalidState
示例2: _remoteFileAppendContents
# 需要导入模块: from stratuslab import Util [as 别名]
# 或者: from stratuslab.Util import printError [as 别名]
def _remoteFileAppendContents(self, filename, data):
data = Util.escapeDoubleQuotes(data, times=4)
rc, output = self._nodeShell('"echo \\"%s\\" >> %s"' % (data, filename),
withOutput=True, shell=True)
if rc != 0:
Util.printError("Failed to append to %s\n%s" % (filename, output))
示例3: getUidGidFromNode
# 需要导入模块: from stratuslab import Util [as 别名]
# 或者: from stratuslab.Util import printError [as 别名]
def getUidGidFromNode(user):
rc, output = self._nodeShell(getUidGidCmd % user,
withOutput=True)
if rc != 0:
Util.printError("Error getting '%s' user UID/GID from Node.\n%s" %
(user,output))
return _extractUidGidFromGetentPasswdOutput(output)
示例4: sign
# 需要导入模块: from stratuslab import Util [as 别名]
# 或者: from stratuslab.Util import printError [as 别名]
def sign(self):
res, output = self._sign()
if res:
Util.printError(output, exit=False)
self._cleanupTempFile()
else:
self._renameFiles()
return res
示例5: _startDhcp
# 需要导入模块: from stratuslab import Util [as 别名]
# 或者: from stratuslab.Util import printError [as 别名]
def _startDhcp(self):
Util.printDetail('(Re)Starting DHCP server.')
serviceName = self.packages['dhcp'].initdScriptName
rc = self.restartService(serviceName)
if rc != 0:
Util.printError('Failed to (re)start DHCP service.')
示例6: _installDhcp
# 需要导入模块: from stratuslab import Util [as 别名]
# 或者: from stratuslab.Util import printError [as 别名]
def _installDhcp(self):
Util.printDetail("Installing DHCP server.")
dhcpPackage = self.getPackageName("dhcp")
self.installPackages([dhcpPackage])
if not self.isPackageInstalled(dhcpPackage):
Util.printError("Failed to install %s." % dhcpPackage)
示例7: doWork
# 需要导入模块: from stratuslab import Util [as 别名]
# 或者: from stratuslab.Util import printError [as 别名]
def doWork(self):
configHolder = ConfigHolder(self.options.__dict__)
signator = Signator(self.manifestFile, configHolder)
isError = signator.sign()
if isError:
Util.printError('Error signing metadata file')
else:
Util.printDetail('Metadata file successfully signed: %s' % signator.outputManifestFile)
示例8: _getManifest
# 需要导入模块: from stratuslab import Util [as 别名]
# 或者: from stratuslab.Util import printError [as 别名]
def _getManifest(self, resourceUri):
url = MarketplaceUtil.metadataUrl(self.marketplaceEndpoint, resourceUri)
self._printDetail('Downloading from: %s' % url)
try:
return self.__getManifest(url)
except:
reason = ''.join(traceback.format_exception_only(*(sys.exc_info()[:2])))
Util.printError('Failed to get manifest for resource uri: %s. %s' % (url,
reason))
示例9: __getIpMacTuplesForNetworkType
# 需要导入模块: from stratuslab import Util [as 别名]
# 或者: from stratuslab.Util import printError [as 别名]
def __getIpMacTuplesForNetworkType(self, _type):
if _type not in self.NET_TYPES_DHCP:
Util.printError('Expected one of: %s. Got %s'%(','.join(self.NET_TYPES_DHCP),_type))
_type = _type.replace(_type[0], _type[0].lower(), 1)
ips = [x for x in getattr(self, '%sAddr'%_type).split()]
macs = [x for x in getattr(self, '%sMac'%_type).split()]
if len(ips) != len(macs):
Util.printError('%s network: number of IPs should match number of MACs.'%_type)
return zip(ips, macs)
示例10: _remoteAppendOrReplaceInFile
# 需要导入模块: from stratuslab import Util [as 别名]
# 或者: from stratuslab.Util import printError [as 别名]
def _remoteAppendOrReplaceInFile(self, filename, search, replace):
res = self._nodeShell(['grep', '"%s"'%search, filename])
replace = Util.escapeDoubleQuotes(replace)
if self._patternExists(res):
rc, output = self._nodeShell('"sed -i \'s|%s|%s|\' %s"' % (search, replace, filename),
withOutput=True, shell=True)
if rc != 0:
Util.printError("Failed to modify %s.\n%s" % (filename, output))
else:
self._remoteFileAppendContents(filename, replace)
示例11: _configureDbUser
# 需要导入模块: from stratuslab import Util [as 别名]
# 或者: from stratuslab.Util import printError [as 别名]
def _configureDbUser(self, username, password):
mysqlCommand = "/usr/bin/mysql -uroot -p%s" % self.oneDbRootPassword
userCreate = "CREATE USER '%s'@'localhost' IDENTIFIED BY '%s'" % (username, password)
userGrant = "GRANT CREATE, DROP, SELECT, INSERT, DELETE, UPDATE, INDEX ON opennebula.* TO '%s'@'localhost'" % username
rc, output = self._execute("%s -e \"%s\"" % (mysqlCommand, userCreate),
withOutput=True, shell=True)
if rc != 0:
Util.printWarning("Couldn't create user '%s'. Already exists?\n%s" % (username, output))
rc, output = self._execute("%s -e \"%s\"" % (mysqlCommand, userGrant),
withOutput=True, shell=True)
if rc != 0:
Util.printError("Error granting permission for user '%s'.\n%s" % (username, output))
示例12: _configureQemuUserOnFrontend
# 需要导入模块: from stratuslab import Util [as 别名]
# 或者: from stratuslab.Util import printError [as 别名]
def _configureQemuUserOnFrontend(self):
"""Add qemu user on Fronted with the same UID and GID as on the node
being configured. Add qemu user to 'cloud' group both on Frontend
and the node.
"""
if self.shareType != 'nfs':
return
user = group = 'qemu'
getUidGidCmd = "getent passwd %s"
Util.printDetail("Configuring '%s' user on Frontend as shared filesystem setup requested." % user)
def getUidGidFromNode(user):
rc, output = self._nodeShell(getUidGidCmd % user,
withOutput=True)
if rc != 0:
Util.printError("Error getting '%s' user UID/GID from Node.\n%s" %
(user,output))
return _extractUidGidFromGetentPasswdOutput(output)
def _extractUidGidFromGetentPasswdOutput(output):
uid, gid = output.split(':')[2:4] # uid, gid
if not all([uid, gid]):
Util.printError("Error extracting '%s' user UID/GID from output.\n%s" %
(user,output))
return uid, gid
uidNode, gidNode = getUidGidFromNode(user)
rc, output = self._executeWithOutput((getUidGidCmd % uidNode).split())
if rc == 0:
uidLocal, gidLocal = _extractUidGidFromGetentPasswdOutput(output)
Util.printDetail("User with UID:%s/GID:%s already configured on Frontend." %
(uidLocal, gidLocal), verboseLevel=self.verboseLevel)
if gidNode != gidLocal:
Util.printError("Frontend user '%s' GID:%s doesn't match GID:%s on Node %s." %
(gidLocal, user, gidNode, self.nodeAddr))
else:
self._execute(['groupadd', '-g', gidNode, '-r', group])
self._execute(['useradd', '-r', '-u', uidNode, '-g', group,
'-d', '/', '-s', '/sbin/nologin',
'-c', '"%s user"'%user, user])
# Instruct libvirt to run VMs with GID of ONE group.
self.appendOrReplaceInFileCmd(self.qemuConf, '^group.*$',
'group = "%s"' % self.oneGroup)
示例13: doWork
# 需要导入模块: from stratuslab import Util [as 别名]
# 或者: from stratuslab.Util import printError [as 别名]
def doWork(self):
configHolder = ConfigHolder(self.options.__dict__)
src = self._get_config_path()
dst = configHolder.configFile
if os.path.exists(dst) and not configHolder.force:
Util.printError(self.existingFileMsg % dst)
else:
try:
self._create_parent_dir(dst)
self._copy_config(src, dst)
Util.printDetail('wrote configuration file: %s' % dst)
except Exception as e:
Util.printError(e)
示例14: _installCAs
# 需要导入模块: from stratuslab import Util [as 别名]
# 或者: from stratuslab.Util import printError [as 别名]
def _installCAs(self):
packages = []
if self.certificateAuthorityPackages and self.certificateAuthorityRepo:
caPackages = map(lambda x: x.strip(), self.certificateAuthorityPackages.split(","))
packages.extend(caPackages)
repoConf = "\n".join([line.strip() for line in self.certificateAuthorityRepo.strip().split("\n")])
repoName = self.caRepoName
for package in packages:
self._updatePackageAndRepoInfo(package, repoName, repoConf)
else:
packages.append(self.getPackageName("CA"))
self.installPackages(packages)
for package in packages:
if not self.isPackageInstalled(package):
Util.printError("Failed to install %s." % package)
示例15: cleanQuarantine
# 需要导入模块: from stratuslab import Util [as 别名]
# 或者: from stratuslab.Util import printError [as 别名]
def cleanQuarantine(self):
self._setPDiskUserCredentials()
disks = self.describeVolumes({'quarantine': ['.*']})
threshold = self._getQuarantineThresholdDate()
disksToCleanUp = []
for disk in disks:
quarantineDate = self._parseQuarantineDate(disk['quarantine'])
if quarantineDate < threshold:
disksToCleanUp.append(disk)
for disk in disksToCleanUp:
self._printDetail('Removing disk: %s' % disk['uuid'])
try:
self.deleteVolume(disk['uuid'])
except (ClientException, ServerException), ex:
Util.printError(str(datetime.now()) + ' ' + str(ex))