-
Notifications
You must be signed in to change notification settings - Fork 387
feat(vcd): create guide how to use api #8773
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
Draft
ThibautOVH
wants to merge
3
commits into
develop
Choose a base branch
from
TG-VCD-How-to-use-api
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
195 changes: 195 additions & 0 deletions
195
..._cloud/hosted_private_cloud_powered_by_vmware/vcd-how-to-use-api/guide.fr-fr.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,195 @@ | ||
| --- | ||
| title: "Comment utiliser les API de Public VCF aaS (alias Public VCF as-a-Service)" | ||
| excerpt: "Guide d’utilisation des API Public VCF aaS (alias Public VCF as-a-Service)" | ||
| updated: 2025-12-03 | ||
| --- | ||
|
|
||
| ## Objectif | ||
|
|
||
| Ce guide présente les étapes permettant d'appeler l’API et d'exécuter des opérations courantes (listing, actions VM, snapshots, etc.). | ||
|
|
||
| ## Prérequis | ||
|
|
||
| Avant d’utiliser l’API, nous vous recommandons de consulter les guides suivants : | ||
|
|
||
| - [Public VCF as-a-Service - Concepts fondamentaux](/pages/hosted_private_cloud/hosted_private_cloud_powered_by_vmware/vcd-get-concepts) | ||
| - [Public VCF as-a-Service - Concepts réseau](/pages/hosted_private_cloud/hosted_private_cloud_powered_by_vmware/vcd_network_concepts) | ||
| - [Création d'une VM sur Public VCF as-a-Service](/pages/hosted_private_cloud/hosted_private_cloud_powered_by_vmware/vcd-first-vm-creation) | ||
| - [Création de composants réseau via Public VCF as-a-Service](/pages/hosted_private_cloud/hosted_private_cloud_powered_by_vmware/vcd_network_creation) | ||
|
|
||
| ## En pratique | ||
|
|
||
| ### Récupérer l’URL de l’API | ||
|
|
||
| L’URL des API Public VCF aaS est disponible dans votre espace client **OVHcldoud** | ||
| Vous pouvez retrouver cette information dans **Informations générales** > **URL API** de votre service **Public VCF aaS** | ||
|  | ||
|
|
||
| Vous pouvez ensuite la stocker dans une variable pour simplifier les commandes : | ||
|
|
||
| ```bash | ||
| apiURL="https://cloud.infra01.example.ovhcloud.com/api" | ||
| baseURL="${apiURL::-4}" | ||
| ``` | ||
|
|
||
| **apiURL** : Remplacer l'URL correspondante à l'URL de votre service. | ||
|
|
||
|
|
||
| ## Autorisation | ||
|
|
||
| Pour appeler l'API, vous devez obtenir un **token de session**, valable pour une durée limitée. | ||
|
|
||
| ### Récupérer la version d’API supportée | ||
|
|
||
| Cette commande liste toutes les versions disponibles et indique lesquelles sont dépréciées : | ||
|
|
||
| ```bash | ||
| curl $apiURL"/versions" | ||
| ``` | ||
|
|
||
| Définition de la version : | ||
|
|
||
| ```bash | ||
| VER="39.0" | ||
| ``` | ||
|
|
||
| > **Tip** | ||
| > Utilisez toujours la version la plus récente (`deprecated = false`) pour bénéficier des dernières fonctionnalités. | ||
|
|
||
| ### Encoder votre utilisateur et mot de passe | ||
|
|
||
| Cette commande encode vos identifiants au format requis par VMware Cloud Director : | ||
|
|
||
| ```bash | ||
| AUTH=$(echo "<username>@<org>:<password>" | base64 -w 0) | ||
| ``` | ||
|
|
||
| ### Créer un token de session | ||
|
|
||
| La commande suivante ouvre une session et extrait automatiquement le token renvoyé dans les headers HTTP : | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can also create a token inside the Cloud Director WebUI (user preference, if I remember correctly). |
||
|
|
||
| ```bash | ||
| TOKEN=$(curl -Is -XPOST \ | ||
| -H "Accept: application/*;version=$VER" \ | ||
| -H "Authorization: Basic $AUTH" \ | ||
| $baseURL"/cloudapi/1.0.0/sessions/" \ | ||
| | grep "x-vmware-vcloud-access-token" | awk '{print $2}') | ||
| ``` | ||
|
|
||
| > **Warning** | ||
| > Le token n’apparaît **pas** dans le corps de la réponse mais uniquement dans les **headers**. | ||
|
|
||
| ## Utilisation de l'API | ||
|
|
||
| ### Lister les vApps | ||
|
|
||
| Cette requête renvoie toutes les vApps accessibles dans votre organisation. | ||
|
|
||
| ```bash | ||
| curl -XGET \ | ||
| -H "Accept: application/*;version=$VER" \ | ||
| -H "Authorization: Bearer $TOKEN" \ | ||
| $apiURL"/vApps/query" | ||
| ``` | ||
|
|
||
| ### Lister les VM | ||
|
|
||
| Cette commande liste les VMs (hors templates) : | ||
|
|
||
| ```bash | ||
| curl -XGET \ | ||
| -H "Accept: application/*;version=$VER" \ | ||
| -H "Authorization: Bearer $TOKEN" \ | ||
| $apiURL"/vms/query?filter=isVAppTemplate==false" | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ### Démarrer une VM | ||
|
|
||
| Cette commande envoie l’action `powerOn` à la VM cible : | ||
|
|
||
| ```bash | ||
| curl -XPOST \ | ||
| -H "Accept: application/*;version=$VER" \ | ||
| -H "Authorization: Bearer $TOKEN" \ | ||
| $apiURL"/vApp/<vm-id>/power/action/powerOn" | ||
| ``` | ||
|
|
||
| > **Note** | ||
| > Cette opération renvoie une **tâche**, consultable via l’API des tâches. | ||
|
|
||
| --- | ||
|
|
||
| ### Créer un snapshot | ||
|
|
||
| Cette commande crée un snapshot de la VM sélectionnée : | ||
|
|
||
| ```bash | ||
| curl -XPOST \ | ||
| -H "Accept: application/*;version=$VER" \ | ||
| -H 'Content-Type: application/vnd.vmware.vcloud.createSnapshotParams+json' \ | ||
| -H "Authorization: Bearer $TOKEN" \ | ||
| $apiURL"/vApp/<vm-id>/action/createSnapshot" \ | ||
| -d '{ | ||
| "name": "MonSnapshot", | ||
| "memory": false, | ||
| "quiesce": true | ||
| }' | ||
| ``` | ||
|
|
||
| > **Warning** | ||
| > Le quiescing nécessite des VMware Tools fonctionnels. En cas d’erreur, essayez `"quiesce": false`. | ||
|
|
||
| --- | ||
|
|
||
| ### Consulter une tâche | ||
|
|
||
| Cette commande interroge le statut d'une tâche via son identifiant : | ||
|
|
||
| ```bash | ||
| curl -XGET \ | ||
| -H "Accept: application/*;version=$VER" \ | ||
| -H "Authorization: Bearer $TOKEN" \ | ||
| $apiURL"/task/<task-id>" | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ### Supprimer la session | ||
|
|
||
| Il est recommandé de supprimer votre session une fois les opérations terminées : | ||
|
|
||
| ```bash | ||
| curl -i -XDELETE \ | ||
| -H "Accept: application/*;version=$VER" \ | ||
| -H "Authorization: Bearer $TOKEN" \ | ||
| $baseURL"/cloudapi/1.0.0/sessions/current" | ||
| ``` | ||
|
|
||
| > **Tip** | ||
| > Fermer votre session améliore la sécurité en évitant toute utilisation prolongée du token. | ||
|
|
||
| ## Erreurs courantes | ||
|
|
||
| | Erreur | Cause possible | Résolution | | ||
| |-------|----------------|------------| | ||
| | **401 Unauthorized** | Token expiré ou invalide | Générer un nouveau token | | ||
| | **403 Forbidden** | Permissions insuffisantes | Vérifier les rôles attribués dans VCD | | ||
| | **404 Not Found** | Mauvais ID de ressource | Vérifier l’UUID de la VM/vApp | | ||
| | **500 Internal Server Error** | Snapshot impossible ou ressource indisponible | Réessayer sans quiescing, vérifier VMware Tools | | ||
| | **503 Service Unavailable** | Plateforme en maintenance | Réessayer plus tard | | ||
|
|
||
| > **Note** | ||
| > Certaines opérations (snapshot, powerOn, etc.) peuvent prendre plusieurs minutes. | ||
|
|
||
| ## Aller plus loin | ||
|
|
||
| Pour plus d’informations sur les appels API disponibles et la documentation officielle VMware Cloud Director, consultez : | ||
| [VMware Cloud Director API](https://developer.broadcom.com/xapis/vmware-cloud-director-api/latest/doc/landing-user_operations.html) | ||
|
|
||
| Si vous souhaitez obtenir une formation ou une assistance technique personnalisée, contactez votre commercial ou cliquez sur [ce lien](/links/professional-services). | ||
|
|
||
| Rejoignez le canal [Discord](https://discord.gg/ovhcloud) pour échanger directement avec notre équipe. | ||
|
|
||
| Vous pouvez également participer à la [communauté d’utilisateurs](/links/community) pour partager vos expériences et bonnes pratiques. | ||
Binary file added
BIN
+7.46 KB
...ivate_cloud_powered_by_vmware/vcd-how-to-use-api/images/vcd-manager-api-url.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions
2
.../hosted_private_cloud/hosted_private_cloud_powered_by_vmware/vcd-how-to-use-api/meta.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| id: ee73f58d-30b7-47d1-8188-a277e9ecd4f0 | ||
| full_slug: vmware-vcd-api |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<org-name>Maybe add an example.