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

Python pysphere.VIServer类代码示例

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

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



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

示例1: main

def main(argv=None):

    if argv is None:
    argv=sys.argv

    server = VIServer()
    try:
        server.connect(sys.argv[1], sys.argv[2], sys.argv[3])

    hosts = server.get_hosts()
        for h_mor, h_name in hosts.items():
            props = VIProperty(server, h_mor)
        try:
            f = open("/tmp/esxi_hosts_" + sys.argv[1] + ".txt", "w")
            try:
            f.write("memorySize=" + str(props.hardware.memorySize) + "\n")
            f.write("overallCpuUsage=" + str(props.summary.quickStats.overallCpuUsage) + "\n")
                    f.write("overallMemoryUsage=" + str(props.summary.quickStats.overallMemoryUsage) + "\n")
            f.write("uptime=" + str(props.summary.quickStats.uptime) + "\n")
                # $CPUTotalMhz = $_.Summary.hardware.CPUMhz * $_.Summary.Hardware.NumCpuCores
                # $row."CpuUsage%" = [math]::round( ($row.CpuUsageMhz / $CPUTotalMhz), 2) * 100
                f.write("cpuMhz=" + str(props.summary.hardware.cpuMhz) + "\n")
                f.write("numCpuCores=" + str(props.summary.hardware.numCpuCores) + "\n")
            finally:
                f.close()
        except IOError:
            print "0"
            sys.exit(0)	
开发者ID:karabatov,项目名称:linscripts,代码行数:28,代码来源:check_esxi_hosts.py


示例2: viConnect

def viConnect(vCenter,username,password,vmname):
	server = VIServer()
	server.connect(vCenter,username,password)
	#print "vCenter: {} User: {} Pass: {}".format(vCenter,username,password)
	#return server
	#print viConnect("192.168.219.129","root","vmware")
	return getVm(server,vmname)
开发者ID:cjohannsen81,项目名称:pySphereClient,代码行数:7,代码来源:pySphereClient.py


示例3: esx_connect

def esx_connect(host, user, password):
    esx = VIServer()
    try:
        esx.connect(host, user, password)
    except VIApiException, e:
        print("There was an error while connecting to esx: %s" % e)
        return 1
开发者ID:bartekrutkowski,项目名称:egniter,代码行数:7,代码来源:egniter.py


示例4: connect_VI

def connect_VI(vcenter_hostname, user, password):
    # Create the connection to vCenter Server
    server = VIServer()
    try:
        server.connect(vcenter_hostname, user, password)
    except VIApiException, err:
        module.fail_json(msg="Cannot connect to %s: %s" % (vcenter_hostname, err))
开发者ID:mikecali,项目名称:BAU_plays,代码行数:7,代码来源:vm_snapshot.py


示例5: _connect_server

def _connect_server(bot):
    try:
        server = VIServer()
        server.connect(bot.config.pysphere.server, bot.config.pysphere.login, bot.config.pysphere.password)        
    except Exception, e:
        bot.say("No connection to the server")
        return False
开发者ID:perheld,项目名称:willie-pysphere,代码行数:7,代码来源:willie-pysphere.py


示例6: connectToHost

def connectToHost(host,host_user,host_pw):
    #create server object
    s=VIServer()
    #connect to the host
    try:
        s.connect(host,host_user,host_pw)
        return s
开发者ID:prwitt,项目名称:python,代码行数:7,代码来源:vm_include.py


示例7: host_connect

def host_connect(host):
    """ Connect to a host. """
    server = VIServer()
    server.connect(host, CREDS.get('Host', 'user'),
                   CREDS.get('Host', 'pass'))

    return server
开发者ID:gcavalcante8808,项目名称:vunit,代码行数:7,代码来源:vmwtest.py


示例8: main

def main():
    u"""Main method

    Create session.
    Excute subcommand.
    """
    # Import
    import socket
    import getpass
    import sys
    from pysphere import VIApiException, VIServer
    import argument

    # Get argument
    args = argument.args()
    s = VIServer()

    # Set information
    host = args.host if args.host else raw_input('Host> ')
    user = args.user if args.user else raw_input('User> ')
    passwd = args.passwd if args.passwd else getpass.getpass('Password> ')
    try:
        print 'Connecting...'
        s.connect(host, user, passwd)

        # Execute function
        args.func(args, s)
    except socket.error:
        print >> sys.stderr, "Cannot connected."
    except VIApiException:
        print >> sys.stderr, "Incorrect user name or password."
    except Exception, e:
        print >> sys.stderr, e.message
开发者ID:corrupt952,项目名称:pyxenter,代码行数:33,代码来源:esxi.py


示例9: get_connection

def get_connection(host_ip, username, password):
    server = VIServer()
    if host_ip is not None and username is not None and password is not None:
        server.connect(host_ip, username, password)
    else:
        return None
    return server
开发者ID:wuhongyang,项目名称:iass-web,代码行数:7,代码来源:vmwarecli.py


示例10: main

def main():
    vm = None

    module = AnsibleModule(
        argument_spec=dict(
            vcenter_hostname=dict(required=True, type='str'),
            vcenter_username=dict(required=True, type='str'),
            vcenter_password=dict(required=True, type='str'),
            datacenter_name=dict(required=True, type='str'),
            folder_structure=dict(required=True, type='list'),
            guest_list=dict(required=True, type='list'),
        ),
        supports_check_mode=False,
    )

    if not HAS_PYSPHERE:
        module.fail_json(msg='pysphere module required')

    vcenter_hostname = module.params['vcenter_hostname']
    vcenter_username = module.params['vcenter_username']
    vcenter_password = module.params['vcenter_password']
    guest_list = module.params['guest_list']
    folder_structure = module.params['folder_structure']
    base_datacenter = module.params['datacenter_name']

    # CONNECT TO THE SERVER
    viserver = VIServer()
    try:
        viserver.connect(vcenter_hostname, vcenter_username, vcenter_password)
    except VIApiException, err:
        module.fail_json(msg="Cannot connect to %s: %s" %
                         (vcenter_hostname, err))
开发者ID:zarlant,项目名称:ansible-modules,代码行数:32,代码来源:vsphere_folder_relocate.py


示例11: vcenter_connect

def vcenter_connect():
    """ Connect to the vcenter. """
    server = VIServer()
    server.connect(CREDS.get('Vcenter', 'server'),
                   CREDS.get('Vcenter', 'user'),
                   CREDS.get('Vcenter', 'pass'))

    return server
开发者ID:gcavalcante8808,项目名称:vunit,代码行数:8,代码来源:vmwtest.py


示例12: __init__

 def __init__(self, vcip, vcuser, vcpassword, dc, clu):
     self.vcip = vcip
     self.translation = {'POWERED OFF':'down', 'POWERED ON':'up'}
     s = VIServer()
     s.connect(vcip, vcuser, vcpassword)
     self.s = s
     self.clu = clu
     self.dc = dc
开发者ID:aiminickwong,项目名称:nuages,代码行数:8,代码来源:vsphereng.py


示例13: VSphereConnection

class VSphereConnection(ConnectionUserAndKey):
    def __init__(self, user_id, key, secure=True,
                 host=None, port=None, url=None, timeout=None, **kwargs):
        if host and url:
            raise ValueError('host and url arguments are mutually exclusive')

        if host:
            host_or_url = host
        elif url:
            host_or_url = url
        else:
            raise ValueError('Either "host" or "url" argument must be '
                             'provided')

        self.host_or_url = host_or_url
        self.client = None
        super(VSphereConnection, self).__init__(user_id=user_id,
                                                key=key, secure=secure,
                                                host=host, port=port,
                                                url=url, timeout=timeout,
                                                **kwargs)

    def connect(self):
        self.client = VIServer()

        trace_file = os.environ.get('LIBCLOUD_DEBUG', None)

        try:
            self.client.connect(host=self.host_or_url, user=self.user_id,
                                password=self.key,
                                sock_timeout=DEFAULT_CONNECTION_TIMEOUT,
                                trace_file=trace_file)
        except Exception:
            e = sys.exc_info()[1]
            message = e.message
            if hasattr(e, 'strerror'):
                message = e.strerror
            fault = getattr(e, 'fault', None)

            if fault == 'InvalidLoginFault':
                raise InvalidCredsError(message)
            raise LibcloudError(value=message, driver=self.driver)

        atexit.register(self.disconnect)

    def disconnect(self):
        if not self.client:
            return

        try:
            self.client.disconnect()
        except Exception:
            # Ignore all the disconnect errors
            pass

    def run_client_method(self, method_name, **method_kwargs):
        method = getattr(self.client, method_name, None)
        return method(**method_kwargs)
开发者ID:SecurityCompass,项目名称:libcloud,代码行数:58,代码来源:vsphere.py


示例14: conexion_viserver

    def conexion_viserver(self):
        self.logger.debug(self)
        esxi = VIServer()
        esxi.connect(self.creds['ip'], self.creds['user'],
                     self.creds['pw'], trace_file=self.config.logpysphere)

        self.logger.debug("Conectado a %s %s", esxi.get_server_type(),
                          esxi.get_api_version())
        return esxi
开发者ID:dvinazza,项目名称:esxi-tools,代码行数:9,代码来源:host.py


示例15: connectToHost

def connectToHost(host,host_user,host_pw):
    #create server object
    s=VIServer()
    #connect to the host
    try:
        s.connect(host,host_user,host_pw)
        return s
    except VIApiException, err:
        print "Cannot connect to host: '%s', error message: %s" %(host,err)    
开发者ID:Fabian1976,项目名称:python-ovirt-foreman-api,代码行数:9,代码来源:api_vmware.py


示例16: connect_vcenter

def connect_vcenter(vcenter):
    #default_context = ssl._create_default_https_context
    server = VIServer()
    try:
        #ssl._create_default_https_context = ssl._create_unverified_context
        server.connect(vcenter.host_name, vcenter.user_name, vcenter.user_password)
        return server
    except AttributeError, e:
        print "ERROR: " + str(e)
        pass
开发者ID:AnsiblePower,项目名称:AnsiblePower,代码行数:10,代码来源:vmvc.py


示例17: revert

def revert(datastore):
  #vmsphear username and password
  server = VIServer()
  server.connect("101.91.1.21", "root", "Vsphear_root_password")

  vm1 = server.get_vm_by_path(datastore)
  print "Cuurrent Status",vm1.get_status()
  print "Reverting VM:", datastore 
  vm1.revert_to_snapshot()
  print "Vm reverted"
开发者ID:BwRy,项目名称:sandy,代码行数:10,代码来源:pysph.py


示例18: GetHostConfig

def GetHostConfig(host, user, password):
    from pysphere import VIServer
    server = VIServer()

    try:
        server.connect(host, user, password)
    except Exception, e:
        print "Error while connecting to %s:" % host
        print "%s" % e
        return None, False
开发者ID:sebbrochet,项目名称:IT360Awareness,代码行数:10,代码来源:list_esxconf.py


示例19: create_vmware_connection

def create_vmware_connection(vmware_settings):
    try:
        server = VIServer()
        server.connect(vmware_settings['host'],
                       vmware_settings['user'],
                       vmware_settings['password'])
    except:
        print traceback.format_exc()
        raise
    return server
开发者ID:mitchchen,项目名称:sdk,代码行数:10,代码来源:vmware_samplescaleout.py


示例20: connectToHost

def connectToHost(host, hostUsername, hostPassword):
    # create server object
    server = VIServer()

    try:
        server.connect(host, hostUsername, hostPassword)
        return server

    except VIApiException:
        raise
开发者ID:mrajagopal,项目名称:VMwareControl,代码行数:10,代码来源:VmInclude.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python vi_mor.VIMor类代码示例发布时间:2022-05-27
下一篇:
Python api.get_particle_array函数代码示例发布时间: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