Git Product home page Git Product logo

handle-esxi-hosts-vcenter-python's Introduction

handle-esxi-hosts

Some Python modules used to handle ESXi Hosts:

  • Add a standalone ESXi Host to a Cluster with vSAN enabled or not
  • Move an ESXi Host from a cluster to another
  • Remove an ESXi Host from the vCenter inventory

Bonus: Print out the vCenter inventory

Those moduels use pyVmomi (VMware vSphere API Python)

import vcenter_helper
import handle_esxi_host
import sys

vc_details = {
    'host': '10.162.54.10',
    'user': '[email protected]',
    'pwd': '****',
}


def main(argv):
    # Establish connection with vCenter
    vc_si = vcenter_helper.create_connection_to_endpoint(
                                    ip_address=vc_details['host'],
                                    username=vc_details['user'],
                                    password=vc_details['pwd'])


    # Print vC Inventory
    vcenter_helper.print_vc_inventory(vc_serviceInstance=vc_si)


    # Add a standalone ESXi Host to a Cluster with vSAN enabled
    cluster = handle_esxi_host.get_cluster_object_from_vc(
                                 vc_serviceInstance=vc_si,
                                 target_cluster_name='cls')
    handle_esxi_host.add_standalone_esxi_host(
                                vc_serviceInstance=vc_si,
                                host_ip='10.160.178.123',
                                hostUserName='root',
                                hostPassword='',
                                dest_cluster=cluster,
                                cluster_vsan_enabled=True)


    # Move an ESXi Host from a cluster to another
    ## Get Cluster object (assuming a second cluster named 'cluster-test' got created)
    second_cluster = handle_esxi_host.get_cluster_object_from_vc(
                                 vc_serviceInstance=vc_si,
                                 target_cluster_name='cluster-test')
    ## Get Host object
    host = handle_esxi_host.get_host_object_from_vc(
                                vc_serviceInstance=vc_si,
                                target_host_name='10.145.6.172')
    ## Move the ESXi Host from its original cluster to the other cluster
    handle_esxi_host.move_host_to_another_cluster(
                                 host=host,
                                 dest_cluster=second_cluster)


    # Remove an ESXi Host from the vCenter Inventory
    handle_esxi_host.remove_host_from_vc_inventory(host)


if __name__ == "__main__":
    main(sys.argv)

handle-esxi-hosts-vcenter-python's People

Watchers

 avatar  avatar

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.