This project contains the artifacts related to the OSB Actions Proof of Concept. The goals of this poc are: *Implement an OSB server that returns a discovery_url on service instance creation. *Implement a discovery_url that returns a json of an actions swagger. *Implement a gui that utilizes the server and the actions swagger to dynamically execute said actions.
The demo server is autogenerated (using go-swagger) from a swagger specification that combines the OSB spec with some sample backup & restore actions.
- goswagger swagger code generation tool has been installed. This will enable automatic generation of files from swagger.yml file.
- Within your workspace you have setup the standard folders expected for a GO workspace, and the GOPATH variable pointing to it.
- cd to your go workspace's src folder.
git clone <crb git repo path> osb_api
.
Note: You must name the destination folder osb_api as go uses folder names as package names.
- cd to the project folder.
- Generate required classes from swagger spec file for building.
swagger generate server -f combined-swagger.yaml -A osbapi
.
Note: You must name the application 'osbapi' as goswagger uses it to name the packages and files, some of which cannot be modified.
- Download and install dependencies using one of the following methods:
- Using godeps tool:
- Run "godep save ./..." to compile the "Godeps/Godeps.json" and generate the lists of required packages in "vendor/".
- Using native go get command:
- Run
go get -u -f ./...
- Run
- Using godeps tool:
- cd cmd/osbapi-server/
- Run
go build
orgo install
.
- Start the server as local standalone app
./osbapi-server --host=localhost --port=8080
$ curl -X POST "http://localhost:8080/v2/service_instances/test_instance/backups" -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"backup_type\": \"incremental\", \"expires\": \"12/31/2020\", \"backup_location\": \"http://s3.amazonaws.com/bucket/backup1.tar\", \"backup_location_protocol\": \"s3\", \"backup_location_credentials\": \"admin/password\", \"note\": \"Changing expiration date of this backup.\", \"compression\": \"tar\", \"encryption\": \"AES128\"}"
$ curl -X POST "http://localhost:8080/v2/service_instances/test_instance/restores" -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"backup_location\": \"http://s3.amazonaws.com/bucket/backup1.tar\", \"note\": \"Had to restore from an error at 12pm EST.\"}"
$ curl -X PUT "http://localhost:8080/v2/service_instances/test_instance" -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"service_id\": \"string\", \"plan_id\": \"string\", \"context\": {}, \"organization_guid\": \"string\", \"space_guid\": \"string\", \"parameters\": {}}"
$ curl -X GET "http://localhost:8080/v2/service_instances/test_instance/backups" -H "accept: application/json"
$ curl -X GET "http://localhost:8080/v2/service_instances/test_instance/backups/test_backup" -H "accept: application/json"
$ curl -X GET "http://localhost:8080/v2/service_instances/test_instance/restores" -H "accept: application/json"
$ curl -X GET "http://localhost:8080/v2/actions/swagger" -H "accept: application/json"
$ curl -X GET "http://localhost:8080/v2/actions/swagger2" -H "accept: application/json"
$ curl -X PUT "http://localhost:8080/v2/service_instances/test_instance/backups/backup_instance" -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"expires\": \"12/31/2020\", \"backup_location\": \"http://s3.amazonaws.com/bucket/backup1.tar\", \"backup_location_protocol\": \"s3\", \"backup_location_credentials\": \"admin/password\", \"note\": \"Changing expiration date of this backup.\", \"compression\": \"tar\", \"encryption\": \"AES128\"}"
$ curl -X DELETE "http://localhost:8080/v2/service_instances/test_instance/backups/test_backup" -H "accept: application/json"
$ curl -X PUT "http://localhost:8080/v2/service_instances/test/pause" -H "accept: application/json"
$ curl -X PUT "http://localhost:8080/v2/service_instances/test/restart" -H "accept: application/json"
$ curl -X PUT "http://localhost:8080/v2/service_instances/test/stop" -H "accept: application/json"
$ curl -X PUT "http://localhost:8080/v2/service_instances/test/start" -H "accept: application/json"
This UI calls the demo server and mocs up some example backup & restore actions on provisioned service instances.
OSB Actions demo server up and running
Open ui/index.html in your browser Enter in any "Service", "Plan", "Instance" names.
- E.g "service1", "plan1", "instance1".
Enter in a discovery URL from the OSB server
- E.g "http://localhost:8080/v2/actions/swagger" (for backup & restore)
- "http://localhost:8080/v2/actions/swagger2" (for pause/start/stop/restart)
Create some backups
- click "createBackup" and fill in the details.
View your backups
- click "getBackups" to get a list of backups you've created
Create some restores
- click on "createRestore" and fill in the details
I think you get the rest...