Jump to: navigation, search

Difference between revisions of "Trove/dev-env"

(Created page with "= Trove API and Redstack Dev Environment Set Up on Mac OS X = == Intro == This article describes how to point a local running Trove instance to a Devstack/Redstack deployment...")
 
(VM)
Line 17: Line 17:
  
 
== Installing VMWare Fusion and Trove services ==
 
== Installing VMWare Fusion and Trove services ==
=== VM ===
+
openstack=== VM ===
 
# In order to run trove/redstack in a local VM, you need to start by installing a guest with Ubuntu 12.04 server. Download an image file from Ubuntu's web site (http://www.ubuntu.com/download/server) and create a new guest from it in your preferred virtualization solution (VMWare fusion, VirtualBox, Parallels, etc.)
 
# In order to run trove/redstack in a local VM, you need to start by installing a guest with Ubuntu 12.04 server. Download an image file from Ubuntu's web site (http://www.ubuntu.com/download/server) and create a new guest from it in your preferred virtualization solution (VMWare fusion, VirtualBox, Parallels, etc.)
 
## Recommended version ubuntu-12.04.1-server-amd64.iso
 
## Recommended version ubuntu-12.04.1-server-amd64.iso
Line 24: Line 24:
 
### Notice! It seems that the guest-agent will fail to "$ sudo pip install extras" and the below should be run on the redstack guest: <pre>$ sudo iptables -t nat -A POSTROUTING -s 10.0.0.0/24 -o eth0 -j MASQUERADE</pre>
 
### Notice! It seems that the guest-agent will fail to "$ sudo pip install extras" and the below should be run on the redstack guest: <pre>$ sudo iptables -t nat -A POSTROUTING -s 10.0.0.0/24 -o eth0 -j MASQUERADE</pre>
 
## It seems there is no need for the VMWare tools. They don't solve the copy/paste (or make working with the terminal any easier...) and we simply recommend using ssh instead. see details below.
 
## It seems there is no need for the VMWare tools. They don't solve the copy/paste (or make working with the terminal any easier...) and we simply recommend using ssh instead. see details below.
## For better performance, make sure you go to the VM Settings -> Processors & Memory -> Advanced Options and check the "Enable hypervisor applications in this virtual machine" (see more about this at the bottom of this page: https://github.com/stackforge/trove-integration)
+
## For better performance, make sure you go to the VM Settings -> Processors & Memory -> Advanced Options and check the "Enable hypervisor applications in this virtual machine" (see more about this at the bottom of this page: https://github.com/openstack/trove-integration)
## The full description of installing Redstack is described here: https://github.com/stackforge/trove-integration/blob/master/README.md but we recommend you follow this path:
+
## The full description of installing Redstack is described here: https://github.com/openstack/trove-integration/blob/master/README.md but we recommend you follow this path:
 
### When you set up the guest ubuntu, either create is with the 'ubuntu' user or add it: <pre>$ adduser ubuntu</pre> <pre>$ visudo</pre>
 
### When you set up the guest ubuntu, either create is with the 'ubuntu' user or add it: <pre>$ adduser ubuntu</pre> <pre>$ visudo</pre>
 
#### Add this line to the file below the root user <pre>$ ubuntu  ALL=(ALL:ALL) ALL</pre> <pre>**OR use this if you dont want to type your password to sudo a command**</pre> <pre>$ ubuntu  ALL=(ALL:NOPASSWD) ALL</pre>
 
#### Add this line to the file below the root user <pre>$ ubuntu  ALL=(ALL:ALL) ALL</pre> <pre>**OR use this if you dont want to type your password to sudo a command**</pre> <pre>$ ubuntu  ALL=(ALL:NOPASSWD) ALL</pre>
Line 32: Line 32:
 
### Get git: <pre>$ apt-get update</pre> <pre>$ apt-get install git-core -y</pre>
 
### Get git: <pre>$ apt-get update</pre> <pre>$ apt-get install git-core -y</pre>
 
### This is a good point to take a snapshot of this guest
 
### This is a good point to take a snapshot of this guest
### Clone this repo: <pre>$ git clone https://github.com/stackforge/trove-integration.git</pre>
+
### Clone this repo: <pre>$ git clone https://github.com/openstack/trove-integration.git</pre>
 
### Go into the scripts directory: <pre>$ cd trove-integration/scripts/</pre>
 
### Go into the scripts directory: <pre>$ cd trove-integration/scripts/</pre>
 
#### Install all the dependencies and then install trove via devstack (this Brings up trove (rd-api rd-tmgr) and initializes the trove database) <pre>$ ./redstack install</pre>
 
#### Install all the dependencies and then install trove via devstack (this Brings up trove (rd-api rd-tmgr) and initializes the trove database) <pre>$ ./redstack install</pre>
Line 39: Line 39:
 
#### or running the steps manually: <pre>$ ./redstack build</pre> <pre>$ ./redstack test-init (used to be "initialize"?)</pre> <pre>$ ./redstack build-image mysql (or "percona")</pre>
 
#### or running the steps manually: <pre>$ ./redstack build</pre> <pre>$ ./redstack test-init (used to be "initialize"?)</pre> <pre>$ ./redstack build-image mysql (or "percona")</pre>
 
#### And starting it: <pre>$ ./redstack start</pre>
 
#### And starting it: <pre>$ ./redstack start</pre>
### For more information and usage see here:  https://github.com/stackforge/trove-integration/blob/master/README.md
+
### For more information and usage see here:  https://github.com/openstack/trove-integration/blob/master/README.md
 
## There used to be an issue with precise getting jammed. We're not sure if this is still the case, but if you get into such issues, please check the workaround described here:
 
## There used to be an issue with precise getting jammed. We're not sure if this is still the case, but if you get into such issues, please check the workaround described here:
 
### Installing Ubuntu Precise on VMWare Fusion http://wiki.openstack.org/vmware-fusion-precise (just use defaults)
 
### Installing Ubuntu Precise on VMWare Fusion http://wiki.openstack.org/vmware-fusion-precise (just use defaults)

Revision as of 18:51, 24 July 2013

Trove API and Redstack Dev Environment Set Up on Mac OS X

Intro

This article describes how to point a local running Trove instance to a Devstack/Redstack deployment in a VM or Cloud instance. You should be able to debug and test your changes without having to deploy.

Prerequisites

Installing VMWare Fusion and Trove services

openstack=== VM ===

  1. In order to run trove/redstack in a local VM, you need to start by installing a guest with Ubuntu 12.04 server. Download an image file from Ubuntu's web site (http://www.ubuntu.com/download/server) and create a new guest from it in your preferred virtualization solution (VMWare fusion, VirtualBox, Parallels, etc.)
    1. Recommended version ubuntu-12.04.1-server-amd64.iso
    2. Recommended RAM size is 2GB, but could probably work with 1GB if needed
    3. It seems no special network settings are needed in order to be able to access the guest from the host, the defaults work just fine
      1. Notice! It seems that the guest-agent will fail to "$ sudo pip install extras" and the below should be run on the redstack guest:
        $ sudo iptables -t nat -A POSTROUTING -s 10.0.0.0/24 -o eth0 -j MASQUERADE
    4. It seems there is no need for the VMWare tools. They don't solve the copy/paste (or make working with the terminal any easier...) and we simply recommend using ssh instead. see details below.
    5. For better performance, make sure you go to the VM Settings -> Processors & Memory -> Advanced Options and check the "Enable hypervisor applications in this virtual machine" (see more about this at the bottom of this page: https://github.com/openstack/trove-integration)
    6. The full description of installing Redstack is described here: https://github.com/openstack/trove-integration/blob/master/README.md but we recommend you follow this path:
      1. When you set up the guest ubuntu, either create is with the 'ubuntu' user or add it:
        $ adduser ubuntu
        $ visudo
        1. Add this line to the file below the root user
          $ ubuntu  ALL=(ALL:ALL) ALL
          **OR use this if you dont want to type your password to sudo a command**
          $ ubuntu  ALL=(ALL:NOPASSWD) ALL
      2. Install ssh server on the guest:
        $ sudo apt-get install ssh (or openssh)
      3. Now, you can run ifconfig on the guest and get it's IP. Use that to ssh (as ubuntu) to it from your mac and continue working from there, it's easier ...
      4. Get git:
        $ apt-get update
        $ apt-get install git-core -y
      5. This is a good point to take a snapshot of this guest
      6. Clone this repo:
        $ git clone https://github.com/openstack/trove-integration.git
      7. Go into the scripts directory:
        $ cd trove-integration/scripts/
        1. Install all the dependencies and then install trove via devstack (this Brings up trove (rd-api rd-tmgr) and initializes the trove database)
          $ ./redstack install
      8. Since latest merges of Redstack in to Devstack, i'm not sure what is the exact state of the system at this point, since the screen session is already showing trove-api and trove-taskmanager as running in two of the screens. In any case you can "initialize" trove by:
        1. running this, which encapsulate several calls:
          $ ./redstack kick-start mysql
        2. or running the steps manually:
          $ ./redstack build
          $ ./redstack test-init (used to be "initialize"?)
          $ ./redstack build-image mysql (or "percona")
        3. And starting it:
          $ ./redstack start
      9. For more information and usage see here: https://github.com/openstack/trove-integration/blob/master/README.md
    7. There used to be an issue with precise getting jammed. We're not sure if this is still the case, but if you get into such issues, please check the workaround described here:
      1. Installing Ubuntu Precise on VMWare Fusion http://wiki.openstack.org/vmware-fusion-precise (just use defaults)

Local Dev

The main idea here, is to have trove-api and/or trove-taskmanager running locally on your mac (in a console or through your IDE so you can actually debug the code) but working against keystone/nova/swift/rabbit-mq/mysql that are all installed on your redstack node (installed above)

  1. First, get the code:
    $ git clone https://github.com/stackforge/trove.git
  2. You'll need the have mysql client installed. If you don't have it already, install it using homebrew (running $ sudo pip install mysql-python would fail otherwise)
    1. Installing homebrew https://github.com/mxcl/homebrew/wiki/Installation
    2. Then install mysql
      $ brew install mysql
  3. You're going to use a dedicated python virtual env. Set it up and "activate" it like this:
    $ trove/trove/tools/install_venv.py
    $ source ./venv/bin/activate
  4. In your new env, install python-swiftclient and mysql-python:
    $ sudo pip install python-swiftclient
    $ sudo pip install mysql-python
  5. Due to some issue with openssl and cms (that doesn't work properly on a mac by default) you'll have to apply this fix:
    1. Download the openssl tar ball from http://www.openssl.org/source/
      1. openssl-1.0.1e.tar.gz seems to work fine: http://www.openssl.org/source/openssl-1.0.1e.tar.gz
    2. unzip it ($ tar xvzf filename) and follow the instruction here:
      1. Installing openssl on Mac OS X with cms enabled http://stackoverflow.com/questions/9275786/updating-openssl-version-on-osx
        1. basically, running:
          sudo ./Configure --prefix=/usr/ darwin64-x86_64-cc enable-cms
          $ sudo make
          $ sudo make test
          $ sudo make install
    3. As an alternative you can run
      brew install openssl
      and then back up and replace
      sudo cp /usr/bin/openssl /usr/bin/openssl_old; sudo cp /usr/local/Cellar/openssl/1.0.1e/bin/openssl /usr/bin/openssl; sudo chown root:wheel /usr/bin/openssl; sudo chmod 755 /usr/bin/openssl
  6. Depends on what you've done so far, you might need to "clean up" your env. If you encounter issues with keystone (authenticating) try this:
    1. Delete all .pem files under /tmp/keystone-signing-nova
    2. Delete all .pem files under /tmp/keystone-signing-trove
    3. You might also have to delete ~/.apitoken

Configuring local trove files

For your local processes (api and taskmanager) to find the needed resources on your redstack, you'll have to modify the conifg files. It is recommended you create a copy of trove.conf.sample and trove-taskmanager.conf.sample, modify them and point to those copies when running the api and taskmanager services (details below). You'll also have to modify the api-paste.ini, but since it's currently referenced hard codedly, you'll have to modify this file directly and be carefull not to check it in ;-)

  1. Update the auth_host entry in api-paste.ini with the ip of your redstack guest
  2. Update the host entries in trove.conf.sample & trove-taskmanager.conf.sample to point to the Devstack/Redstack host (i.e. nova_compute_url, nova_volume_url, notifier_queue_hostname)
    1. No need to change the bind_host (i think ...)
    2. sql_connection = mysql://root:e1a2c042c828d3566d0a@localhost/trove - replace localhost with the redstack ip
    3. swift_url = http://localhost:8080/v1/AUTH_ - replace localhost with the redstack ip
    4. trove_auth_url = http://0.0.0.0:5000/v2.0 - replace the 0.0.0.0 with the redstack ip
    5. nova_compute_url = http://localhost:8774/v2 - replace localhost with the redstack ip
    6. nova_volume_url = http://localhost:8776/v1 - replace localhost with the redstack ip
    7. notifier_queue_hostname = localhost - replace localhost with the redstack ip
    8. rabbit_host = localhost - replace localhost with the redstack ip. add this one if it's not there
  3. Update the trove-guestagent.conf.sample as well if you are going to be running this locally.

Running the trove services locally

Trove scripts currently expect to be run from the project root folder. Configure your IDE to do this, and also make sure to use the .venv as the interpreter

  1. $ bin/trove-api --config-file=etc/trove/trove.conf.sample (web service)
    1. Notice! if you created a copy of the config file, make sure you point to your copy instead!
  2. $ bin/trove-taskmanager --config-file=etc/trove/trove-taskmanager.conf.sample (task manager)
    1. Notice! same as the notice above ;)
  3. $ bin/trove-guestagent --config-file=etc/trove/trove-guestagent.conf.sample (guest agent)
    1. Notice! same as the notice above ;)

You can now access your local api server using curl, Chrome's Advanced Rest Cliet or trove-cli (the command line utility - get it by installing python-troveclient) To get things rolling, you start by obtaining an auth token. For some reason, i couldn't do this with the Chrome's rest client, but you can use the two methods below:

  1. $ curl -d "{\"auth\":{\"passwordCredentials\":{\"username\": \"radmin\", \"password\": \"radmin\"},\"tenantName\":\"trove\"}}" -H "Content-type: application/json" http://IP_OF_REDSTACK_GUEST:35357/v2.0/tokens
    1. Notice, you use the redstack ip since this is were your keystone runs
  2. $ trove-cli --username=radmin --apikey=radmin --tenant=trove --auth_url=http://IP_OF_REDSTACK_GUEST:35357/v2.0/tokens auth login --service_url http://localhost:8779/v1.0/YOUR_TENANT_ID
    1. You can obtain your tenant_id by running this on the redstack guest:
      $ ./redstack nova-client credentials
    2. Notice the use of the --service_url

Remember that you also have the api and taskmanager running on your redstack node. So remember to have only one running - those that you start locally, needs to be stopped on the redstack node. ssh into it, run screen -x stack, go the the relevant screen (ctrl a followed by ctrl " - will show you the list of screens and you can select the one you need) and hit ctrl c to stop them. you can then restart them by hitting the up arrow and enter.

Hacking RabbitMQ

The api server talks to the taskmanager via Rabbit, and "knows" the name of the queue from the trove.conf.sample (or your local copy of it, if renamed): taskmanager_queue = taskmanager When running taskmanager under debug, it'll actually create/listen on a queue called pydevd.py - be sure to update your conf file appropriately if you run taskmanager under debug. also, make sure to bounce the api server after you make those changes. Also, notice, that even if you leave the api server running on the redstack node, you'd still have to update this conf file, it should be under /etc/trove/trove.conf

There is a nice management plugin for RabbitMQ, with a web gui console. To use it, do the following:

  • On the Redstack node (the one running Rabbit) run:
    $ sudo /usr/lib/rabbitmq/bin/rabbitmq-plugins enable rabbitmq_management
    $ sudo service rabbitmq-server restart
  • You can now access it through port 55672:
  • The default user to use is: "guest" and the password is taken from redstack.rc:
    • RABBIT_PASSWORD=f7999d1955c5014aa32c
  • more about this console: http://www.rabbitmq.com/management.html

Accessing the DB

In order to access the admin DB on the redstack guest, you can:

  • Run:
    $ mysql -u root -p"ADMIN_PASS"
    mysql> show databases; (to see the databases)
    mysql> use trove; (to start using the trove DB)
    mysql> show tables; (to see the list of tables)
    • Now run any query you want
    • The admin password is taken from redstack.rc:
      • MYSQL_PASSWORD=e1a2c042c828d3566d0a
  • Alternatively, you can setup a local gui-based client on your mac, such as SequelPro and point to your redstack ip

Notes

  • If the services are not run in the project root the trove/extensions will not be loaded.
  • If you are developing guest agent code you will probably still have to copy files to the VM Devstack/Redstack