Skip to main content

REST API Automation study

Project description

RestApi Automation

Using RestApi to Automate the Test cases -> Backup, Restore

Before Start

The Setup should be ready with Avamar server connected to vCenter and proxy registered with the Avamar Server.

Installation

Python Version --> Preferably 3.5.0 and above.

Use the package manager [pip] if possible the latest Version.

apt-get install python-pip

Other Libraries

bash pip install requests --> to install the requests module

bash pip install yaml --> For Yaml Configuration

bash pip install logging --> For Log creation

Usage

Fill the Config.yaml file for User Entries. Some of them are explained below,

Authorization : Authorization Token to access Avamar Server(Use Postman to retrieve one).
vCenterSessionId : Session Id of the vCenter server.
vmType : The type of VM whose backup has to be taken(Windows, Linux)
FolderPath : Folder where the VM is kept
NewVMName : While Restoring the New VM name

For Eg.

IP: 10.110.211.252
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJyb2xlIjoiUk9PVCIsInVzZXJfbmFtZSI6Ik1DVXNlciIsInNjb3BlIjpbIndyaXRlIl0sImRvbWFpbiI6Ii8iLCJhdXRob3JpemVkX2RvbWFpbiI6Ii8iLCJleHAiOjE1NTI2NDc2NzksImF1dGhvcml0aWVzIjpbIlJPT1QiXSwianRpIjoiNjBlZTUyNWItZjBmYi00NTE2LWIyMTEtYmZiNThiMzQ3Y2E3IiwiY2xpZW50X2lkIjoiM2MwNDFiODctNTIyYi00NThlLTgwZmYtYjY5MTZiMmU5N2JmIn0.EpkFA2litAI_CigsTK1s3GYFmG6BP48_EOj-IIPXgNX5-SwpDlg32-MP8XgCbMYXOpPLRUzlPnIIBA8jANBVL9Tg3esF_u2qmKU7CMLVyJTIfZhB9x1NAoE5S0_6Fb8Z68PkbUWkUYc0ubaoGEhMzc775bLxU4g_ULUdtkQSGKYCTg2CLnmqhONZaWTw5M83Y-L8qZ7T4DvgEbkWtXHZ0jdnLcSiAXtv1qX3rEESk8LYVSuvoeLIPSnNK50vydh_H_cPTw9jfF_J8Qfa5mTAAfnuzTZBPGtyA2zodtOin1yyEOC1VPz7HpHU-0NMOKF1YCVleZXzV35BdNw-JxBfS1c92BMZQoF-yqyTf1Q5qwGCMA0lghxd0ClNwTM4YCCe-o3FBcVeCWLehL5MyGDuLk0JI8uGRJPR7XHpwpy8KTSF8L_9A-0i3xS0ZZQf9AxTDIEMIheEAF0VWgu3ulZ92Ud_9qThICTUWvqkHonuLiKs2FoPxrGfFyOeSeLlaZEO
vCenterSessionId: 4f99479faf19893b1dd86507b7fcfc7e
vCenter: 10.110.211.168
PolicyName: Gsan-Policy
PolicyDomain: /10.110.211.168/VirtualMachines
Content-Type: application/json
VM_id: c146dd0ebed42ff4cd94460ddeb509fb6cbdf7e7
vmType: Windows
VcCid: 14bda782e11827a1c69201a43ac0e3cc2b4a24a8
Datastore: datastore1
FolderPath: /AVE_A10N_DC/vm/Automation/
NewVMName: Restore-VM-2019_18
ResourcePoolPath: /AVE_A10N_DC/host/10.110.211.22/Resources/Compute-ResourcePool/
DatacenterName: AVE_A10N_DC

Running

After filling the yaml file run the below command in the terminal,

python REST_Automation.py

Log file produced is

Contributing

All suggestions and trial are welcome.

Project details


Release history Release notifications

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for RESTApi-prasanth, version 6.7.0.2
Filename, size File type Python version Upload date Hashes
Filename, size RESTApi_prasanth-6.7.0.2-py3-none-any.whl (3.7 kB) File type Wheel Python version py3 Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page