Giter Club home page Giter Club logo

Comments (8)

giriatgit avatar giriatgit commented on June 8, 2024

How to enable logs in this code so that we understand whats happening behind the REST APIs? I tired following but still no logs or output.

import logging

logging.getLogger("requests").setLevel(logging.DEBUG)
logging.getLogger('urllib3').setLevel(logging.DEBUG)

from vsphere-automation-sdk-python.

aagrawal3 avatar aagrawal3 commented on June 8, 2024

Please share following details:

  • Installation type: typical/local/air-gapped
  • Environment details such as Python, Setuptools and pip version.
  • Steps to reproduce

Our listVM sample is also available in samples dir and detailed instructions to install SDK and run samples are available in README. Please refer to quick start guide and run SDK samples sections.

from vsphere-automation-sdk-python.

girishkumarbk avatar girishkumarbk commented on June 8, 2024

Installation type is Typical.

(vCenterDemo) (base) girish$ pip3 --version
pip 23.1.2 from /Users/../lib/python3.7/site-packages/pip (python 3.7)
(vCenterDemo) (base) girish$
(vCenterDemo) (base) girish$
(vCenterDemo) (base) girish$ python3 --version
Python 3.7.6
(vCenterDemo) (base) girish$
(vCenterDemo) (base) girish$

Steps to reproduce:
(1) Update the sample code with vCenter server ip, user credentials
(2) Run python3 my sample.py (The code is pasted in earlier message) The sample given at https://github.com/vmware/vsphere-automation-sdk-python/tree/v8.0.0.1

from vsphere-automation-sdk-python.

aagrawal3 avatar aagrawal3 commented on June 8, 2024

Please try this (replace values in placeholders for IP, Username and Password):

import requests
import urllib3
from vmware.vapi.vsphere.client import create_vsphere_client
session = requests.session()

# Disable cert verification for demo purpose.
# This is not recommended in a production environment.
session.verify = False

# Disable the secure connection warning for demo purpose.
# This is not recommended in a production environment.
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

# Connect to a vCenter Server using username and password
vsphere_client = create_vsphere_client(server='<vc_ip>', username='<vc_username>', password='<vc_password>', session=session)

# List all VMs inside the vCenter Server
list_of_vms = vsphere_client.vcenter.VM.list()

print("List Of VMs")
print("----------------------------")
print(list_of_vms)
print("----------------------------")

from vsphere-automation-sdk-python.

girishkumarbk avatar girishkumarbk commented on June 8, 2024

Hi. Just tried the above code. but still no Vms.

(vCenterDemo) (base) girish$ python3 vCClient2.py
List Of VMs

[]

from vsphere-automation-sdk-python.

girishkumarbk avatar girishkumarbk commented on June 8, 2024

(vCenterDemo) (base) girish $ python3 vCClient2.py
List Of VMs

[ ]

from vsphere-automation-sdk-python.

girishkumarbk avatar girishkumarbk commented on June 8, 2024

Nevermind. Got the output.

Summary(vm='vm-16', name='vm-001', power_state=State(string='POWERED_ON'), cpu_count=2, memory_size_mib=8192)]

from vsphere-automation-sdk-python.

girishkumarbk avatar girishkumarbk commented on June 8, 2024

Thanks.

from vsphere-automation-sdk-python.

Related Issues (20)

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.