Skip to content

python warning and guide restructuring #7896

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: vSphere SDK verwenden
excerpt: Erfahren Sie hier, wie Sie das vSphere SDK einrichten und verwenden
updated: 2020-11-18
updated: 2025-05-21
---

## Ziel
Expand All @@ -10,47 +10,55 @@ Aktionen in Ihrer Infrastruktur können mithilfe des vSphere SDK automatisiert w

**Diese Anleitung erklärt, wie Sie das vSphere SDK in verschiedenen Programmiersprachen einrichten und verwenden.**

## Voraussetzungen

- Sie haben Zugriff auf Ihr [OVHcloud Kundencenter](/links/manager).
- Eine virtuelle Maschine, die mit einem unserer [OVF-Templates](/pages/bare_metal_cloud/managed_bare_metal/ovf_template) erstellt wurde.


> [!warning]
> Die folgenden Codebeispiele wurden mit Python 2.7 erstellt. Beachten Sie, dass Sie Ihren Code möglicherweise anpassen müssen, wenn Ihre Umgebung Debian 12 verwendet. In diesem Fall empfehlen wir Ihnen, die neueste Version von Python 3 herunterzuladen.
>

## In der praktischen Anwendung

### Python

#### Umgebung einrichten

##### Betriebssystem

Dieses Beispiel verwendet eine auf Debian 9 installierte VM, die mithilfe der [für Ihre Managed Bare Metal bereitgestellten Templates](/pages/bare_metal_cloud/managed_bare_metal/ovf_template) deployt wurde.

##### Voraussetzungen
Dieses Beispiel verwendet eine mit Debian 9 installierte VM, die aus [Templates für Ihre Managed Bare Metal Infrastruktur](/pages/bare_metal_cloud/managed_bare_metal/ovf_template) bereitgestellt wird.

Folgende Pakete müssen installiert werden:

```
```bash
apt-get install python git python-pip
```
##### vSphere SDK

#### vSphere SDK

Laden Sie das vSphere SDK mit folgendem Befehl herunter:

```
```bash
git clone https://github.com/vmware/vsphere-automation-sdk-python.git
```
Das Verzeichnis “/vsphere-automation-sdk-python” wird erstellt. Gehen Sie in diesen Ordner, um den Installationsbefehl auszuführen:

```
Das Verzeichnis `/vsphere-automation-sdk-python` wird erstellt. Wechseln Sie zu diesem Ordner, um den Installationsbefehl auszuführen:

```bash
pip install --upgrade --force-reinstall -r requirements.txt --extra-index-url file:///<absolute_path_to_sdk>/lib
```

Im vorliegenden Beispiel handelt es sich um folgenden Befehl:

```
```bash
pip install --upgrade --force-reinstall -r requirements.txt --extra-index-url file:///root/vsphere-automation-sdk-python/lib
```

Sobald das SDK installiert ist, können Sie Skripte verwenden.

#### Skriptbeispiel
### Beispielskript

##### Verbindung
#### Verbindung

Dieses Beispiel testet Login und Logout von vCenter. Hierbei können Sie auch überprüfen, ob alles korrekt installiert ist:

Expand Down Expand Up @@ -83,7 +91,7 @@ print("Disconnecting..")
vconnect()
```

##### VMs einer Managed Bare Metal auflisten
#### Auflisten der in Managed Bare Metal vorhandenen VMs

In diesem Beispiel werden alle VMs in der Managed Bare Metal aufgelistet:

Expand Down Expand Up @@ -132,45 +140,41 @@ vconnect()

#### Umgebung einrichten

##### Betriebssystem

Wir verwenden hier eine auf Ubuntu 18.04 installierte VM, die mithilfe der [für Ihre Managed Bare Metal bereitgestellten Templates](/pages/bare_metal_cloud/managed_bare_metal/ovf_template) deployt wurde.

##### Voraussetzungen
Dieses Beispiel verwendet eine mit Ubuntu 18.04 installierte VM, die aus [Templates für Ihre Managed Bare Metal Infrastruktur verfügbar](/pages/bare_metal_cloud/managed_bare_metal/ovf_template) bereitgestellt wird.

Folgende Pakete müssen installiert werden:

```
```bash
apt-get install lib32z1 lib32ncurses5 uuid uuid-dev libssl-dev perl-doc libxml-libxml-perl libcrypt-ssleay-perl libsoap-lite-perl libdata-compare-perl libmodule-build-perl libuuid-perl libsocket6-perl libnet-inet6glue-perl libarchive-zip-perl
```

```
```bash
cpan install Crypt::OpenSSL::RSA UUID::Random Exception::Class Crypt::X509 List::MoreUtils
```

##### vSphere SDK
#### vSphere SDK

Laden Sie das vSphere SDK über folgenden Link herunter:

[https://my.vmware.com/group/vmware/get-download?downloadGroup=VS-PERL-SDK67](https://my.vmware.com/group/vmware/get-download?downloadGroup=VS-PERL-SDK67)
<https://my.vmware.com/group/vmware/get-download?downloadGroup=VS-PERL-SDK67>

Stellen Sie sicher, dass es sich um die mit Ihrem Betriebssystem kompatible Version handelt.

In diesem Beispiel ist die heruntergeladene Datei: “VMware-vSphere-Perl-SDK-6.7.0-8156551.x86_64.tar.gz”

Extrahieren Sie die soeben heruntergeladene Datei mit folgendem Befehl:

```
```bash
tar –zxvf VMware-vSphere-Perl-SDK-6.7.0-8156551.x86_64.tar.gz
```

Starten Sie den Installer mit den folgenden Befehlen:

```
```bash
cd vmware-vsphere-cli-distrib
```

```
```bash
./vmware-install.pl
```

Expand All @@ -180,9 +184,9 @@ Nach der Installation werden weitere Module installiert. Drücken Sie auf `Enter

Um die Installation abzuschließen, muss ein Verzeichnis ausgewählt werden, in dem das SDK installiert wird. Standardmäßig ist dieses Verzeichnis “/usr/bin”.

#### Skriptbeispiel
### Beispielskript

##### Verbindung
#### Verbindung

Dieses Beispiel testet Login und Logout von vCenter. Hierbei können Sie auch überprüfen, ob alles korrekt installiert ist:

Expand All @@ -205,7 +209,7 @@ Util::disconnect();
print "Disconnected \n";
```

##### VMs einer Managed Bare Metal auflisten
#### Auflisten der in Managed Bare Metal vorhandenen VMs

Dieses Beispiel listet alle VMs einer Managed Bare Metal Infrastruktur auf:

Expand Down Expand Up @@ -237,23 +241,23 @@ Util::disconnect();
print "Disconnected \n";
```

##### Samples verwenden
#### Samples verwenden

Im vorliegenden Beispiel wird ein bereits erstelltes Skript aus dem Verzeichnis vmware-vsphere-cli-distrib/apps/vm/ aufgerufen.
Im vorliegenden Beispiel wird ein bereits erstelltes Skript aus dem Verzeichnis `vmware-vsphere-cli-distrib/apps/vm/` aufgerufen.

Hier ist die Liste der Skripte, die bereits in diesem Verzeichnis verfügbar sind:

```
```bash
ls vmware-vsphere-cli-distrib/apps/vm/
guestinfo.pl sharesmanager.pl snapshotmanager.pl vdiskcreate.pl vmclone.pl vmcontrol.pl vmcreate.pl vminfo.pl vmmigrate.pl vmreconfig.pl vmregister.pl vmsnapshot.pl vmtemplate.pl
```

Um einen Snapshot "test" der VM "Debian1" zu erstellen, verwenden Sie diesen Befehl (vorher die Platzhalter mit Ihren Anmeldeinformationen ersetzen):

```
```bash
perl snapshotmanager.pl --server pcc-149-202-xxx-xxx.ovh.com --username damien --password MyPassword --operation create --vmname Debian1 --snapshotname test
```

## Weiterführende Informationen

Für den Austausch mit unserer User Community gehen Sie auf <https://community.ovh.com/en/>.
Treten Sie unserer [User Community](/links/community) bei.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: Using the vSphere SDK
excerpt: Find out how to implement and use the vSphere SDK
updated: 2020-11-18
updated: 2025-05-21
---

## Objective
Expand All @@ -10,49 +10,55 @@ Actions within your infrastructure can be automated using the vSphere SDK.

**This guide explains the implementation and usage in various programming languages.**

## Requirements

- Access to the [OVHcloud Control Panel](/links/manager).
- A virtual machine created with one of our [OVF templates](/pages/bare_metal_cloud/managed_bare_metal/ovf_template).


> [!warning]
> The code examples below were created using Python 2.7. Please note that you may need to adjust your commands accordingly if your environment uses Debian 12. In this case, we recommend that you download the latest version of Python 3.
>

## Instructions

### Python

#### Setting up the environment

##### OS

This example uses a VM installed with Debian 9, deployed from [templates available for your Managed Bare Metal infrastructure](/pages/bare_metal_cloud/managed_bare_metal/ovf_template).

##### Requirements

It is necessary to install these packages:
To begin, it is necessary to install these packages:

```
```bash
apt-get install python git python-pip
```

##### vSphere SDK
#### vSphere SDK

Download the vSphere SDK with the following command:

```
```bash
git clone https://github.com/vmware/vsphere-automation-sdk-python.git
```

The directory "/vsphere-automation-sdk-python" will be created. Switch to this folder to perform the installation command:
The directory `/vsphere-automation-sdk-python` will be created. Switch to this folder to perform the installation command:

```
```bash
pip install --upgrade --force-reinstall -r requirements.txt --extra-index-url file:///<absolute_path_to_sdk>/lib
```

In this example, it is the following command:

```
```bash
pip install --upgrade --force-reinstall -r requirements.txt --extra-index-url file:///root/vsphere-automation-sdk-python/lib
```

Once the SDK is installed, you can make use of scripts.

#### Script example
### Script example

##### Connection
#### Connection

This example tests the connection and disconnection to vCenter. It will also help to verify if everything is properly installed.

Expand Down Expand Up @@ -85,7 +91,7 @@ print("Disconnecting..")
vconnect()
```

##### Listing the VMs of a Managed Bare Metal infrastructure
#### Listing the VMs of a Managed Bare Metal infrastructure

This example lists all VMs of a Managed Bare Metal infrastructure.

Expand Down Expand Up @@ -134,47 +140,41 @@ vconnect()

#### Setting up the environment

##### OS

This example uses a VM installed with Ubuntu 18.04, deployed from [templates available for your Managed Bare Metal infrastructure](/pages/bare_metal_cloud/managed_bare_metal/ovf_template).

##### Requirements
To begin, it is necessary to install these packages:

It is necessary to install these packages:

```
```bash
apt-get install lib32z1 lib32ncurses5 uuid uuid-dev libssl-dev perl-doc libxml-libxml-perl libcrypt-ssleay-perl libsoap-lite-perl libdata-compare-perl libmodule-build-perl libuuid-perl libsocket6-perl libnet-inet6glue-perl libarchive-zip-perl

```

```
```bash
cpan install Crypt::OpenSSL::RSA UUID::Random Exception::Class Crypt::X509 List::MoreUtils

```

##### vSphere SDK
#### vSphere SDK

Download the vSphere SDK using this link:

[https://my.vmware.com/group/vmware/get-download?downloadGroup=VS-PERL-SDK67](https://my.vmware.com/group/vmware/get-download?downloadGroup=VS-PERL-SDK67)
<https://my.vmware.com/group/vmware/get-download?downloadGroup=VS-PERL-SDK67>

Make sure to download the version that is compatible with your operating system.

In this example the file downloaded is: "VMware-vSphere-Perl-SDK-6.7.0-8156551.x86_64.tar.gz"

Extract the file you just downloaded using this command:

```
```bash
tar –zxvf VMware-vSphere-Perl-SDK-6.7.0-8156551.x86_64.tar.gz
```

Start the installer using the following commands:

```
```bash
cd vmware-vsphere-cli-distrib
```

```
```bash
./vmware-install.pl
```

Expand All @@ -184,9 +184,9 @@ After the installation, additional modules will be installed. Hit `Enter`{.actio

In order to complete the installation, you will need to select a directory in which the SDK will install. By default, the directory is "/usr/bin".

#### Script example
### Script example

##### Connection
#### Connection

This example tests the connection and disconnection to vCenter. It will also help to verify if everything is properly installed.

Expand All @@ -209,7 +209,7 @@ Util::disconnect();
print "Disconnected \n";
```

##### Listing the VMs of a Managed Bare Metal infrastructure
#### Listing the VMs of a Managed Bare Metal infrastructure

This example lists all VMs of a Managed Bare Metal infrastructure.

Expand Down Expand Up @@ -241,23 +241,23 @@ Util::disconnect();
print "Disconnected \n";
```

##### Using samples
#### Using samples

In this example, a script that is already created and present in the directory "vmware-vsphere-cli-distrib/apps/vm/" is called.

Here is a list of the scripts already available in this directory:

```
```bash
ls vmware-vsphere-cli-distrib/apps/vm/
guestinfo.pl sharesmanager.pl snapshotmanager.pl vdiskcreate.pl vmclone.pl vmcontrol.pl vmcreate.pl vminfo.pl vmmigrate.pl vmreconfig.pl vmregister.pl vmsnapshot.pl vmtemplate.pl
```

To create a snapshot "test" of the VM "Debian1", use this command (replacing the example placeholders with your credentials):

```
```bash
perl snapshotmanager.pl --server pcc-149-202-xxx-xxx.ovh.com --username damien --password MyPassword --operation create --vmname Debian1 --snapshotname test
```

## Go further

Join our community of users on <https://community.ovh.com/en/>.
Join our [community of users](/links/community).
Loading