aboutsummaryrefslogtreecommitdiffstats
path: root/bootstrap/vagrant-onap/doc/source/features/example_usage.rst
blob: fc5f8b39df795af6d4d113a3d3df529229ea6f74 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
=================================================
Example usage to bring up a developer environment
=================================================

In the example, we will bring up a single ONAP component using the Vagrant ONAP
tool.

There are multiple scenarios in which this tool can be made use of by a
developer, they usually fall in the following use cases.

Use case 1: Use Vagrant ONAP to just clone project related source code
----------------------------------------------------------------------

In this use case, the developer needs just the source code of the project to work on.

Since the Vagrant ONAP project supports building docker containers and compiling
source files, we need to first edit the settings.yaml file to add key value pairs
indicating we need to only clone repo and not build docker image or compile then.
By default, Vagrant ONAP clones repo, but to not run the build process and cloning
docker images, the following are required to be added in the settings file.

.. code-block:: console

    skip_get_images: "True"

.. end

The reason this is done is because as mentioned in the
`configure execution docs. <https://git.onap.org/integration/tree/bootstrap/vagrant-onap/doc/source/features/configure_execution.rst>`,
the default values taken are:

.. code-block:: console

    'build_image'         => 'True',
    'clone_repo'          => 'True',
    'compile_repo'        => 'False',
    'enable_oparent'      => 'True',
    'skip_get_images'     => 'False',
    'skip_install'        => 'True'

.. end

We override them and skip_get_images is given precedence over build_image.

Use case 2: Use Vagrant ONAP to clone project related source code and clone Docker Images
-----------------------------------------------------------------------------------------

In this use case, the developer needs to clone docker images of the project to work on.

For this case, we will edit the settings.yaml file to add key value pairs indicating we
need to clone repo and clone docker image from Nexus.

.. code-block:: console

    build_images: "False"
    compile_repo: "True"
    skip_get_images: "False"
    skip_install: "True"

.. end

Use case 3: Use Vagrant ONAP to clone project related source code and build Docker Images locally
-------------------------------------------------------------------------------------------------

In this use case, the developer needs to build docker images of the project to work on.

For this case, we will edit the settings.yaml file to add key value pairs indicating we need to
clone repo and build docker image locally and not fetch them from Nexus.

.. code-block:: console

    build_images: "True"
    compile_repo: "True"
    skip_get_images: "False"
    skip_install: "True"

.. end

Use case 4: Use Vagrant ONAP to clone project related source code and build Docker Images and start services
------------------------------------------------------------------------------------------------------------

In this use case, the developer needs to build docker images of the project he or
she wanted to work on and start the services running inside them.

For this case, we will edit the settings.yaml file to add key value pairs indicating
we need to clone repo, compile repo, build docker image and run the image.

.. code-block:: console

    build_images: "True"
    compile_repo: "True"
    skip_get_images: "False"
    skip_install: "False"

.. end

Once the required changes to the settings file is added, we can use the run.sh
script in tools directory to setup the development environment.

Example steps for setting up a development environment for VFC project.
-----------------------------------------------------------------------

In this example we will be using vagrant ONAP to get all the source code of VFC
project and the developer can point the IDE to the cloned repo in the ./opt directory
and start the development process.

.. code-block:: console

   $ ./tools/run.sh vfc

.. end

At the end of the setup process, all the VFC related source code will be present
in the vagrant-onap/opt/ directory. The developer can point an IDE to this directory
and start contributing. When the changes are done, the developer can SSH into the VM
running VFC and tests can be executed by running Maven for Java and Tox for Python
from the ~/opt/vfc directory.

.. code-block:: console

   $ vagrant ssh vfc
   $ cd ~/opt/vfc/<vfc-subrepo>
   $ tox -e py27

.. end

This way the tool helps the developer to clone repos of a particular project,
without having to manually search for repos and setup an environment.

Also, if something gets messed up in the VM, the developer can tear down the VM
and spin a fresh one without having to lose the changes made to the source code since
the ./opt files are in sync from the host to the VM.

.. code-block:: console

   $ vagrant destroy vfc

.. end