You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 5 Next »

Setting up IDE

You can set up the SDNC IDE by following instructions from Setting Up Your Development Environment with the additions described below.

Install sonarlint plugin

<coming soon>

Download the Source Code

Create Your Linux Foundation Account

If you already have a Linux Foundation account, you can skip this section.

You will need linux foundation account to submit code change to ONAP projects repos. If you only want to read the code, you can skip this step.

To create your linux foundation account, go to Linux Foundation Identity page, and select I need to create a Linux Foundation ID, the following page will be shown:

Filling the information and click on Create new account to proceed account creation.

Download SDNC Projects

Follow steps in Get git command from ONAP gerrit to get the git clone command and clone each of the following SDNC projects:

Project NameProject Descriptionhas code
sdnc/adaptorsSDNC adaptors(minus)
sdnc/architectureSDNC architectural artifacts (e.g. blueprints)(minus)
sdnc/coreSDNC core platform(minus)
sdnc/featuresSDNC Karaf features(minus)
sdnc/northboundSDNC northbound adaptors(tick) java
sdnc/oamSDNC OA&M tools(tick) bash, javascript, python, DGs
sdnc/parentParent POMS to be used by SDNC components (minus)
sdnc/pluginSDNC plugins(minus)


Note: The ONAP SDNC projects are more like a demo version of ECOMP's SDN-GC.

Download CCSDK Projects

Follow steps in Get git command from ONAP gerrit to get the git clone command and clone each of the following CCSDK projects:

Project NameProject Descriptionhas code
ccsdk/dashboardOpeations Manager Dashboard(tick)
ccsdk/distributionCCSDK distribution packaging (e.g. docker containers)(minus)
ccsdk/parentParent POMs to be used by CCSDK clients(minus)
ccsdk/platform/blueprintsBlueprints. not in Amesterdam release(minus)
 ccsdk/platform/nbapiNorthbound API(tick)
 ccsdk/platform/pluginsPlatform plugins(tick)
 ccsdk/sli/adaptorsCommon adaptors for use by directed graphs(tick)
ccsdk/sli/coreCore Service Logic Interpreter classes(tick)
 ccsdk/sli/northboundCommon northbound APIS related to service logic interpreter(tick)
 ccsdk/sli/pluginsCommon plugins used by direcged graphs (tick) python
ccsdk/storage/esaasElastic Storage as a Service.  not in Amesterdam release(minus)
ccsdk/storage/pgaasPGAAS (PostgreSQL as a Service)(tick) java, python, bash
ccsdk/utilsUtilities(tick) bash, yaml


Get git clone Command From ONAP gerrit

Use your linux foundation account to login onto ONAP projects.

Get Project list by entering the project key name in the Filter, for example sdnc, this list of projects under sdnc will be shown as below:

Click on the wanted project from the list, the General page of the selected project will be shown. the following is the General page of sdnc/adaptors:

Now click on Clone with commit-msg hook, then click on http, then click on the notepad icon.

The git clone command for the selected project is now copied into your clipboard. You do paste to use it at where-ever you want to.


View Code in gerrit Website

ONAP code can also be viewed from gerrit web site as below (sdnc/adaptors project is used as the example here):


To view the coce through gerrit client, first follow steps in SDNC - Development Environment Setup to get the Projects list page.

Then, choose either one of the following option to view the code of the desired project.

Option 1: view through "gitweb" option in project list page

Note: this option will bring you to, and only to, the HEAD branch which is the master branch.


In the project list page, click on the gitweb under the Repository Browser column of your project row.

The master branch's summary page will be shown up. Click on the tree option.

Now, the repo details page will be shown and you can view the code in master branch from there.


Option 2: view from "Branches" option in project page

Note: this option allows you to select a particular branch to view it code.

In the project list page, click the project under the Project Name column. (using sdnc/adaptors project as example here)

It takes you to the project General page, click on the Branches option.

The project page will be switched to Branches page. Check out the Branch Name column, click the gitweb on the same row of the desired branch.

The project Summary page of the selected branch will be shown up.  Click on the tree option.

Now, the repo details page will be shown and you can view the code in master branch from there.

Compiling

coming soon

Unit Testing

coming soon

How to Commit Code

Install git-review

To commit code to ONAP, you must have git-review installed.

The steps in this section only need to be done one time, except the Tips (smile)

On Linux

run the following command to check if git-review is installed as part of your OS image.

git-review 

If not the following command to install the git-review.

sudo apt install git-review

here's an example:

install git-review on Linux

ubuntu@beili-ws-01:~/Videos$ git-review

The program 'git-review' is currently not installed. You can install it by typing:

sudo apt install git-review

ubuntu@beili-ws-01:~/Videos$ sudo apt install git-review


On Windows

must have git installed

If you do not have git installed, following Install Git on Windows at atlassian's tutorials for installing git to

  • download the Git for Windows installer
  • start installer and follow Git Setup wizard screen Next until Finish prompts to complete the installation.

must have python installed

If you do not have python installed, following Python & pip Windows installation to

install git-review using pip

Open a git bash terminal by

  • going to the bin directory under your git installed directory (for example, C:\Program Files\Git\bin directory ),
  • run bash.exe

In the git bash terminal, run the following command to install git-review

c:/Python27/Scripts/pip2.7 install git_review --proxy <your proxy>


Set Git Remote Gerrit

Check your git remote setting, use the following command

git remote -v

Here's an example of output:


If the gerrit does not exist, you need to set it up with the following command:

git remote add gerrit <the link of the origin>

Note: the remote origin is added automatically after git clone of the repo. The gerrit link is the same as the origin's, hence, we just directly use it.

Set Git Config

Use the following command to check your git config:

git config -l

Ensure that you have the following configuraiton set properly:

GIT Config KeyExpected ValueSetting Command
core.eollfgit config --global core.eol lf

core.autocrlf

truegit config --global core.autocrlf true
user.nameyour namegit config --global user.name <your name>
user.emailyour email addressgit config --global user.email <your email address>


Create A Review

Checkout the master branch, work on your changes, once you are ready for submission, do the following to create a review.

  1. Ensure your workspace is clean and up-to-date

Use the following command to check all the changes in the master branch

git status

Ensure

      • your branch is up-to-date with the origin/master
        • do a git pull to get the latest master code
      • all the changed files are the ones you wanted to submit.
        • remove any un-wanted files

2. Run the following commands in the listed order to create a review

StepsCommandNotes
1git commit -sam <comment summary>Commit summary should not exceed 50 char. See ONAP Commit Messages for more details.
2git log --shortstat

To ensure change lines are properly done and your commit has the following:

    • Change-Id
    • Signed-off-by

Here's an example:

git log --shortstat

C:\workspace\onap_sdnc\northbound>git log --shortstat
commit 4728eada855f9162030f5b46a2513e3dbffa757c
Author: beili.zhou <beili.zhou@amdocs.com>
Date: Fri Oct 13 19:19:11 2017 -0400

Sonar coverage vnfapi -VNFSDNSvcLogicServiceClient

Add Junit test case for VNFSDNSvcLogicServiceClient
In VNFSDNSvcLogicServiceClient:
- Fix sonarlint issues (remove un-used import and etc)
- Changed tab to 4 spaces as per ONAP Java code style

Issue-Id: SDNC-123
Change-Id: Id176e915f17ef5fabc6805415f92d60b4c8e95b2
Signed-off-by: beili.zhou <beili.zhou@amdocs.com>

2 files changed, 580 insertions(+), 240 deletions(-)


If the Change-Id does not exist, do not proceed. You need to following SDNC - Development Environment Setup to fix it before proceeding further.

3git commit --amend

Use this command to do the following:

    • add more desciption about this commit (refer to Commit Messages for how to organize commit description)
    • insert Issue-Id: <your ONAP issue id> before the Change-Id
4git review

This command will create the review at Gerrit.

Once this command is completed, your newly created review can be found from Outgoing reviews in Gerrit self dashboard .

3. Update the Gerrit Review to get ready

From Gerrit self dashboard, click your newly created review, it will bring up the review details.

Click the Add button in the Reviewers section, to add reviewers (who is going to review your code) and committers (who is going to review your code as well as approve and commit your code).

Note:

    • The ONAP Jobbuilder will be added automatically within one or two minutes after the review created, and a verfiy build will also be automatically triggered for your review in ONAP jenkins server.
    • The committer can be found from Software Defined Newtork Controller secion in Resources and Repositories page.


By now, you will just wait and check your email for information of

  • If the verify jenkins build is passed for your review
    • If it is passed, ONAP Jobbuilder will add a +1 to the Verified field in your review.
  • If there's any comments in your review
    • the comments details can be view from the History section by clicking on the description or Expand All button
  • If your review has been merged
    • If your review is merged or in process to be merged, you will see in the Code-Review field, you have a +2 from one of the committer you have added in your Reviewers.


Tips

How to Change the Comments in A Review

Oops, I made a mistake in my review comments. It cannot be changed in the gerrit review. (sad)

Go back to your workspace, and do the following to change the comments of your existing review.

StepsCommandNotes
1git commit --amendupdate the comment as desired
2git log --shortstatvalidate your commit now has the updated comments, as well as the Change-Id as the one in the gerrit review
3git review

push the changed comment to the review again.

Once the command is completed, go to your review, you will see

  • the comments content adjust to your new ones
  • the Patch Sets is now increased by one, such as from (1/1) to (2/2). here's an example:


How to Update the Code in A Review

Now, I got comments in my view, and I have made the code adjustment in my workspace and tested.

Follow the steps to push your new code changes to the your existing reiew.

Stepscommandnotes
1git commit -sam "my updated code"To create a new commit with your updated code
2git log --shortstat

you will see the most 2 recent commits are from

  • your commit from step 1
  • your original commit of the existing review
3git rebase -i HEAD~2

To run rebase interactively for the most recent 2 commits

In the interactive mode, it will bring up the text which contains pick for your last 2 commits along with the following content:

Do the following:

  • replace the pick in the start line of your commit from step 1 (marked with "my updated code") with s or squash,
  • remove any other text line related to this commit in the line below.
  • save the change by entering :wq


Once this command is completed, 2 commits will be merged into 1 commit.

4git log --shortstat

you will see there's only 1 commit which replaces the 2 commit you have seen in step 2.

validate your commit has the Change-Id as the one in the gerrit review 

5git review

push the changed comment to the review again.

Once the command is completed, go to your review, you will see

  • the comments content adjust to your new ones
  • the Patch Sets is now increased by one, such as from (1/1) to (2/2). here's an example:


How to Fix A Commit Does Not Have Change-Id

The would only happen when you are creating your very first review in a repo. It mainly because your workspace might have some mis-config which lead your repo clone was not done properly with the Clone with commit-msg hook option.

Follow the steps below to do the correction.

StepsCommandNotes
1git reset HEAD~1to undo the commit
2

from github helper page, download commit-msg,

and place it under your <repo>/.git/hook directory

set the proper commit-msg hook

this will set the Change-Id properly in your commit

3Use your previous command to create the commit again
4git log --shortstatto check the existence of Change-Id


How to Find All of My Merged Changes

You can find your recent merged changes from Gerrit self dashboard, however, it only works for Recent changes.

To find all of your changes, you can type in "is:closed(owner:self)" in the Search field at Gerrit self dashboard, then click on the Search button.



How to Deploy a minimal ONAP sdnc environment

This tutorial is based on ONAP-integration project[1] which utilizes Vagrant[2], a deployment tool to build an ONAP environment.

The goal of this section is to guide how to quickly build an running ONAP SDNC envrionment which is going to use the existed image in the ONAP Nexus3 server.

Actually it supports various automate deployment environment including compling code with maven, building docker images as part of the deployment procedure.

ONAP-integration

"Integration framework, automated tools, code and scripts, best practice guidance related to cross-project Continuous System Integration Testing (CSIT), and delivery of ONAP."

Prerequisites

(1) After installation, make sure that your system is restarted in order to let configuration be activated.

(2) Instead of using Git bash, Cygwin could be also used and make sure "dos2unix" package is installed which will be used during setup

Basic setup

Windows 10

Download the exe and install.

Ubuntu 16.04
install virtualbox

Add the following line to your /etc/apt/sources.list:

deb http://download.virtualbox.org/virtualbox/debian xenial contrib

Run the command below

wget -q https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | sudo apt-key add -
wget -q https://www.virtualbox.org/download/oracle_vbox.asc -O- | sudo apt-key add -
sudo apt-get update
sudo apt-get install virtualbox-5.2
install vagrant
wget https://releases.hashicorp.com/vagrant/1.9.5/vagrant_1.9.5_x86_64.deb
sudo dpkg -i vagrant_1.9.5_x86_64.deb
install git
sudo apt-get install git
install dos2unix
sudo apt install dos2unix


Download The Project

git clone https://git.onap.org/integration'
  • Hint:  More information could be found under integration\bootstrap\vagrant-onap\README.md

Windows: Open Gitbash As Administrator

Convert Line Ending 

cd integration/bootstrap/vagrant-onap/lib
find . -type f -print0 | xargs -0 dos2unix

Hint: This issue might be fixed later

Configure Deployment Mode

  • There is an settings.yaml.development under integration\bootstrap\vagrant-onap\etc used for different deployment scenarios.
  • The goal of this tutorial is to have a running SDNC environment, so in the configuration, it turns off clone and build project.
  • Only file name called settings.yaml will be picked-up by the deployment script.
  • There is an issue in the sample file that "build_images" should be replaced by "build_image", otherwise, this configuration won't work.
cp settings.yaml.development settings.yaml
vim settings.yaml

The example shows below 

build_image: "False"
clone_repo: "False"
compile_repo: "False"
enable_oparent: "False"
skip_get_images: "False"
skip_install: "False"
  • Hint: Under integration\bootstrap\vagrant-onap\doc\source\features\configure_execution.rst, it talks about the functionality of these attributes.
  • Hint: Under integration\bootstrap\vagrant-onap\doc\source\features\example_usage.rst, it talks about the use cases of using this tool.

Modify Vagrantfile

vim integration/bootstrap/vagrant-onap/Vagrantfile
  • In configuration =  {...}, find docker_version and update the corresponding value to '1.2-STAGING-latest'

For example,

...
configuration = {
	...
	'docker_version' => '1.2-STAGING-latest',
	...
}
...

Modify SDNC Deployment Script

vim integration/bootstrap/vagrant-onap/lib/sdnc
  • Find function get_sdnc_images{...} in the file and modify

  • Mainly use pull_onap_image to replace pull_openecomp_image

  • Pull onap/ccsdk-dgbuilder-image instead of openecomp one

For example,

...
# get_sdnc_images() - Build or retrieve necessary images
function get_sdnc_images {
    if [[ "$build_image" == "True" ]]; then
        _build_sdnc_images
    else
        # pull_openecomp_image sdnc-image openecomp/sdnc-image:latest
        # pull_openecomp_image admportal-sdnc-image openecomp/admportal-sdnc-image:latest
        # pull_openecomp_image dgbuilder-sdnc-image openecomp/dgbuilder-sdnc-image:latest
        pull_onap_image sdnc-image onap/sdnc-image:latest
        pull_onap_image admportal-sdnc-image onap/admportal-sdnc-image:latest
        pull_docker_image nexus3.onap.org:10001/onap/ccsdk-dgbuilder-image:latest onap/ccsdk-dgbuilder-image:latest
    fi
    pull_docker_image mysql/mysql-server:5.6
}
...

Start Deployment

cd integration/bootstrap/vagrant-onap
./tools/run.sh sdnc

Configure Port Forward

This could be replaced by adding scripts in Vagrantfile.

Open RestConf Page

http://127.0.0.1:8282/apidoc/explorer/index.html

Credentials: admin/Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U

Basic usage of vagrant and docker

// check running vm instances

vagrant global-status

//  ssh to the vm

vagrant ssh ${vm-id}

// check docker images

docker images

// check running docker instances

docker ps -a

// ssh to the docker instance

docker exec it ${docker-instance} bash


Reference:

[1] ONAP integration: https://git.onap.org/integration/

[2] Vagrant: https://www.vagrantup.com/

[3] ONAP SDC setup: Using Vagrant-Onap for local deployment of SDC project - WIP!!!

[4] Virtualbox Download link: https://www.virtualbox.org/wiki/Linux_Downloads

How to Deploy New Code (based on standard ONAP lab setup)

coming soon

Remote Debugging

coming soon

  • No labels