当前位置: 首页>>代码示例>>Python>>正文


Python Util.printWarning方法代码示例

本文整理汇总了Python中stratuslab.Util.printWarning方法的典型用法代码示例。如果您正苦于以下问题:Python Util.printWarning方法的具体用法?Python Util.printWarning怎么用?Python Util.printWarning使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在stratuslab.Util的用法示例。


在下文中一共展示了Util.printWarning方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _killMachine

# 需要导入模块: from stratuslab import Util [as 别名]
# 或者: from stratuslab.Util import printWarning [as 别名]
    def _killMachine(self):
        self._printStep('Killing machine')

        if self.vmId:
            self.cloud.vmKill(self.vmId)
        else:
            Util.printWarning('Undefined VM ID, when trying to kill machine.')
开发者ID:StratusLab,项目名称:client,代码行数:9,代码来源:Creator.py

示例2: _getConfSubnets

# 需要导入模块: from stratuslab import Util [as 别名]
# 或者: from stratuslab.Util import printWarning [as 别名]
        def _getConfSubnets():
            subnetTemplate = """
subnet %(subnet)s netmask %(netmask)s {
  option routers %(routers)s;
}
"""
            subnet = ''
            # All net types are defined together with NATing. Assuming NATing for
            # Local net type. Need to create a shared network.
            if Util.isTrueConfVal(self.nat) and _isAllDhcpGroupsDefined(dhcpGroups):
                subnet = """
shared-network StratusLab-LAN {
"""
                for _type in self.NET_TYPES_DHCP:
                    subnet += subnetTemplate % {
                               'subnet'  : getattr(self, self._assembleDhcpAttributeName('%sSubnet' % _type)),
                               'netmask' : getattr(self, self._assembleDhcpAttributeName('%sNetmask' % _type)),
                               'routers' : getattr(self, self._assembleDhcpAttributeName('%sRouters' % _type))}
                subnet += "}\n"

            elif Util.isTrueConfVal(self.nat) and dhcpGroups['OneLocalNetwork']:
                subnet = """
shared-network StratusLab-LAN {
"""
                # main interface
                subnet += """
subnet %(subnet)s netmask %(netmask)s {
}
""" % {'subnet'  : self.dhcpSubnet,
       'netmask' : self.dhcpNetmask}
                # virtual interface
                natGateway = getattr(self, 'natGateway', '')
                if not natGateway:
                    natGateway = Util.gatewayIpFromNetAddress(self.natNetwork)
                subnet += subnetTemplate % {'subnet'  : self.natNetwork,
                                            'netmask' : self.natNetmask,
                                            'routers' : natGateway}
                subnet += "}\n"

            elif dhcpGroups['OnePublicNetwork']:
                # main interface
                subnet += """
subnet %(subnet)s netmask %(netmask)s {
}
""" % {'subnet'  : self.dhcpSubnet,
       'netmask' : self.dhcpNetmask}

            elif dhcpGroups['OneLocalNetwork']:
                # virtual interface
                subnet = subnetTemplate % {
                                'subnet'  : self.dhcpOneLocalNetworkSubnet,
                                'netmask' : self.dhcpOneLocalNetworkNetmask,
                                'routers' : self.dhcpOneLocalNetworkRouters}
            else:
                Util.printWarning('Invalid parameters combination to configure DHCP.')

            return subnet
开发者ID:remyd1,项目名称:client,代码行数:59,代码来源:BaseSystem.py

示例3: _configureDbUser

# 需要导入模块: from stratuslab import Util [as 别名]
# 或者: from stratuslab.Util import printWarning [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))
开发者ID:remyd1,项目名称:client,代码行数:16,代码来源:BaseSystem.py

示例4: addElementToManifest

# 需要导入模块: from stratuslab import Util [as 别名]
# 或者: from stratuslab.Util import printWarning [as 别名]
    def addElementToManifest(root, elementName, value):
        elems = root.findall('.//{%s}%s' % (ManifestInfo.NS_SLTERMS, elementName))

        if elems:
            # Check if already present. If yes, do nothing.
            for elem in elems:
                if elem.text and elem.text == value:
                    Util.printWarning(
                        "Element '%s' with value '%s' already defined in the manifest. Skipping addition of the element." % \
                        (elementName, elem.text))
                    return

        elem = etree.Element('{%s}%s' % (ManifestInfo.NS_SLTERMS, elementName))
        elem.text = value

        descriptionElement = root.find('.//{%s}Description' % ManifestInfo.NS_RDF)
        descriptionElement.append(elem)
开发者ID:StratusLab,项目名称:client,代码行数:19,代码来源:ManifestInfo.py

示例5: _persistRemoteBridgeConfig

# 需要导入模块: from stratuslab import Util [as 别名]
# 或者: from stratuslab.Util import printWarning [as 别名]
    def _persistRemoteBridgeConfig(self, iface, bridge):
        netScriptsDir = '/etc/sysconfig/network-scripts/'
        ifaceFile = '%s/ifcfg-%s' % (netScriptsDir, iface)
        bridgeFile = '%s/ifcfg-%s' % (netScriptsDir, bridge)

        if self._nodeShell('[ -f %s ]' % bridgeFile, shell=True) == 0:
            Util.printWarning(('Bridge configuration already present (%s:%s).' % 
                               (self.nodeAddr, bridgeFile)) + \
                               ' Please update it manually if required.')
            return

        cmd = 'cat %s' % ifaceFile
        rc, output = self._nodeShell(cmd, withOutput=True, shell=True)
        if rc != 0:
            Util.printWarning('Failed to get content of %s:%s:\n%s' % 
                              (self.nodeAddr, ifaceFile, output))
            return

        ifaceConfOrig = output
        try:
            bridgeConf, ifaceConf = self._buildBridgeAndIfaceConfig(ifaceConfOrig,
                                                                    iface, bridge)
        except Exceptions.ConfigurationException, ex:
            Util.printWarning('Failed to build config for %s and %s.\n%s' % 
                              (iface, bridge, str(ex)))
            return
开发者ID:StratusLab,项目名称:client,代码行数:28,代码来源:centos.py

示例6: checkOptions

# 需要导入模块: from stratuslab import Util [as 别名]
# 或者: from stratuslab.Util import printWarning [as 别名]
    def checkOptions(self):
        if len(self.args) != 1:
            self.parser.error('Please specify an image')
        self.image = self.args[0]

        if not os.path.isfile(self.image):
            self.parser.error('Image does not exist: ' + self.image)

        if not self.options.locations:
            self.options.__dict__.update({'locations': []})
            Util.printWarning("Image physical location (URL) was not provided. "
                              "You'll have to set it manually in the resulting manifest.")
        else:
            self.options.__dict__.update({'locations': [self.options.__dict__['locations']]})

        if not self.options.compression:
            # Guess compression from file name if not given explicitly.
            compression = Compressor.getCompressionFormat(self.image)
            self.options.__dict__.update({'compression': compression})

        if self.options.disksbus not in VmManager.DISKS_BUS_AVAILABLE:
            self.parser.error("Unknown disks bus type %s. Available types: %s" %
                              (self.options.disksbus, ', '.join(VmManager.DISKS_BUS_AVAILABLE)))
开发者ID:StratusLab,项目名称:client,代码行数:25,代码来源:stratus_build_metadata.py

示例7: _compressFile

# 需要导入模块: from stratuslab import Util [as 别名]
# 或者: from stratuslab.Util import printWarning [as 别名]
    def _compressFile(self, filename, fmt):

        if fmt.lower() == 'none':
            return filename

        if Compressor.getCompressionFormat(filename) != '':
            Util.printWarning('skipping compression; file appears to already be compressed')
            return filename

        compressionCmd = Compressor._getCompressionCommandByFormat(fmt)

        compressedFilename = '%s.%s' % (filename, fmt)
        if os.path.isfile(compressedFilename):
            Util.printWarning('Compressed file %s already exists, skipping' % compressedFilename)
            return compressedFilename

        if not os.path.exists(filename):
            Util.printError('Missing file: ' + filename, exit=True)

        ret = self._execute([compressionCmd, filename])
        if ret != 0:
            Util.printError('Error compressing file: %s' % compressedFilename, exit=True)

        return compressedFilename
开发者ID:StratusLab,项目名称:client,代码行数:26,代码来源:Uploader.py

示例8: printWarning

# 需要导入模块: from stratuslab import Util [as 别名]
# 或者: from stratuslab.Util import printWarning [as 别名]
 def printWarning(self, msg):
     Util.printWarning(msg)
开发者ID:StratusLab,项目名称:client,代码行数:4,代码来源:Configurable.py

示例9: _configureRootDbUser

# 需要导入模块: from stratuslab import Util [as 别名]
# 或者: from stratuslab.Util import printWarning [as 别名]
 def _configureRootDbUser(self, password):
     rc, output = self._execute(["/usr/bin/mysqladmin", "-uroot", "password", "%s" % password], withOutput=True)
     if rc != 0:
         Util.printWarning("Couldn't set root password. Already set?\n%s" % output)
开发者ID:remyd1,项目名称:client,代码行数:6,代码来源:BaseSystem.py

示例10: _addCompressionFormatToManifest

# 需要导入模块: from stratuslab import Util [as 别名]
# 或者: from stratuslab.Util import printWarning [as 别名]
 def _addCompressionFormatToManifest(self):
     if self.compressionFormat.lower() != 'none':
         ManifestInfo.addElementToManifestFile(self.manifestFile,
                                               'compression', self.compressionFormat)
     else:
         Util.printWarning("'none' specified for compression; manifest compression element NOT updated")
开发者ID:StratusLab,项目名称:client,代码行数:8,代码来源:Uploader.py


注:本文中的stratuslab.Util.printWarning方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。