diff options
author | 2017-09-28 14:31:07 -0400 | |
---|---|---|
committer | 2017-09-28 14:34:01 -0400 | |
commit | a3b65e405278eb4b54de869a19b66ed9338dd1a6 (patch) | |
tree | 51b694ca9e585bcd76cf6c39ea95974a949d8beb /docs/tutorials/portal-sdk/setting-up.rst | |
parent | 51d83152697da4f2ef2242471ee43f36e6b64300 (diff) |
Added tutorial for portal-sdk apps
Added a tutorial for how to create a basic app
using the portal sdk.
Change-Id: I52783748760501e57751e19d1eb586d21cbef0d9
Issue-Id: PORTAL-100
Signed-off-by: jsseidel <jsseidel@fastmail.com>
Diffstat (limited to 'docs/tutorials/portal-sdk/setting-up.rst')
-rw-r--r-- | docs/tutorials/portal-sdk/setting-up.rst | 137 |
1 files changed, 137 insertions, 0 deletions
diff --git a/docs/tutorials/portal-sdk/setting-up.rst b/docs/tutorials/portal-sdk/setting-up.rst new file mode 100644 index 00000000..6c0ece54 --- /dev/null +++ b/docs/tutorials/portal-sdk/setting-up.rst @@ -0,0 +1,137 @@ +Setting up +========== + +Dependencies +------------ + +In order to build Portal SDK applications on your machine, you'll need to install the following: + +1. OpenJDK 8 +2. Maven +3. MariaDB (v10.1) +4. Apache Tomcat (v8.5) + +Cloning the Portal SDK repository +--------------------------------- + +Clone the Portal SDK repository with git: + +:: + + git clone http://gerrit.onap.org/r/portal/sdk + +Building the base +----------------- + +Now, we'll build the base with maven: + +:: + + cd sdk/ecomp-sdk + mvn install + +Setting up the MariaDB database +------------------------------- + +Adding support for lowercase table names +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +To add support for lowercase table names, make sure the following line in your :code:`/etc/mysql/my.cnf` file is present under the :code:`[mysqld]` section: + +:: + + lower_case_table_names = 1 + +If you made changes, you'll need to restart your MariaDB instance. Hint: + +:: + + sudo systemctl restart mariadb.service + + +Database setup +^^^^^^^^^^^^^^ + +Now, we set up the database and user privileges. Log into your MariaDB instance as the 'root' user and do the following: + +:: + + drop database if exists ecomp_sdk; + drop user if exists 'ecomp_sdk_user'@'localhost'; + + create database ecomp_sdk; + create user 'ecomp_sdk_user'@'localhost' identified by 'password'; + grant all privileges on ecomp_sdk.* to 'ecomp_sdk_user'@'localhost'; + +Adding tables +^^^^^^^^^^^^^ + +Next, we need to run several SQL statements in the repository: + +:: + + mysql -proot -uroot < sdk/ecomp-sdk/epsdk-app-common/db-scripts/EcompSdkDDLMySql_1707_Common.sql + mysql -proot -uroot < sdk/ecomp-sdk/epsdk-app-common/db-scripts/EcompSdkDMLMySql_1707_Common.sql + mysql -proot -uroot < sdk/ecomp-sdk/epsdk-app-os/db-scripts/EcompSdkDDLMySql_1707_OS.sql + mysql -proot -uroot < sdk/ecomp-sdk/epsdk-app-os/db-scripts/EcompSdkDMLMySql_1707_OS.sql + + +Using 'root' for both your MySQL username and password is just about the worst security policy imaginable. For anything other than temporary setups (very temporary), please choose reasonable user names and hard-to-guess passwords. + +Your project directory +------------------------------- + +Because you'll want your project to use the latest portal SDK code (retrieved via :code:`git pull`), you work directly in :code:`sdk/ecomp_sdk/epsdk-app-os`. + +Connecting your app to the backend database +------------------------------------------- + +We need to tell our app how to access the database tables we created above. Open :code:`sdk/ecomp-sdk/epsdk-app-os/src/main/webapp/WEB-INF/conf/system.properties` and change the following two lines to reflect the database user you set up above as well as your particular installation of MariaDB: + +:: + + db.connectionURL = jdbc:mysql://localhost:3306/ecomp_sdk + db.userName = ecomp_sdk_user + db.password = password + +Building your app +----------------- + +When you want to build your app: + +:: + + # First cd to the project directory + cd sdk/ecomp_sdk/epsdk-app-os + mvn clean package + +.. note:: You don't always have to :code:`clean`. Only use it when you want to clear out intermediate objects and build your entire project from scratch. + +.. _installingyourapp: + +Installing your app +------------------- + +To install your app, run the following commands, or better, create a script: + +:: + + # Shutdown tomcat + <tomcat install>/bin/shutdown.sh + rm -rf <tomcat install>/webapps/epsdk-app-os* + cp target/epsdk-app-os.war <tomcat install>/webapps/. + # Start tomcat + <tomcat install>/bin/startup.sh + +Viewing your app +---------------- + +Assuming you have installed Tomcat locally, for example in a vagrant VM with port forwarding, you can `access the app`_ in your normal browser: + +:: + + http://localhost:8080/epsdk-app-os/login.htm + +To log in, use user/password 'demo/demo'. + +.. _access the app: http://localhost:8080/epsdk-app-os/login.htm |