====== Intellij IDEA - Setup of SNMP Manager environment ======
Author: David McGee + Colm Carew + Avi
===== Prerequisites =====
In order for everything to go as smoothly as possible please ensure you have done or will do the following before importing the project into Idea.
* Ensure you can run Intellij as sudo as the Snmp Manager needs to be run as sudo - sudo /Applications/IntelliJ\ IDEA.app/Contents/MacOS/idea - maybe set up and alias
* Install Grails 2.5.6 for Mac Install SDK Man http://sdkman.io/install.html and use it to install grails 2.5.6 - sdk install grails 2.5.6
* Download Mac JDK-7 from dropbox and place it in ~/.sdkman/candidates/java/
* You will need to download GWT 2.5.1 and keep it in a secure directory i.e. your user directory or your documents http://www.gwtproject.org/versions.html. Once downloaded you will need to set GWT_HOME to be the location of where you put the downloaded directory - do this in your .bashrc or .bash_profile file
* Ensure your host file (/etc/hosts for mac/linux) contains the following entry : 23.23.106.9 errigalArtifactory errigalArtefactory
* Ensure you have Idea Ultimate as Idea CE does not support grails. The applications can be run from the command line.
* Ensure your password for the root account in MySQL is the same as on our QA - ask someone if you don't know it :)
===== DB and Appfile Setup =====
Unfortunately there are a lot of steps here but there is an easy way and a hard way, the easy way only applies to CC and EXT DBs for now.
For either you should run these two commands first :
* sudo mkdir -p /export/home/scotty/appfiles/
* sudo chown -R $(whoami) /export/home/scotty
==== The Easy Way ====
* Install the necessary tools:
* Install Homebrew
* /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
* Install Ansible
* brew install ansible
* Install SSHPASS
* brew install https://raw.githubusercontent.com/kadwanev/bigboybrew/master/Library/Formula/sshpass.rb
* Clone the following two projects into the same folder (I suggest an applications folder or IdeaProjects folder) :
* https://bitbucket.org/errigal/database-setup
* https://bitbucket.org/errigal/env-configuration
* CD into database-setup
* Run the following command
* ansible-playbook -i ../env-configuration/prodcrc local.yml --diff --extra-vars "database=snmp_manager mysql_root_pass=THEDBPASS" --vault-id @prompt
* Note that prodcrc can be replaced with prodext if you want EXT data. The database is snmp_manager and ensure to change the root password to your local root password install
* If you are running MySQL through docker you will need to run:
* ansible-playbook -i ../env-configuration/prodcrc local.yml --diff --extra-vars "mysql_path='docker exec -i CONTAINER /usr/local/mysql/bin/mysql' database=snmp_manager mysql_root_pass=THEDBPASS" --vault-id @prompt
* You will need the password for this so also ask someone for that if you don't know it, Once done just leave it run and complete and it should download the DB and run development transforms as well as download the app files
==== The Harder Way ====
* Download a micro/small SNMP Manager database from a customer and load it into your local MySQL instance.
* Run the Dev scripts on this database, they should be found in - https://bitbucket.org/errigal/idms-sql-script
* Create the following directory and make sure to take the SnmpManagerFiles directory from the same instance you took the database from (i.e. if you take an EXT DB you also have to go to the EXT app handler and get the Appfiles for this application). Again, please ask a colleague for help here if you don't know what to do.
* sudo mkdir -p /export/scotty/home/appfiles/SnmpManagerFiles
* Make sure these folders are owned by you
* sudo chown -R : /export/scotty/home
* Clone the project from BitBucket : git clone https://bitbucket.org/errigal/snmpmanager.git
===== Importing the Project in Idea =====
* Click Import Project and Select the snmpmanager project and click ok
* Choose Create project from existing sources and click next
* Click next to leave the Project Name as default
* Click next again
* You will then be asked to pick an SDK, ensure you choose 1.7
* You will then be asked from the grails version, navigate and find your install of grails 2.5.6, select it and click next
* You will then be given a list of detected frameworks, click Finish
* Once loaded you should be asked to Configure GWT, click configure then click OK on the next popup
* You should now locate the development scripts and run them against your freshly imported SNMP Manager database. If there are no development scripts, run the QA scripts.
* Next you will need to locate the grails configuration and click edit, this will be at the top bar of Idea and should be to the right
* In the VM Options enter the following, remember to change the database to your appropriately named database for the Reporting Manager
* -Xms4096m -Xmx4096m -XX:PermSize=2048m -XX:MaxPermSize=512m -XX:+UseConcMarkSweepGC -Djava.snmpmanager.database=snmp_manager -Dhttps.protocols=TLSv1
* In the Command line options (above the VM options) make sure it looks like
run-app --refresh-dependencies -Dgrails.server.port.http=8082
* Ensure **grails-app/actionHandlers** directory is marked as source root (classes may not be imported correctly otherwise)
* Right click on grails-app/actionHandlers directory
* Mark Directory as => Source Root
* NOTE as of grails 2.5.6 --refresh-dependencies is important as you will get a class not found error for ireasoning (The Snmp Trap Jar)
* Click Apply and OK
* Right click the ./lib folder and click on "Add as library"
* Open the Run Grails Command Window in Idea, on Mac this is accomplished via CMD+ALT+G
* Enter clean as a command click ok and allow it to finish
* Open the Grails command window again and run compile and allow it to finish
* Open the Grails command window again and run compile-gwt-modules and allow it to finish
* Click Run and the Grails Application should run. Monitor the logs to ensure you do not get any exceptions!
===== Tips/Troubleshooting =====
Only look at these if you're having issues
If you have issues with dependency errors on compile, ensure you are running Intellij as ROOT
* add alias idea="sudo /Applications/IntelliJ\ IDEA.app/Contents/MacOS/idea" to your .bash_profile
Quartz : You may want to drop and recreate the quartz/qrtz tables : http://wiki.err/doku.php?id=development:grails:grails25&s%5B%5D=qrtz
You may experience issues with the following when trying to get the SNMP Manager setup on a dev environment:
* SNMP Manager won't start due to MIB/Trap Rules/File mismatch. We need to make sure that the trap rule files referenced in the database are the same as the files you have on your local dev box :) This is why it's important to take the database and files from the same QA location, within a close time interval.
* Keep an eye on the configuration tables during dev setup: configuration, thread_config and remote_thread_config tables. Ensure the data in the table fields match up with your dev environment as expected.
* If you are getting the "ireasoning" related library (class not found, etc.) issues, add the "--refresh-dependencies" option to your Grails app run configuration.