Git Product home page Git Product logo

pysphere's Introduction

========
PySphere 
========
Python API for interacting with the vSphere Web Services SDK.
-------------------------------------------------------------

Visit the project_ site for more information.

.. _project: http://pysphere.googlecode.com

**Among other operations, PySphere provides easy interfaces to:**

- Connect to VMWare's ESX, ESXi, Virtual Center, Virtual Server hosts 
- Query hosts, datacenters, resource pools, virtual machines
- VMs: Power on, power off, reset, revert to snapshot, get properties, update 
  vmware tools, clone, migrate.
- vSphere 5.0 Guest Operations: create/delete/move files and directories.
  upload/download files from the guest system. List/start/stop processes in 
  the guest system.
- Create and delete snapshots
- Get hosts statistics and monitor performance

An of course, you can use it to access all the vSphere API through python.

It's built upon a slightly modified version of ZSI_ (that comes bundled-in) 
which makes it really fast in contrast to other python SOAP libraries that don't
provide code generation.

.. _ZSI: http://pywebsvcs.sourceforge.net/zsi.html

Installation
------------

The simplest way is using setuptools_' easy_install:

.. _setuptools: http://pypi.python.org/pypi/setuptools

::

  easy_install -U pysphere

Or using the pip_:

.. _pip: http://pypi.python.org/pypi/pip

::

  pip install -U pysphere

You can aslo find the source package and windows installer in the downloads_ 
section. To install it from the source package:

.. _downloads: http://code.google.com/p/pysphere/downloads/list

1. Unzip the package
2. run: ``python setup.py install``

Quick Example
-------------

Here's how you power on a virtual machine. See also the `getting started`_ guide
and the project's wiki_ with the full documentation.

.. _getting started: http://code.google.com/p/pysphere/wiki/GettingStarted
.. _wiki: http://code.google.com/p/pysphere/w/list

>>> from pysphere import VIServer
>>> server = VIServer()
>>> server.connect("my.esx.host.com", "myusername", "secret")
>>> vm = server.get_vm_by_path("[datastore] path/to/file.vmx")
>>> vm.power_on()
>>> print vm.get_status()
POWERED ON

Discussion Group
----------------

You can find a lot more examples and use cases in the `discussion group`_

.. _discussion group: http://groups.google.com/group/pysphere

License
-------

Copyright (c) 2012, Sebastian Tello
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

  * Redistributions of source code must retain the above copyright notice,
    this list of conditions and the following disclaimer.
  * Redistributions in binary form must reproduce the above copyright notice,
    this list of conditions and the following disclaimer in the documentation
    and/or other materials provided with the distribution.
  * Neither the name of copyright holders nor the names of its contributors
    may be used to endorse or promote products derived from this software
    without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.



ZSI License
-----------

Copyright (c) 2003, The Regents of the University of California,
through Lawrence Berkeley National Laboratory (subject to receipt of
any required approvals from the U.S. Dept. of Energy). All rights
reserved. Redistribution and use in source and binary forms, with or
without modification, are permitted provided that the following
conditions are met:

(1) Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
(2) Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
(3) Neither the name of the University of California, Lawrence Berkeley
National Laboratory, U.S. Dept. of Energy nor the names of its contributors
may be used to endorse or promote products derived from this software without
specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.

You are under no obligation whatsoever to provide any bug fixes,
patches, or upgrades to the features, functionality or performance of
the source code ("Enhancements") to anyone; however, if you choose to
make your Enhancements available either publicly, or directly to
Lawrence Berkeley National Laboratory, without imposing a separate
written license agreement for such Enhancements, then you hereby grant
the following license: a non-exclusive, royalty-free perpetual license
to install, use, modify, prepare derivative works, incorporate into
other computer software, distribute, and sublicense such Enhancements
or derivative works thereof, in binary and source code form.

pysphere's People

Contributors

argos83 avatar pablodcar avatar

Stargazers

 avatar  avatar

Watchers

 avatar

pysphere's Issues

Connecting using Kerberos / AD

Connect to pysphere using Kerberos / AD

From: https://groups.google.com/forum/#!topic/pysphere/jcFn6ZtwUgk

This should be done by implementing this function: 
http://www.vmware.com/support/developer/vc-sdk/visdk41pubs/ApiReference/vim.Sess
ionManager.html#loginBySSPI

Original issue reported on code.google.com by [email protected] on 31 Jul 2012 at 1:06

VIVirtualMachine.send_file() gratuitiosly overwrites urllib2's installed default opener

What steps will reproduce the problem?
1. have a default proxy configured that does not allow access to the ESXi hosts.
2. configure urllib2 to not use a proxy:

proxy_handler = urllib2.ProxyHandler({})
opener = urllib2.build_opener(proxy_handler)
urllib2.install_opener(opener)

3. try uploading a file to a guest with vm.send_file()

What is the expected output? What do you see instead?

This causes send_file() to abort with an exception because the connection
to the ESX host can't be established.

What version of the product are you using? On what operating system?

pysphere 0.1.7, python 2.6.8, Windows 7

urllib2.urlopen() has accepted a request object since at least python 2.5.

Apply the following patch:

--- vi_virtual_machine.py,0     2012-10-09 18:04:01.576577700 +0200             
+++ vi_virtual_machine.py       2012-10-09 19:12:04.782569200 +0200             
@@ -1276,10 +1276,9 @@                                                          

             url = url.replace("*", urlparse(self._server._proxy.binding.url    
                                                                      ).hostname
)                                                                               
-            opener = urllib2.build_opener(urllib2.HTTPHandler)                 
             request = urllib2.Request(url, data=content)                       
             request.get_method = lambda: 'PUT'                                 
-            resp = opener.open(request)                                        
+            resp = urllib2.urlopen(request)                                    
             if not resp.code == 200:                                           
                 raise VIException("File could not be send",                    
                                   FaultTypes.TASK_ERROR)

Original issue reported on code.google.com by [email protected] on 9 Oct 2012 at 7:46

Delete a VM

Being able to delete a VM would be extremely useful. Is this a limitation on 
the vSphere SDK or on pysphere. If its pysphere I would be more than happy to 
write the module for it. 

Original issue reported on code.google.com by [email protected] on 5 Apr 2012 at 12:52

get_datastores InvalidPropertyFault

What steps will reproduce the problem?
for ds, name in server.get_datastores().items():

What is the expected output? What do you see instead?
Traceback (most recent call last):
  File "./check_vsphere.py", line 195, in <module>
    sys.exit(main(sys.argv[1:]))
  File "./check_vsphere.py", line 56, in main
    return datastore(server, warning, critical)
  File "./check_vsphere.py", line 170, in datastore
    for ds, name in server.get_datastores().items():
  File "/usr/lib/python2.6/site-packages/pysphere/vi_server.py", line 189, in get_datastores
    return self._get_managed_objects(MORTypes.Datastore, from_mor)
  File "/usr/lib/python2.6/site-packages/pysphere/vi_server.py", line 759, in _get_managed_objects
    obj_type=mo_type)
  File "/usr/lib/python2.6/site-packages/pysphere/vi_server.py", line 687, in _retrieve_properties_traversal
    raise VIApiException(e)
pysphere.resources.vi_exception.VIApiException: [InvalidPropertyFault]:


What version of the product are you using? On what operating system?
Machine being queried by script is ESXi 3.5.0
Machine running script is CentOS 6

Please provide any additional information below.
Code works against newer ESXi machine.

Original issue reported on code.google.com by [email protected] on 9 May 2013 at 3:13

R78 issue with VMclone

What steps will reproduce the problem?
1.Calling CloneVM with sync_run true results in Attribute error
2.
3.

What is the expected output? What do you see instead?
What I try to do: use a template to clone a VM from a template residing on 
another datastore.  Since the command executes flawless (I monitor it in 
vsphere), my argument are correct and so is the core section of the 
CloneVM_task in pysphere.  It goes wrong in the wrap-up of the call. I run the 
task against vCenter instead of the hypervisor (since only vcenter supports 
cloning)

IMHO there are two issues:
1. Minor: CloneVM returns different object types based on the value of one of 
its arguments, the sync_run parameter:  sync_run=true --> return 
VIVirtualMachine; sync_run=false --> returns VITask. While technically OK, it's 
a bit confusing and you need to be careful to test the value or sync_run to 
deal with the correct return type.  Other pysphere tasks do not have that 
behavior.

2. Major: IMHO the call to "return VIVirtualMachine(self._server, 
vi_task.get_result())" is not correct. vi_task.get_result() does not return a 
MOR but a VIProperty, hence you get the attribute non existing error for the 
call to instantiate the VIVirtualMachine class which expects a MOR.  The 
correct call would be:  "return VIVirtualMachine(self._server, 
vi_task.get_result()._obj)"

When I implemented this change my whole code ran OK.

What version of the product are you using? On what operating system?
Pysphere: R78.
Host: Windows 2008 R2, 64-bit
Python: 2.7 in 32 bit mode.
Vcenter and Vsphere: 5.0 U1

Please provide any additional information below.
My code:
vm.clone(name, sync_run=True, folder=None, resourcepool=rp_mor,
                                             datastore=ds_mor, host=host_mor, power_on=False)

Where I believe the problem is: vi_virtual_machine.py around line 530

            if sync_run:
                status = vi_task.wait_for_state([vi_task.STATE_SUCCESS,
                                                 vi_task.STATE_ERROR])
                if status == vi_task.STATE_ERROR:
                    raise VIException(vi_task.get_error_message(),
                                      FaultTypes.TASK_ERROR)
                return VIVirtualMachine(self._server, vi_task.get_result()) 

            return vi_task

Original issue reported on code.google.com by [email protected] on 10 Sep 2012 at 9:39

Add support to python3

Fist make the python 2.X version as compatible as possible with python 3 (e.g. 
by modifying ZSI's object types comparisons with the isinstance built-in)

Then run 2to3 and add the necessary fixes

Original issue reported on code.google.com by [email protected] on 21 Mar 2012 at 5:35

VIServer registered vm's method won't work with resource_pool filter

What steps will reproduce the problem?
1. Instantiate a VIServer object and connect to vcenter server;
2. Try to get registered VM's using a resource pool as a filter;

What is the expected output? What do you see instead?
The list of vm's inside the resource pool.

What version of the product are you using? On what operating system?
Vmware Vcenter 5.0.

Client libs:

Ubuntu 12.10
Python 2.7
pysphere==0.1.7


Original issue reported on code.google.com by [email protected] on 5 Dec 2012 at 6:07

AD user not recognized when using domain

What steps will reproduce the problem?
1. server.connect("vmhost","DOMAIN\user","passsword")

What is the expected output? What do you see instead?
No expected output.
pysphere.resources.vi_exception.VIApiException: [InvalidLoginFault]: Cannot 
complete login due to an incorrect user name or password.


What version of the product are you using? On what operating system?
0.1.8 on CentOS 6 64 and Cygwin64, currently the VMWare version is 5.1


Please provide any additional information below.
pysphere works well with non DOMAIN accounts, tested on 5.1 and 4.1 versions of 
VMWare

Original issue reported on code.google.com by [email protected] on 1 Oct 2013 at 9:55

Add a __getitem__ method to VIVirtualMachine class

This is an enhancement proposal. It would be fantastic if we could add a 
__getitem__ method to VIVirtualMachine classes so that one might be able to 
index a VIVirtualMachine instance—like so: vm['memory_mb']—and get the 
pertinent information. This would essentially be a shorthand for the following:
``
vm.get_properties()['memory_mb']
``

Original issue reported on code.google.com by [email protected] on 30 Aug 2013 at 3:53

vm.send_file: <unicode> URL + <str> file contents = UnicodeDecodeError

What steps will reproduce the problem?
1. Set up your server connection
2. Get a VM entity
3. Call `vm.send_file(bla, bla)`

What is the expected output? What do you see instead?
I expect the local file to be uploaded to the guest.  Instead, I've been seeing 
stuff like this:

  File "/usr/lib/python2.7/site-packages/pysphere/vi_virtual_machine.py", line 1193, in send_file
    resp = opener.open(request)
  File "/usr/lib/python2.7/urllib2.py", line 400, in open
    response = self._open(req, data)
  File "/usr/lib/python2.7/urllib2.py", line 418, in _open
    '_open', req)
  File "/usr/lib/python2.7/urllib2.py", line 378, in _call_chain
    result = func(*args)
  File "/usr/lib/python2.7/urllib2.py", line 1215, in https_open
    return self.do_open(httplib.HTTPSConnection, req)
  File "/usr/lib/python2.7/urllib2.py", line 1174, in do_open
    h.request(req.get_method(), req.get_selector(), req.data, headers)
  File "/usr/lib/python2.7/httplib.py", line 958, in request
    self._send_request(method, url, body, headers)
  File "/usr/lib/python2.7/httplib.py", line 992, in _send_request
    self.endheaders(body)
  File "/usr/lib/python2.7/httplib.py", line 954, in endheaders
    self._send_output(message_body)
  File "/usr/lib/python2.7/httplib.py", line 812, in _send_output
    msg += message_body
UnicodeDecodeError: 'ascii' codec can't decode byte 0x89 in position 0: ordinal 
not in range(128)

What version of the product are you using? On what operating system?
I'm the latest svn revision, or r75 of `vi_virtual_machine.py`.  Only testing 
with Python 2.7 on Arch Linux.

Please provide any additional information below.
This problem only started appearing recently--I've been able to send files to 
guest systems without a problem since I started using pysphere a month or two 
ago.  I'm not sure what changed, exactly, but somewhere along the line it 
appears that the "msg" you see in the last line of the stack trace is a unicode 
object while the "message_body" from the same line is a str object.  The "msg" 
variable holds a bunch of header information, while the "message_body" contains 
the actual binary content of the file I'm trying to send.

I've watched/debugged this off and on for a few days, and it seems that the 
problem goes away if I simply force the URL to be a str object sometime before 
this line in vi_virtual_machine.py:

    request = urllib2.Request(url, data=content)

Original issue reported on code.google.com by [email protected] on 30 Jul 2012 at 5:02

Patch for /trunk/pysphere/vi_task.py

Perceive real timeout values as requested. IE: timeout=5

In [19]: time.clock() - start_time
Out[19]: 0.010006999999999877

In [20]: time.clock() - start_time
Out[20]: 0.013527999999999984

In [21]: start_time = time.time()

In [22]: time.time() - start_time
Out[22]: 10.152903079986572

In [23]: time.time() - start_time
Out[23]: 10.824795961380005

Original issue reported on code.google.com by [email protected] on 28 May 2012 at 9:54

Attachments:

Add an Alarm manager class to simplify vSphere alarms API

See 
http://groups.google.com/group/pysphere/browse_thread/thread/2bba503390fbf2a5/97
7cbcfdde6268c7#977cbcfdde6268c7

e.g.

class VIAlarm:

  def list_alarms(...)

  def silence_alarm(...)

we might add some callback functionality where a user can provide a function to 
be called when a particular alarm are sets off

Original issue reported on code.google.com by [email protected] on 21 Mar 2012 at 5:45

Question: Does pysphere support everything possible on vsphere web service APIs

I tried to find information about overall architecture/design of pysphere in 
vain. My question is using pysphere, can I access every property, method, type 
available at vsphere web services level 
(http://www.vmware.com/support/developer/vc-sdk/visdk41pubs/ApiReference/index.h
tml)? Or am I restricted to what's exposed by pysphere client libraries and any 
new access would require enhacing the client lib?

For instance vijava gives complete (100%) access to underlying web services 
functionality

Original issue reported on code.google.com by [email protected] on 5 May 2012 at 12:21

Support disk consolidation

One important part of maintaining snapshots on modern vSphere is consolidating 
disks. pysphere should support this. Related VMWare docs 
http://pubs.vmware.com/vsphere-51/index.jsp?topic=%2Fcom.vmware.wssdk.apiref.doc
%2Fvim.VirtualMachine.html

Original issue reported on code.google.com by [email protected] on 11 Sep 2013 at 11:36

Some resource pools are missing when calling _get_resource_pools()

The method returns a dictionary where keys are the resource pool paths and the 
values their MORs.

This path key is formed by the resource pool name and all its ancestors names 
separated by '/'. For example:
/Resources/AnotherRP/This Resource Pool

However there might be more than one root resource pool. The root rp (not shown 
from the VI Client) generally is named "Resources"
So that is not a unique key for the dictionary, in your case you have two rp 
named "/Resources" so adding the second to the dictionary overwrites the first.

I should probably invert the dictionary, i.e. make their MOR (which have to be 
unique) be the keys and the paths, their values).

This will impact on other functionality of pysphere that uses 
_get_resource_pools, so I'll have to check all the code.


Original issue reported on code.google.com by [email protected] on 20 Jan 2012 at 6:55

Implement upload/download files from datastores.

Implement upload/download files from datastores.

This functionality must be implemented out of the vsphere sdk, they are just 
simple PUT/GET requests to the server.

See: http://communities.vmware.com/message/1540767

Original issue reported on code.google.com by [email protected] on 14 Apr 2012 at 12:03

Just only a feature request for monitoring vmware

Dear pysphere-project-team!

First of all thank you for this really good library.

We are using a nagios environment to monitor our vmware host and their virtual 
machine. How about to get some current useful information like cpu utilization, 
cpu usage, mem usage, net usage, io statistics or storage information over this 
api. In my opinion the execution of a script to monitor a host is much than 
over the perl api. 

A well know perl-script is developed from op5 (check_vmware_api.pl). It is good 
but perl isn't so powerful than python xD

best regards

realburns 

Original issue reported on code.google.com by [email protected] on 17 Apr 2013 at 2:35

Adding cdrom boot image and changing device boot-order

We are looking at a way to boot the system into our own ISO image. So a way to 
add an ISO image from a datastore, as well as changing the boot-order of 
devices.

This second feature is strictly required as we could expect the order to be to 
boot from CD before disk, and simply connecting an image would boot it on 
reboot.

Is this currently already possible ?

Original issue reported on code.google.com by [email protected] on 7 Sep 2012 at 11:03

searching multiple types - thoughts?

I am adding a search feature into my app, and I'm looking for the best way to 
search "everything". Below is my current method. If there a more efficient 
method using the current library?

# search term
search = "esx"
pattern = re.compile(search, flags=re.IGNORECASE)

print "searching..."
items = server.get_hosts()
for item in items:
     if pattern.search(items[item]):
            print "host: %s" % items[item]

items = server.get_datastores()
for item in items:
    if pattern.search(items[item]):
        print "datastore: %s" % items[item]

items = server.get_clusters()
for item in items:
    if pattern.search(items[item]):
        print "cluster: %s" % items[item]

items = server.get_resource_pools()
for item in items:
    if pattern.search(items[item]):
        print "resource_pools: %s" % items[item]

vms = server.get_registered_vms()
for vm in vms:
    if pattern.search(vm):
        print "vm: %s" % vm

Original issue reported on code.google.com by [email protected] on 25 Sep 2012 at 9:32

Can't get MAC address for VMware ESXi 5.0

What steps will reproduce the problem?
class AEsxiServer(object):
    def __init__(self, servername, password,  username='root'):
        self.servername = servername
        self.username = username
        self.password = password
        self.vmlist = []
        self.vmstatusdict = {}
        self.vmmaclist = {}
        self.vmdict = {}
        self.inUseDict = {}

    def connect(self):
        print "connecting to %s" % self.servername
        self.server = VIServer()
        self.server.connect(self.servername, self.username, self.password)
        print "connected to %s" % self.servername
        print "Currently server version is: %s %s" \
            % (self.server.get_server_type(), self.server.get_api_version())

    def get_vmmaclist(self):
        for vmPath in self.get_vmlist():
            vm = self.server.get_vm_by_path(vmPath)
            vminfo = vm.get_properties()
            vmmacinfo = vminfo['mac_address']
            print vmmacinfo

def main():
    print "This is Esxi Server Object"
    S=AEsxiServer('xxxx','xxxx')
    S.connect()
    S.get_vmmaclist()

if __name__ == '__main__':
    main()

results:
print vmmacinfo # it will return "None"

S.get_vmmaclist() will return the following errors
Traceback (most recent call last):
  File "./AsterEsxiServer.py", line 133, in <module>
    main()
  File "./AsterEsxiServer.py", line 125, in main
    asterS.get_vmmaclist()
  File "./AsterEsxiServer.py", line 60, in get_vmmaclist
    vmmacinfo = vminfo['mac_address']
KeyError: 'mac_address'

What is the expected output? What do you see instead?
It should output mac address, but it prompts that don't have the key 
'mac_address'
BTW, I can get 

What version of the product are you using? On what operating system?
RHEL6.5

Please provide any additional information below.


Original issue reported on code.google.com by [email protected] on 30 Dec 2013 at 6:21

Enhancement - RelocateVM_Task

Here's a small patch that implements vSphere API Method "RelocateVM_Task" as 
member function of the VIVirtualMachine class:

 * pysphere.vi_virtual_machine.VIVirtualMachine.relocate()


> What version of the product are you using? On what operating system?
Against latest SVN checkout; tested on both Ubuntu 12.04 x64 and Windows XP x64.

-- Chris

PS: Thanks for the quality module.

Original issue reported on code.google.com by [email protected] on 31 Jul 2012 at 10:49

Attachments:

Timeout when running a long process on VM and waiting for it to complete

What steps will reproduce the problem?
1. Used a Windows VM
2. Issued a remote command that takes a long time
   (you can simulate this by a batch program that just waits 
    around for 20 or more minutes)
3. Issue the VM's list_processes waiting for the exit_code to be set

What is the expected output? What do you see instead?
Expect the exit_code to eventually get set.  Instead, get the following error:
  File "test.py", line 154, in _getProcess
    processes = vm.list_processes() 
File 
"/root/Perforce/ToolsAutomation/PEToolsDepot/ToolsAutomation/VSAInstaller/python
/pysphere/vi_virtual_machine.py", line 1236, in list_processes
    raise VIApiException(e)
pysphere.resources.vi_exception.VIApiException: 
[GuestOperationsUnavailableFault]: The guest operations agent could not be 
contacted.

What version of the product are you using? On what operating system?
0.1.6 
Linux (CentOS 5.3)
(also failed same way under Windows, so it has more to do with the SOAP 
interface)

Please provide any additional information below.


Original issue reported on code.google.com by [email protected] on 1 Mar 2012 at 5:37

TypeError for ZSI NoHost_Def Options

Original mail from John Calcote. (see 
http://groups.google.com/group/pysphere/browse_thread/thread/81d97515a223e5e9#)

Hi Seba, 
I think I ran into a bug in pysphere - it may be in ZSI itself. I got 
the following TraceBack when attempting to call 
AcquireCIMServicesTicket on the VIServer instance with a managed 
object reference to a host that was currently disconnected: 
Traceback (most recent call last): 
  File "c:\fusion\fio-esx-agent-mgr-script.py", line 15, in <module> 
    fioesxagentmgr.main() 
  File "c:\users\jcalcote\dev\hg\management\src\util\vmware\fio-agent- 
cim\src\fioesxagentmgr\__init__.py", line 80, in main 
    esx_manager.poll_for_config_changes() 
  File "c:\users\jcalcote\dev\hg\management\src\util\vmware\fio-agent- 
cim\src\fioesxagentmgr\esxmgr.py", line 251, in 
poll_for_config_changes 
    ticket = self._get_host_services_ticket(mor) 
  File "c:\users\jcalcote\dev\hg\management\src\util\vmware\fio-agent- 
cim\src\fioesxagentmgr\esxmgr.py", line 150, in 
_get_host_services_ticket 
    response = self._server._proxy.AcquireCimServicesTicket(request) 
  File "c:\users\jcalcote\dev\hg\management\src\util\vmware\fio-agent- 
cim\eggs\pysphere-0.1.6-py2.7-win32.egg\pysphere\resources 
\VimService_services.py", line 1416, in AcquireCimServicesTicket 
    response = 
self.binding.Receive(AcquireCimServicesTicketResponseMsg.typecode) 
  File "c:\users\jcalcote\dev\hg\management\src\util\vmware\fio-agent- 
cim\eggs\pysphere-0.1.6-py2.7-win32.egg\pysphere\ZSI\client.py", line 
549, in Receive 
    return _Binding.Receive(self, replytype, **kw) 
  File "c:\users\jcalcote\dev\hg\management\src\util\vmware\fio-agent- 
cim\eggs\pysphere-0.1.6-py2.7-win32.egg\pysphere\ZSI\client.py", line 
467, in Receive 
    msg = FaultFromFaultMessage(self.local.ps) 
  File "c:\users\jcalcote\dev\hg\management\src\util\vmware\fio-agent- 
cim\eggs\pysphere-0.1.6-py2.7-win32.egg\pysphere\ZSI\fault.py", line 
253, in FaultFromFaultMessage 
    pyobj = ps.Parse(FaultType.typecode) 
  File "c:\users\jcalcote\dev\hg\management\src\util\vmware\fio-agent- 
cim\eggs\pysphere-0.1.6-py2.7-win32.egg\pysphere\ZSI\parse.py", line 
326, in Parse 
    return how.parse(self.body_root, self) 
  File "c:\users\jcalcote\dev\hg\management\src\util\vmware\fio-agent- 
cim\eggs\pysphere-0.1.6-py2.7-win32.egg\pysphere\ZSI\TCcompound.py", 
line 203, in parse 
    value = what.parse(c_elt, ps) 
  File "c:\users\jcalcote\dev\hg\management\src\util\vmware\fio-agent- 
cim\eggs\pysphere-0.1.6-py2.7-win32.egg\pysphere\ZSI\TCcompound.py", 
line 206, in parse 
    value = what.parse(c_elt, ps) 
  File "c:\users\jcalcote\dev\hg\management\src\util\vmware\fio-agent- 
cim\eggs\pysphere-0.1.6-py2.7-win32.egg\pysphere\ZSI\TC.py", line 
1455, in parse 
    pyobj = what.parse(elt, ps) 
  File "c:\users\jcalcote\dev\hg\management\src\util\vmware\fio-agent- 
cim\eggs\pysphere-0.1.6-py2.7-win32.egg\pysphere\ZSI\TCcompound.py", 
line 147, in parse 
    what = TypeDefinition.getSubstituteType(self, elt, ps) 
  File "c:\users\jcalcote\dev\hg\management\src\util\vmware\fio-agent- 
cim\eggs\pysphere-0.1.6-py2.7-win32.egg\pysphere\ZSI\schema.py", line 
296, in getSubstituteType 
    (self.type[0], self.type[1], pyclass), ps.Backtrace(elt)) 
TypeError: ("Substitute Type (urn:vim25, NoHost) is not derived from 
<class 'pysphere.resources.VimService_services_types.NoHost_Def'>", u'/ 
soapenv:Envelope/soapenv:Body/soapenv:Fault/detail/NoHostFault') 

It looks like it should have thrown a NoHost exception, but instead it 
throws a TypeError. 
Thanks in advance, 
John

Original issue reported on code.google.com by [email protected] on 16 Mar 2012 at 5:38

Separate methods for sync and async tasks

Methods triggering tasks returns different object types depending on the value 
of the sync_run parameter which might be confusing. These should probably be 
implemented on separate methods.

If this is implemented, the sync_run parameter should still be supported for a 
few versions (showing a deprecation warning).

Pros:
 - clarity, a method will only return a specified type of result

Cons:
 - lots of new methods will be added. E.g. clone_async (or clone_task), revert_to_snapshot_async (revert_to_snapshot_task), etc. This might be even more confusing
 - handle backwards compatibility

Related to: https://code.google.com/p/pysphere/issues/detail?id=20

Original issue reported on code.google.com by [email protected] on 10 Sep 2012 at 3:33

duplicated snapshots list

What steps will reproduce the problem?
1. vm = server.get_vm_by_name('some-existing-vm')
2. len(vm.get_snapshots()) # f.i 3
3. vm.refresh_snapshot_list()
4. len(vm.get_snapshots()) # 6 - duplicated

worse case (my case :) ):
1. vm = server.get_vm_by_name('some-existing-vm') # vm has 4 snapshots
2. vm.create_snapshot('12/12/2011') # snapshot will be 'refreshed' transparently
3. # now i'm removing snapshots over KEEP_OLD_SNAPSHOTS=4
4. i lost all my snapshots in that keys instead of oldest one

What is the expected output? What do you see instead?
 * snapshots list should be cleared and next filled with current state


What version of the product are you using? On what operating system?
 * pysphere 0.1.5
 * python 2.6
 * debian squeeze


Please provide any additional information below.

in file 
http://code.google.com/p/pysphere/source/browse/trunk/pysphere/vi_virtual_machin
e.py at line 1430:
 * snapshots are appended into self._root_snapshots
 * but self._root_snapshots is only cleared while creating new VIVirtualMachine in __init__
 * i think it should by cleared before "for root_snap in self.properties.snapshot.rootSnapshotList:
"


Original issue reported on code.google.com by [email protected] on 20 Dec 2011 at 12:57

VIVirtualMachine.get_status() causes error in ESXi "Recent Tasks"

What steps will reproduce the problem?

    1. Do `vm.get_status()`
    2. Log into ESXi server using vSphere Client, look in Recent Tasks

What is the expected output? What do you see instead?

    I don't expect to have an error in the log, but instead I see the attached file.

    ("Create task collector" --- "The operation is not supported on the object.")

What version of the product are you using? On what operating system?

    pysphere==0.1.6
    VMware ESXi 4.1.0

Please provide any additional information below.

    Despite the error, functionally it appears to work.

Original issue reported on code.google.com by [email protected] on 27 Sep 2012 at 10:19

Attachments:

start_command runs asynchronously

What steps will reproduce the problem?

While running a long running command, the API call will return before
completing.   This causes race conditions and there is no option
to run synchronously or get_state.


What version of the product are you using? On what operating system?
1.7, RedHat 6

Original issue reported on code.google.com by [email protected] on 14 Mar 2013 at 8:40

[patch] add support for guest_dists

The current API does not include the GuestDiskInfo data as described in 
http://www.vmware.com/support/developer/vc-sdk/visdk41pubs/ApiReference/

The attached patch adds them. I'm happy to rename the property or a different 
approach if you prefer. Feedback welcome.

Cheers,
 Michael

Original issue reported on code.google.com by [email protected] on 5 Dec 2013 at 1:34

Attachments:

get_properties() - Storage

Is there any way to get the allocated disk space for a specific host?
I need to run a comprehensive Python script against a few thousand machines and 
one of the key things i need to fetch is allocated disk space.


I can not find any documentation on it, nor can i find anything in the source 
codes, is this feature completely left out?

Original issue reported on code.google.com by [email protected] on 5 Dec 2011 at 8:36

vm.list_processes()

1. pid = self.vm.start_process(r'c:\windows\system32\calc.exe', arg)
2. vm.list_processes() >>> pid found as expected.
3. kill the process.
4. vm.list_processes() >>> pid still being listed.

That's an error i guess.

pysphere 0.1.7, Python 2.6, ESXi 5.0, Windows XP SP3 guest, Windows 7 64bits 
host.

I'm writing a function to start process in guest and wait until process be dead.

Original issue reported on code.google.com by [email protected] on 27 Mar 2013 at 2:44

Error creating vm instance (by Harish)

Reported by Harish


Code:
{{{
from pysphere import VIServer
server = VIServer()
server.connect("192.168.3.30", "root", "root123")
vmlist = server.get_registered_vms()
print server.get_registered_vms()
vm1 = server.get_vm_by_name("Win64-7")
vm2 = server.get_vm_by_path("[datastore2] Win64-7/Win64-7.vmx")´
print vm1.get_status()
print vm2.get_status()
server.disconnect() 
}}}

Error:

{{{
Python 2.7.1 (r271:86832, Nov 27 2010, 18:30:46) [MSC v.1500 32 bit (Intel)] on 
win32 Type "copyright", "credits" or "license()" for more information. 

'[datastore2] RHEL64-5.3 ES/RHEL64-5.3 ES.vmx', 'datastore2? 
Win64-7/Win64-7.vmx', '[datastore2] New Virtual Machine/New Virtual 
Machine.vmx'] 

Traceback (most recent call last): 

File "C:\Documents and Settings\hmunagapati\Desktop\vm_py\test.py", line 
10, in <module> 
vm1 = server.get_vm_by_name("Win64-7") 
File "C:\Python27\lib\site-packages\pysphere\vi_server.py", line 218, in 
get_vm_by_name 
return VIVirtualMachine(self, mor) 
File "C:\Python27\lib\site-packages\pysphere\vi_virtual_machine.py", line 
47, in init 
self.update_properties() 
File "C:\Python27\lib\site-packages\pysphere\vi_virtual_machine.py", line 
741, in update_properties 
self.mor, get_all=True) 
File "C:\Python27\lib\site-packages\pysphere\vi_server.py", line 396, in 
get_object_properties 
return request_call(request) 
File "C:\Python27\lib\site-packages\pysphere\vi_server.py", line 696, in 
call_retrieve_properties 
return self.proxy.RetrieveProperties?(request).returnval 
File 
"C:\Python27\lib\site-packages\pysphere\resources\VimService?_services.py", 
line 61, in RetrieveProperties? 
response = self.binding.Receive(RetrievePropertiesResponseMsg?.typecode) 
File "C:\Python27\lib\site-packages\pysphere\ZSI\client.py", line 544, in 
Receive 
return Binding.Receive(self, replytype, kw) 
File "C:\Python27\lib\site-packages\pysphere\ZSI\client.py", line 469, in 
Receive 
reply = self.ps.Parse(tc) 
File "C:\Python27\lib\site-packages\pysphere\ZSI\parse.py", line 326, in 
Parse 
return how.parse(self.body_root, self) 
File "C:\Python27\lib\site-packages\pysphere\ZSI\TCcompound.py", line 
203, in parse 
value = what.parse(c_elt, ps) 
File "C:\Python27\lib\site-packages\pysphere\ZSI\TCcompound.py", line 
203, in parse 
value = what.parse(c_elt, ps) 
File "C:\Python27\lib\site-packages\pysphere\ZSI\TCcompound.py", line 
203, in parse 
value = what.parse(c_elt, ps) 
File "C:\Python27\lib\site-packages\pysphere\ZSI\TC.py", line 1392, in 
parse 
pyobj = what.parse(elt, ps) 
File "C:\Python27\lib\site-packages\pysphere\ZSI\TCcompound.py", line 
203, in parse 
value = what.parse(c_elt, ps) 
File "C:\Python27\lib\site-packages\pysphere\ZSI\TC.py", line 446, in 
parse 
pyobj = self.text_to_data(v, elt, ps) 
File "C:\Python27\lib\site-packages\pysphere\ZSI\TCtimes.py", line 211, 
in text_to_data 
retval = fix_timezone(retval, tz_from = m.groupdict().get('tz'), tz_to 
= None) 
File "C:\Python27\lib\site-packages\pysphere\ZSI\TCtimes.py", line 98, in 
fix_timezone 
ltv:6? = datetime((ltv:6? + [0, 
tz_from])).astimezone(tz_to).timetuple():6? 
File "C:\Python27\lib\site-packages\pysphere\ZSI\TCtimes.py", line 48, in 
utcoffset 
dt.hour, dt.minute, dt.second, dt.weekday(), 0, -1))) 
OverflowError?: mktime argument out of range 
}}}




Original issue reported on code.google.com by [email protected] on 30 Nov 2011 at 7:56

PerfCompositeMetric instance has attribute 'entity' and ChildEntity


I could see an attribute check in method "get_entity_statistic" of 
vi_performance_manager.py

if composite:
            if hasattr(query, "Entity"):
                stats.extend(query.Entity.Value)
            if hasattr(query, "ChildEntity"):
                for item in query.ChildEntity:
                    stats.extend(item.Value)
        else:
            if hasattr(query[0], "Value"):
                stats = query[0].Value


When will happen this situation ???
AttributeError: PerfCompositeMetric instance has no attribute 'entity'
AttributeError: PerfCompositeMetric instance has no attribute 'ChildEntity'

Is this the only way to do it. 

Why can't we check value of attibutes (currentSupported or summarySupported) of 
PerfProviderSummary and proceed.






Original issue reported on code.google.com by [email protected] on 26 Nov 2012 at 8:30

currentBalance and targetBalance Key/Values for ClusterComputeResource

What steps will reproduce the problem?
1.
properties = ["summary.targetBalance"]

results = s._retrieve_properties_traversal(property_names=properties,
                                           obj_type=MORTypes.ClusterComputeResource)


for item in results:
    print "=" * 80
    print "MOR:", item.Obj
    for p in item.PropSet:
        print p.Name, "=>", p.Val


What is the expected output? 
the same as effectiveCpu

What do you see instead?
Invalid Property Type

What version of the product are you using? On what operating system?
pysphere-0.1.7

Please provide any additional information below.
They keys are there
['AdmissionControlInfo', 'CurrentBalance', 'CurrentEVCModeKey', 
'CurrentFailoverLevel', 'DasData', 'DynamicProperty', '
DynamicType', 'EffectiveCpu',....


Output from

mors = s.get_datacenters().keys() + s.get_clusters().keys() + 
s.get_hosts().keys() + s._get_managed_objects(MORTypes.VirtualMachine).keys()
# for mor in mors: print mor
props = {MORTypes.ClusterComputeResource:[]}
results = s._get_object_properties_bulk(mors, props)


for host in results:
    for prop in host.PropSet:
       print "prop Name"
       print "========="
       print dir(prop.Name)
       print "prop Val"
       print "========="
       print dir(prop.Val)



Original issue reported on code.google.com by [email protected] on 15 Nov 2013 at 10:52

login_in_guest() Failed with Unix Login

Was able to log in to ESXi and find the VM by name, then any attempts to log in 
to the VM fail. I am able to connect and login to a Windows guest just fine. I 
created additional users in my unix VM and tested, all of which failed the same 
with the following error:
Traceback (most recent call last):
  File "./test.py", line 20, in <module>
    vm.login_in_guest("user1", "password")
  File "/usr/local/lib/python2.7/dist-packages/pysphere/vi_virtual_machine.py", line 1044, in login_in_guest
    self.__validate_authentication(auth)
  File "/usr/local/lib/python2.7/dist-packages/pysphere/vi_virtual_machine.py", line 1722, in __validate_authentication
    raise VIApiException(e)
pysphere.resources.vi_exception.VIApiException: [InvalidGuestLoginFault]: 
Failed to authenticate with the guest operating system using the supplied 
credentials.

System info of the VM running the script:
root@test:~# uname -a
Linux archive 3.2.0-51-generic-pae #77-Ubuntu SMP Wed Jul 24 20:40:32 UTC 2013 
i686 athlon i386 GNU/Linux
root@test:~# cat /proc/version
Linux version 3.2.0-51-generic-pae (buildd@komainu) (gcc version 4.6.3 
(Ubuntu/Linaro 4.6.3-1ubuntu5) ) #77-Ubuntu SMP Wed Jul 24 20:40:32 UTC 2013
root@test:~# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 12.04.2 LTS
Release:        12.04
Codename:       precise

See ubuntu.png for the version information of the VM (only able to get console 
access and no copy/paste for text mode)

The VM is running an updated version on VMware tools.
-See ubuntu2.png picture

Finally, I tested this on an Ubuntu Desktop VM and a different Ubuntu Server 
VM, all of which returned the same error as above.

Let me know if I need to provide any further information.


Original issue reported on code.google.com by [email protected] on 17 Sep 2013 at 6:18

Attachments:

Error using guest send_file function in IPv6 enviroment - address mangled

What steps will reproduce the problem?
1. Start python console
2. Load pysphere module
3. Create pysphere instance and connect to ESXi server (successful) 
4. create vm instance using get_vm_by_name()
5. Set guest credentials using vm.login_in_guest()
6. Attempt to push local file to guest file system using vm.send_file() 
function.  This produces the error below.  

What is the expected output? What do you see instead?
Successful push of file from local system to guest system

What version of the product are you using? On what operating system?
Current - 0.1.8

Please provide any additional information below.

From initial trouble shooting it appears the IPv6 address somewhere in the 
process to use the urllib2.py library.  Looks like the ":" colons are being 
used somewhere to split the address up expecting a port and is ignoring the 
wrapping square brackets "[]".
initial ipv6 address = "[fd30:f8fe:a3af:4466::100]"
resulting url var looking like this....
url = "[fd30:"

Currently I am seeing this by looking in some print statements in the 
vm_virtual_machine.py around line 1292. "url = url.replace("*", 
urlparse(self._server._proxy.binding.url).hostname)"


Python session below
###############################################

Python 2.6.6 (r266:84292, May 27 2013, 05:35:12) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from pysphere import *
>>> s = VIServer()
>>> s.connect("[fd30:f8fe:a3af:4466::100]", "admin", "adminpass")
>>> vm = s.get_vm_by_name("IPV6guest")
>>> vm.login_in_guest("guestuser","guestpass")
>>> stat = 
vm.send_file("/etc/puppet/manifests/site.pp","/etc/puppet/manifests/site.pp", 
True)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/pyve/mdms/lib/python2.6/site-packages/pysphere/vi_virtual_machine.py", line 1301, in send_file
    resp = urllib2.urlopen(request)
  File "/usr/lib64/python2.6/urllib2.py", line 126, in urlopen
    return _opener.open(url, data, timeout)
  File "/usr/lib64/python2.6/urllib2.py", line 391, in open
    response = self._open(req, data)
  File "/usr/lib64/python2.6/urllib2.py", line 409, in _open
    '_open', req)
  File "/usr/lib64/python2.6/urllib2.py", line 369, in _call_chain
    result = func(*args)
  File "/usr/lib64/python2.6/urllib2.py", line 1198, in https_open
    return self.do_open(httplib.HTTPSConnection, req)
  File "/usr/lib64/python2.6/urllib2.py", line 1165, in do_open
    raise URLError(err)
urllib2.URLError: <urlopen error [Errno -2] Name or service not known>

Original issue reported on code.google.com by [email protected] on 16 Jan 2014 at 6:22

Feature request: return vm's uuid, get_vm_by_uuid

This is two related requets. Since most other systems rely on the VM's uuid, I 
propose:

1. Have a function or flag on get_registered_vms that returns the uuid of a vm 
(..., returnUUID=False). I do see that this information is available under 
VirtualMachineConfigSummary_Def.

2. Implement a get_vm_by_uuid function.

Additionally, as other object (such as vcenter) have a uuid, start looking at 
how to expose this information and select object by uuid.


Original issue reported on code.google.com by [email protected] on 25 Sep 2012 at 10:11

VixVM_WaitForToolsInGuest



Are there any plans to implement the 'VixVM_WaitForToolsInGuest' function.  
Right now, if you revert from a snapshot and attempt to access guest functions, 
vmware tools needs time to initialize or you can crash the guest.

Original issue reported on code.google.com by [email protected] on 27 Jan 2014 at 6:09

This line/command "import pysphere" generates this: "ImportError: cannot import name VIProperty"

What steps will reproduce the problem?
   Using the code in the SVN trunk
   Doing 'python ./setup.py install'
   Then at an interactive python (v2.6) prompt, typing: 
        import pysphere

   This results in the following output:
   [ ... ]
     File "pysphere/vi_performance_manager.py", line 31, in <module>
       from pysphere import VIProperty
   ImportError: cannot import name VIProperty
   >>>>

This happens on Linux (Ubuntu 10.04.03), as well as on MacOSX (Python 2.7 in 
that environment).
Applying the attached patch (then re-installing) resolved this problem for me.

Original issue reported on code.google.com by [email protected] on 9 Apr 2012 at 7:21

Attachments:

Provide "public" get_mor method

It would be great if there was a "public" get_mor() method (I'm currently using 
the _mor property).

Use case: This is an easy way to get snapshots and display them in a web page 
(a lot faster that either of the clients), see option 2 here:
http://blogs.vmware.com/vsphere/2013/01/capturing-virtual-machine-screenshots-in
-vsphere.html

ie: use the URL: https://10.24.145.65/screen?id=vm-162

Original issue reported on code.google.com by [email protected] on 25 Jan 2013 at 7:38

how to run python in remote machine ?

What steps will reproduce the problem?
1. vm.start_process(r"c:\my.py"),  

you can read more about the problem in: 
https://groups.google.com/group/pysphere/browse_thread/thread/9b705990d68b968d

What is the expected output? What do you see instead?
running python module. or a python script easily 

What version of the product are you using? On what operating system?
latest.

Please provide any additional information below.

Original issue reported on code.google.com by [email protected] on 28 May 2012 at 10:59

TypeError: duplicate base class DynamicData_Def

What steps will reproduce the problem?
Unknown.  Problem happens randomly on 10% of the VM guests.

What is the expected output? What do you see instead?


What version of the product are you using? On what operating system?
PySphere 0.1.8.  OS is Windows XP through 8.1 (not version specific).

Please provide any additional information below.

Traceback (most recent call last):
  File "C:\p4root\depot\Systems_Software\Products\Client_IDS\temporary_dev_area\tnili\cidsauto\vsphere\vsphere.py", line 46, in run
    vm1 = server.get_vm_by_path(server_path)
  File "C:\Python27\lib\site-packages\pysphere\vi_server.py", line 286, in get_vm_by_path
    return VIVirtualMachine(self, vm)
  File "C:\Python27\lib\site-packages\pysphere\vi_virtual_machine.py", line 55, in __init__
    self.__update_properties()
  File "C:\Python27\lib\site-packages\pysphere\vi_virtual_machine.py", line 1801, in __update_properties
    p['name'] = self.properties.name
  File "C:\Python27\lib\site-packages\pysphere\vi_property.py", line 71, in __getattr__
    self._get_all()
  File "C:\Python27\lib\site-packages\pysphere\vi_property.py", line 53, in _get_all
    oc = self._server._get_object_properties(self._obj, get_all=True)
  File "C:\Python27\lib\site-packages\pysphere\vi_server.py", line 484, in _get_object_properties
    ret = request_call(request)
  File "C:\Python27\lib\site-packages\pysphere\vi_server.py", line 733, in call_retrieve_properties_ex
    request)._returnval
  File "C:\Python27\lib\site-packages\pysphere\resources\VimService_services.py", line 114, in RetrievePropertiesEx
    response = self.binding.Receive(RetrievePropertiesExResponseMsg.typecode)
  File "C:\Python27\lib\site-packages\pysphere\ZSI\client.py", line 545, in Receive
    return _Binding.Receive(self, replytype, **kw)
  File "C:\Python27\lib\site-packages\pysphere\ZSI\client.py", line 470, in Receive
    reply = self.local.ps.Parse(tc)
  File "C:\Python27\lib\site-packages\pysphere\ZSI\parse.py", line 325, in Parse
    return how.parse(self.body_root, self)
  File "C:\Python27\lib\site-packages\pysphere\ZSI\TCcompound.py", line 199, in parse
    value = what.parse(c_elt, ps)
  File "C:\Python27\lib\site-packages\pysphere\ZSI\TCcompound.py", line 199, in parse
    value = what.parse(c_elt, ps)
  File "C:\Python27\lib\site-packages\pysphere\ZSI\TCcompound.py", line 199, in parse
    value = what.parse(c_elt, ps)
  File "C:\Python27\lib\site-packages\pysphere\ZSI\TCcompound.py", line 199, in parse
    value = what.parse(c_elt, ps)
  File "C:\Python27\lib\site-packages\pysphere\ZSI\TC.py", line 1392, in parse
    pyobj = what.parse(elt, ps)
  File "C:\Python27\lib\site-packages\pysphere\ZSI\TCcompound.py", line 187, in parse
    if callable(what): what = what()
  File "C:\Python27\lib\site-packages\pysphere\ZSI\schema.py", line 350, in _reveal_type
    **self.__kw)
  File "C:\Python27\lib\site-packages\pysphere\resources\VimService_services_types.py", line 43114, in __init__
    ns0.GuestScreenInfo_Def.__bases__ = tuple(bases)
TypeError: duplicate base class DynamicData_Def

Original issue reported on code.google.com by [email protected] on 19 Sep 2013 at 8:38

Templates

We are using vCenter 5.0 and our team has created many templates from which 
VM's are deployed.  I would like to know if pysphere can be used to automate 
this process.

The docs for VIVirtualMachine.clone seem to indicate that this is possible 
although I could not get it to work.

>>> vms = server.get_registered_vms()
>>> templates = [vm for vm in vms if '[iSCSI-Templates]' in vm]
>>> templates[1]
'[iSCSI-Templates] 
WindowsVista-SP1-IE8-x86-Template/WindowsVista-SP1-IE8-x86-Template.vmtx'
>>> vm = server.get_vm_by_path(templates[1])
>>> new_vm = vm.clone("Clone")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python27\lib\site-packages\pysphere\vi_virtual_machine.py", line 537,
 in clone
    FaultTypes.TASK_ERROR)
pysphere.resources.vi_exception.VIException: [Task Error]: The operation is not
allowed in the current state of the host.

Original issue reported on code.google.com by [email protected] on 12 Sep 2013 at 8:16

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.