There are many ways to build and develop Voltha
WHAT WE NEED TO CONSIDER AS A REASON TO CREATE A NEW IMAGE
brew install jq
; on Ubuntu you can do it with sudo apt-get install jq
. You will not regret it.If you have not cloned Voltha, it's time to do it now. If you just want to check it out, you can do it anonymously:
git clone https://gerrit.opencord.org/voltha
If you want to develop it, you better use your Gerrit credentials and clone is as (substitute your user name):
git clone ssh://<your-gerrit-user-name>@gerrit.opencord.org:29418/voltha
You can build Voltha by:
cd vagrant-base vagrant up # when you do this for the first time, this will take considerable time vagrant ssh # to see if image is there and accessible
The above has generated a new Vagrant image, named voltha-base
. To check status of the image, first exit from the image and then run status command:
# when (and if) inside the vagrant image, exit first exit # and then check the image status vagrant status
This should produce an output like this:
Current machine states: voltha-base running (virtualbox) The VM is running. To stop this VM, you can run `vagrant halt` to shut it down forcefully, or you can run `vagrant suspend` to simply suspend the virtual machine. In either case, to restart it again, simply run `vagrant up`.
Once image is created and machine is running, as mentioned in previous steps, we can run the following script and test the sanity of the image before uploading it into Vagrant cloud.
./test_script.sh
In case the script can't get executed, change the access permission of the script using sudo chmod 755 ./test_script.sh
.
Once vagrant image is created, we can use this base image and package it and create a vagrant box of it.
vagrant package
This should create a file named package.box
At this point we need to create a new version and POST it in the Vagrant Cloud. To do so, we need to create a version.
curl https://atlas.hashicorp.com/api/v1/box/rrashidi/voltha-base/versions -X POST -H "X-Atlas-Token: <DEDICATED_VOLTHA_BASE_TOKEN>" -d version[version]='<YOUR_DESIRED_VERSION>' -d version[description]='This is your description' | jq
The result should look something like this:
{ "version": "<YOUR_DESIRED_VERSION>", "status": "unreleased", "description_html": "<p>This is your description</p>\n", "description_markdown": "This is your description", "created_at": "2016-11-29T15:35:21.103Z", "updated_at": "2016-11-29T15:35:21.103Z", "number": "<YOUR_DESIRED_VERSION>", "release_url": "https://atlas.hashicorp.com/api/v1/box/rrashidi/voltha-base/version/<YOUR_DESIRED_VERSION>/release", "revoke_url": "https://atlas.hashicorp.com/api/v1/box/rrashidi/voltha-base/version/<YOUR_DESIRED_VERSION>/revoke", "providers": [] }
Now, we need to create a provider for the newly-created version. We use VirtualBox as the provider.
url https://atlas.hashicorp.com/api/v1/box/rrashidi/voltha-base/version/<YOUR_DESIRED_VERSION>/providers -X POST -H "X-Atlas-Token: <DEDICATED_VOLTHA_BASE_TOKEN>" -d provider[name]='virtualbox' | jq
The result should look something like this:
{ "name": "virtualbox", "hosted": true, "hosted_token": null, "original_url": null, "created_at": "2016-11-29T16:00:17.604Z", "updated_at": "2016-11-29T16:00:17.604Z", "download_url": "https://atlas.hashicorp.com/rrashidi/boxes/voltha-base/versions/<YOUR_DESIRED_VERSION>/providers/virtualbox.box" }
We need to upload the package.box file for the provider.
curl 'https://atlas.hashicorp.com/api/v1/box/rrashidi/voltha-base/version/<YOUR_DESIRED_VERSION>/provider/virtualbox/upload?access_token=<DEDICATED_VOLTHA_BASE_TOKEN>' | jq
The result should look something like this:
{ "upload_path": "https://binstore-test.hashicorp.com/a5bfcdf9-609b-4e8f-b5b8-d9ebdea4d2c6", "token": "a5bfcdf9-609b-4e8f-b5b8-d9ebdea4d2c6" }
Then, we upload the .box file using the upload_path.
curl -X PUT --upload-file package.box https://binstore-test.hashicorp.com/a5bfcdf9-609b-4e8f-b5b8-d9ebdea4d2c6
Now that provider of the version and the vagrant image package is ready, we need to realese the version. To release a version to be accessible to all the users, we should use the provided release-url.
curl https://atlas.hashicorp.com/api/v1/box/rrashidi/voltha-base/version/<YOUR_DESIRED_VERSION>/release -X PUT -H "X-Atlas-Token: <DEDICATED_VOLTHA_BASE_TOKEN>" | jq
The result should look something like this:
{ "version": "<YOUR_DESIRED_VERSION>", "status": "active", "description_html": "<p>This is your description</p>\n", "description_markdown": "This is your description", "created_at": "2016-11-29T15:48:50.809Z", "updated_at": "2016-11-29T16:15:14.471Z", "number": "0.1.3", "release_url": "https://atlas.hashicorp.com/api/v1/box/rrashidi/voltha-base/version/<YOUR_DESIRED_VERSION>/release", "revoke_url": "https://atlas.hashicorp.com/api/v1/box/rrashidi/voltha-base/version/<YOUR_DESIRED_VERSION>/revoke", "providers": [ { "name": "virtualbox", "hosted": true, "hosted_token": "a5bfcdf9-609b-4e8f-b5b8-d9ebdea4d2c6", "original_url": null, "created_at": "2016-11-29T16:00:17.604Z", "updated_at": "2016-11-29T16:00:17.604Z", "download_url": "https://atlas.hashicorp.com/rrashidi/boxes/voltha-base/versions/<YOUR_DESIRED_VERSION>/providers/virtualbox.box" } ] }
Following the execution of this command, the new version gets released. As the result, the previous version is not currently a released version.