6. REST Service (outdated)¶
The REST Api is built using flask and provides the cloud information retrieval functionality through HTTP calls.
6.2. How to run the REST API¶
- Navigate to the cm directory. example:
cd ~/git/cloudmesh/cm
- Configure cloudmesh
pip install .
- Add the MongoDB information in the configuration file
vi ~/.cloudmesh/cloudmesh4.yaml
- Run the REST API
python cm4/flask_rest_api/rest_api.py
6.3. API¶
/vms/
: Provides information on all the VMs./vms/stopped
: Provides information on all the stopped VMs./vms/<id>
: Provides information on the VM identified by the
6.4. Examples¶
Retrieve information about a VM
curl localhost:5000/vms/i-0fad7e92ffea8b345
6.5. Dev - restricting certain ips for certain rest calls¶
from flask import abort, request
from cm4.flask_rest_api.app import app
@app.before_request
def limit_remote_addr():
if request.remote_addr != '10.20.30.40':
abort(403) # Forbidden