Skip to content

Virtual Machine Builds

John Paden edited this page Oct 7, 2020 · 47 revisions

Virtual machine (VM) builds are useful for developing, debugging and learning how to use the OPS environment.

There are pre-built VM's that are useful for taking to the field (https://data.cresis.ku.edu/data/ops/). The steps below also describe how to create these pre-built VM's.

Alternately (and additionally), there is an image of the most current OPS system, without data, located in the ops projects folder (P:\ops\builds). This can be imported into the virtual box(File > Import Appliance) to test changes or develop OPS. This build is virtually identical to what OPS is currently running (the major difference is that OPS is running on redhat and receives system updates). Whenever changes are made to OPS, they should first be tested on the newest appliance. Once the changes are made, it is advisable to recreate the appliance and replace the older one in the projects folder.

Build an OPS VM

Creating a Template VM

NEED TO FINISH DESCRIBING THIS PROCESS Rather than starting from scratch, we recommend starting with the template VM. This section describes how to create the template VM.

The template VM has only a minimal setup:

  1. Centos base install
  2. Username and password setup for root
  3. Username and password setup for pub
  4. Desktop background image
  5. Virtual box guest additions

Template VM

The OPS template VM is called ops.base.ova and is available here. This VM has minimal software already installed and is a good starting place for creating a pre-built VM. This VM has CentOS Linux installed and a few additional packages (NEED TO SPECIFY WHICH HERE). It still needs to be "provisioned". The steps below describe how to provision the VM.

Create a new build from the template VM

  • Download the template VM
  • Install Oracle Virtual Box
  • Import the template VM into Oracle Virtual Box
  • Set the shared folder path if you want a convenient way to pass files back and forth from your VM.
  • Run the VM
  • Login to the VM Default login information: username: ops, password: pubOps
  • Open a terminal and enter the following code:

sudo -i
yum update -y
mkdir /vagrant && cd /vagrant
git clone https://github.com/cresis/OPS.git .
reboot

  • If you want to use "Guest Additions", choose "Devices-->Insert Guest Additions CD Image" from the VM window. This should bring up a few prompts to install the Guest Additions. This will usually ask you to reboot after a successful install before proceeding.

  • After the VM is rebooted, log in and open the terminal, enter the following code:

sudo -i
cd /vagrant
sh conf/provisions.sh
reboot

You will be prompted for a database user/password. Accept the defaults (admin and pubAdmin) by pressing enter. At some point you will be asked to accept two JAVA license agreements. A [MORE] prompt will appear. You can use your space bar to skip to the YES/NO (hit it until you see YES/NO). Type yes for both.

Next, you will be prompted to add django admins. There can be zero or more admins that will be emailed error information if/when django encounters errors. It is recommended that at least one person be on the admin list to receive and deal with such errors.

Finally, you will be asked if django should operate in debug mode. The answer to this question should always be 'no' in a production environment. If working in a development environment, however, activating django's debug mode may provide insight to errors encountered during development. You can change to and from debug mode later by editing /var/django/ops/ops/settings.py and setting DEBUG to true or false.

  • Should you want to preload a portion of the database (i.e. for a field deployment), start the process here instead.

  • If one wants to have the eclipse IDE pre-installed and configured for the build, follow these instructions.

  • You will need to create an anonymous user for the system to work properly. First edit the createUserExample.py file with the new user information. This file is located at "/vagrant/conf/tools/" on your virtual box. Then follow the instructions in the header of createUserExample.py to run python. From within python, run "execfile('createUserExample.py')". This anonymous user should have the following properties: ** username: "anonymous" ** email: "[email protected]" ** password: "anonymous".

  • Run the OPS tests to verify Django is operational on the VM.

  • Next, run MATLAB from your host machine. After setting up the cresis-toolbox, in Matlab: ** edit opsCmd and set "gOps.sysUrl = 'http://192.168.111.222/';" ** run "opsTests"

  • Before testing, make sure the virtual box network environment is set up to use 192.168.111.222. See Virtualbox installation for directions on how to set the host only adapter to use this IP address.

  • If all tests pass the OPS VM is provisioned and running. Finally you can make sure the GeoPortal is working by visiting 192.168.111.222 on your host machine.

  • Secure the geoserver by:

    • Logging into the geoserver (192.168.111.222/geoserver/web/)
    • log in as the administrator (username: root password: pubMaster)
    • Navigate to the Passwords tab (left hand bar)
    • Click on Change password and change it to the standard CReSIS OPS password
  • To finish up the process enter the following commands in a new terminal (close all others):

sudo -i
yum clean all
history -c
exit
history -c
sudo -i
shutdown -h now

Making changes to the VM setup

OPS is open source on github and so authentication is not needed to grab the source code. However, to push changes back to OPS, you need to authenticate. Some additional commands are needed for this:

sudo -i
git config --global user.name "FIRST_NAME LAST_NAME"
git config --global user.email "[email protected]"
git remote set-url origin https://[email protected]/cresis/OPS.git

Create a pre-built VM

After following the steps in [Build an OPS VM](Build an OPS VM), do the following:

  • In Oracle VirtualBox VM Manager click on the VM that you created and rename the VM. Select the "General" settings. Then select the "Basic" tab under the General settings and then change the Name field. Our typical naming convention is: ops.build.yyyy.mm.dd (e.g. "ops.build.2014.05.15")

  • In Oracle VirtualBox VM Manager select File > Export Appliance and select the renamed VM, decide on an output location, and OVF 1.0 as the format. At CReSIS, these prebuilt VM's are shared at /cresis/snfs1/dataproducts/public/data/ops/ which is https://data.cresis.ku.edu/data/ops/.

Using a pre-built VM

The expected IP address is 192.168.111.222 for the setup scripts in the pre-built VM. The virtual box IP address will be something different than this. For example, it may be 192.168.56.102 (use ifconfig -a for Linux including VM). The host computer IP address may be 192.168.56.1 (use ipconfig /all for windows).

To interact with the pre-built VM at a different IP address and to allow the host computer to access it fully:

  1. Add these two ip addresses to allowed hosts:
    • /var/django/ops/ops/settings.py
      • This allows access to the read only interfaces
    • /var/django/ops/ops/authip.py
      • This allows access to the write interfaces
  2. Change the last line in: /etc/httpd/conf/httpd.conf
    • Go to the last line and change IP address to 192.168.56.102 (or whatever your virtual box's IP address is that you will access it on)
    • Comment out: Include /var/www/sites/192.168.111.222/conf/ops.conf
    • Add: Include /var/www/sites/192.168.56.102/conf/ops.conf
  3. Rename the sites directory from 192.168.111.222 and update IP addresses in:
    • /var/www/sites/192.168.56.102/conf/ops.conf
    • /var/www/sites/192.168.56.102/cgi-bin/proxy.cgi

From a Matlab session on the host computer, update your gRadar.ops.url to point to the new server. Usually this involves updating your startup.m to set the OPS URL and rerunning the startup.m:

profile(pidx).ops.url = 'http://192.168.56.102/'; % Read-only for outside of CReSIS

From the Matlab session on the host computer, run opsExploreDatabase.m and it should output:

=============================================
Table opsuser_userprofile_snow_layer_groups:
id  userprofile_id  layer_groups_id
-------------------------------------
3   1               1                
4   1               2       
...