• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python stratuslab.Util类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: _generateOpensslConfig

    def _generateOpensslConfig(self):
        config = """
[ req ]
distinguished_name     = req_distinguished_name
x509_extensions        = v3_ca
prompt                 = no
input_password         = %(certPassword)s
output_password        = %(certPassword)s

dirstring_type = nobmp

[ req_distinguished_name ]
C = EU
O = StratusLab Project
OU = Testing Department
CN = %(commonName)s

[ v3_ca ]
basicConstraints = CA:false
nsCertType=client, email, objsign
keyUsage=critical, digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment, keyAgreement
subjectKeyIdentifier=hash
authorityKeyIdentifier=keyid:always,issuer:always
subjectAltName=email:%(subjectEmail)s
""" % self.configHolder.options

        conf_filename = os.path.join(self.tmp_dir, 'openssl.cfg')
        open(conf_filename, 'w').write(config)

        Util.printDetail("Generated openssl configuration in: %s" % conf_filename,
                         self.configHolder.verboseLevel)
        Util.printDetail("Openssl configuration: %s" % open(conf_filename).read(),
                         self.configHolder.verboseLevel,
                         Util.VERBOSE_LEVEL_DETAILED)
开发者ID:StratusLab,项目名称:client,代码行数:34,代码来源:CertGenerator.py


示例2: testfilePutGetContentUnicode

 def testfilePutGetContentUnicode(self):
     _, filename = tempfile.mkstemp()
     try:
         Util.filePutContent(filename, unicode('Élément', encoding='utf8'))
         assert 'Élément' == Util.fileGetContent(filename)
     finally:
         os.unlink(filename)
开发者ID:StratusLab,项目名称:client,代码行数:7,代码来源:UtilTest.py


示例3: _validateParameters

 def _validateParameters(self):
     Util.printStep('Validating parameters')
     if not self.registrationLdapScheme:
         raise ValidationException('registration_ldap_scheme is not defined')
     if not self.registrationLdapHost:
         raise ValidationException('registration_ldap_host is not defined')
     if not self.registrationLdapPort:
         raise ValidationException('registration_ldap_port is not defined')
     if not self.registrationLdapManagerDn:
         raise ValidationException('registration_ldap_manager_dn is not defined')
     if not self.registrationLdapManagerPassword:
         raise ValidationException('registration_ldap_manager_password is not defined')
     if not self.registrationAdminEmail:
         raise ValidationException('registration_admin_email is not defined')
     if not self.registrationMailHost:
         raise ValidationException('registration_mail_host is not defined')
     if not self.registrationMailPort:
         raise ValidationException('registration_mail_port is not defined')
     if not self.registrationMailUser:
         raise ValidationException('registration_mail_user is not defined')
     if not self.registrationMailPassword:
         raise ValidationException('registration_mail_password is not defined')
     if not self.registrationMailSsl:
         raise ValidationException('registration_mail_ssl is not defined')
     if not self.registrationMailDebug:
         raise ValidationException('registration_mail_debug is not defined')
     if not self.registrationSslTruststore:
         self.registrationSslTruststore = ''
开发者ID:StratusLab,项目名称:client,代码行数:28,代码来源:Registration.py


示例4: testfilePutGetContentStr

 def testfilePutGetContentStr(self):
     _, filename = tempfile.mkstemp()
     try:
         Util.filePutContent(filename, str('Element'))
         assert 'Element' == Util.fileGetContent(filename)
     finally:
         os.unlink(filename)
开发者ID:StratusLab,项目名称:client,代码行数:7,代码来源:UtilTest.py


示例5: _shutdownNode

 def _shutdownNode(self):
     if self.shutdownVm:
         self._stopMachine()
     else:
         self._printStep('Machine ready for use')
         msg = '\n\tMachine IP: %s\tRemember to stop the machine when finished' % self.vmIp
         Util.printInfo(msg)
开发者ID:StratusLab,项目名称:client,代码行数:7,代码来源:Creator.py


示例6: addNetworkAcl

    def addNetworkAcl(self, users, net_id_int, rights):
        """
        users - hex
        net_id_int - integer, network ID
        rights - hex
        """
        # "magic" number
        _magic = self.ACL_USERS['UID']
        net_resource = hex(self.ACL_RESOURCES['NET'] + _magic + net_id_int)

        # Hack to retry on SSL errors
        maxRetries = 3
        retries = 0
        while True:
            try:
                ret, info, _ = self._rpc.one.acl.addrule(self._sessionString,
                                                         users,
                                                         net_resource,
                                                         rights)
                break
            except ssl.SSLError as e:
                retries += 1
                t = strftime("%Y-%m-%d %H:%M:%S", gmtime())
                Util.printDetail('SSL ERROR ENCOUNTERED (%s): %s' % (t, str(e)))
                if retries >= maxRetries:
                    raise e

        if not ret:
            raise OneException(info)

        return info
开发者ID:StratusLab,项目名称:client,代码行数:31,代码来源:one.py


示例7: _killMachine

    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,代码行数:7,代码来源:Creator.py


示例8: listVms

    def listVms(self, showVmsFromAllUsers=False):
        fromAllUsers = -2
        currentUserOnly = -3

        if showVmsFromAllUsers:
            visibilitySwitch = fromAllUsers
        else:
            visibilitySwitch = currentUserOnly

        # Hack to retry on SSL errors.
        maxRetries = 3
        retries = 0
        while True:
            try:
                ret, info, _ = self._rpc.one.vmpool.info(self._sessionString, visibilitySwitch, -1, -1, -1)
                break
            except ssl.SSLError as e:
                retries += 1
                t = strftime("%Y-%m-%d %H:%M:%S", gmtime())
                Util.printDetail('SSL ERROR ENCOUNTERED (%s): %s' % (t, str(e)))
                if retries >= maxRetries:
                    raise e

        if not ret:
            raise OneException(info)

        vmlist = Util.etree_from_text(info)
        for xml in vmlist.findall('VM'):
            self._addStateSummary(xml)

        return etree.tostring(vmlist)
开发者ID:StratusLab,项目名称:client,代码行数:31,代码来源:one.py


示例9: _configureNetworkInterface

    def _configureNetworkInterface(self, device, ip, netmask):
        deviceConf = '/etc/sysconfig/network-scripts/ifcfg-%s' % device
        data = """DEVICE=%s
IPADDR=%s
NETMASK=%s
""" % (device, ip, netmask)
        Util.filePutContent(deviceConf, data)
开发者ID:StratusLab,项目名称:client,代码行数:7,代码来源:centos.py


示例10: _remoteFileAppendContents

    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))
开发者ID:remyd1,项目名称:client,代码行数:7,代码来源:BaseSystem.py


示例11: _configureSudo

 def _configureSudo(self):
     Util.appendOrReplaceInFile(self.sudoersFilePath,
             'Defaults:%s !requiretty' % self.cloudUsername,
             'Defaults:%s !requiretty' % self.cloudUsername)
     Util.appendOrReplaceInFile(self.sudoersFilePath,
             '%s ALL= NOPASSWD: %s' % (self.cloudUsername, self.firewall.binary),
             '%s ALL= NOPASSWD: %s' % (self.cloudUsername, self.firewall.binary))
开发者ID:StratusLab,项目名称:client,代码行数:7,代码来源:PortTranslation.py


示例12: doWork

    def doWork(self):

        # checking marketplace endpoint URL
        url_is_ok = Util.checkUrlExists(ENDPOINT_MKP, 30)
        if url_is_ok is True:

            req = urllib2.Request(ENDPOINT_MKP)
            response = urllib2.urlopen(req)
            content = response.read()

            xml = Util.etree_from_text(content)

            desc_nodes = xml.iter("{" + RDF + "}Description")
            all_desc = []
            desc = {}

            for desc_node in desc_nodes:
                desc["description"] = desc_node.find('{' + DCTERMS + '}description').text
                desc["identifier"] = desc_node.find('{' + DCTERMS + '}identifier').text
                desc["creator"] = desc_node.find('{' + DCTERMS + '}creator').text
                desc["created"] = desc_node.find('{' + DCTERMS + '}created').text
                desc["os"] = desc_node.find('{' + SLTERMS + '}os').text
                desc["os-version"] = desc_node.find('{' + SLTERMS + '}os-version').text
                desc["os-arch"] = desc_node.find('{' + SLTERMS + '}os-arch').text

                # cast in str for NoneType object (otherwise, we should use try/Except)
                print "Description: " + str(desc["description"])
                print "ID: " + str(desc["identifier"])
                print "OS: " + str(desc["os"]), str(desc["os-version"]), "| Arch: " + str(desc["os-arch"])
                print "Creator: " + str(desc["creator"])
                print "Created at: " + str(desc["created"].replace("Z", "").split('T'))
                print "####\n"
                all_desc.append(desc)
开发者ID:StratusLab,项目名称:client,代码行数:33,代码来源:stratus_list_images.py


示例13: _lcmStateToString

 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
开发者ID:StratusLab,项目名称:client,代码行数:7,代码来源:one.py


示例14: _configureVirtualNetInterface

    def _configureVirtualNetInterface(self, device, ip, netmask):
        device = device + ":privlan"

        Util.printDetail("Configuring network interface %s." % device)
        self._configureNetworkInterface(device, ip, netmask)

        Util.printDetail("Starting network interface %s." % device)
        self.executeCmd(["ifup", device])
开发者ID:StratusLab,项目名称:client,代码行数:8,代码来源:BaseSystem.py


示例15: _installPackages

    def _installPackages(self):
        Util.printStep('Removing CIMI server package')
        cmd = 'yum erase -y %s' % self._package
        self._executeExitOnError(cmd)

        Util.printStep('Installing CIMI server package')
        cmd = 'yum install --nogpgcheck -y %s' % self._package
        self._executeExitOnError(cmd)
开发者ID:StratusLab,项目名称:client,代码行数:8,代码来源:CIMI.py


示例16: doWork

 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)
开发者ID:StratusLab,项目名称:client,代码行数:8,代码来源:stratus_sign_metadata.py


示例17: _writeToFilesRemote

 def _writeToFilesRemote(self, listOfFileNameContentTuples):
     tmpFilename = tempfile.mktemp()
     for remoteFilename, content in listOfFileNameContentTuples:
         Util.filePutContent(tmpFilename, content)
         self._nodeCopy(tmpFilename, remoteFilename)
     try:
         os.unlink(tmpFilename)
     except: pass
开发者ID:remyd1,项目名称:client,代码行数:8,代码来源:BaseSystem.py


示例18: sign

 def sign(self):
     res, output = self._sign()
     if res:
         Util.printError(output, exit=False)
         self._cleanupTempFile()
     else:
         self._renameFiles()
     return res
开发者ID:StratusLab,项目名称:client,代码行数:8,代码来源:Signator.py


示例19: _installDhcp

    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)
开发者ID:remyd1,项目名称:client,代码行数:8,代码来源:BaseSystem.py


示例20: _saveFirewallRules

    def _saveFirewallRules(self, filename):
        # back-up
        self.executeCmd(('cp -fp %s %s.LAST'%((filename,)*2)).split(' '))

        _,output = self.executeCmdWithOutput(['iptables-save'])
        Util.printDetail('Saving firewall rules to %s.' % filename)
        filePutContent(filename, output)
        os.chmod(filename, 0600)
开发者ID:remyd1,项目名称:client,代码行数:8,代码来源:BaseSystem.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python stravalib.Client类代码示例发布时间:2022-05-27
下一篇:
Python pubsub.Pubsub类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap