Monday, November 24, 2014

How to Install OpenStack Juno on VirtualBox via DevStack

In my previous post, I share how to set up your own openstack lab via devstack. After I played around the devstack lab, I think I can make whole set up easier. Here, I would like to share how to set up the newest openstack release - juno. The general steps list as below.


  1. Setup VirtualBox
  2. Install Unbuntu
  3. Clone Code from GitHub and Execute ./stack.sh
  4. Connect to Horizon ( web management console ) and command line.

1. Setup VirtualBox
    a. CPU: 1 Processor
    b. Memory: 4GB
    c. HDD(Drive Space): 40GB
    d. Two Network Adaptors: 1 NAT, 2 Host-only

cpu:


Memory:


Drive Space:


NCI (Network Adaptor)1 :




















NCI (Network Adaptor)2 :

Update:
if you would like to connect from another laptop in the local LAN, you can try to add 3rd NIC card (NCI (Network Adaptor)3 :) and set up with "Bridge Adapter" (Some people said port forwarding, but I used Bridge). When you check the ip addr / ifconfig you will see there has IP against the 3rd NIC card.

2. Install Ubuntu
I install unbuntu 14.04 desktop version (ubuntu-14.04.1-desktop-amd64.iso). I skip this since there has lots of online resources.

3. Clone code and run ./Stack.sh
After you setup your ubuntu box, login and launch command line ( terminal ) and execute the command as below


# sudo apt-get update
# sudo apt-get upgrade
sudo apt-get dist-upgrade
sudo reboot

sudo apt-get install git

git clone -b stable/juno https://github.com/openstack-dev/devstack.git
cd devstack
wget https://dl.dropboxusercontent.com/u/44260569/localrc
./stack.sh

Installation Done ! username: admin / demo and password: devstack



























ps: 
  • Download juno version from github is using -b ( branch ) to version juno.
  • I prepared the localrc for juno. You can download it via wget. localrc is old version configuration file, the new configuration file is local.conf but when setup program check there has localrc, it will reference it first, otherwise it will follow local.conf. 
  • If you want to change user account (admin or demo) to your password, you can edit localrc file. However, it's better to use vim (# sudo apt-get install vim ) since vi is painful when I use it.
  • ./stack.sh will take a while, but if your OS is forced to sleep via such as screen saver, you better to stop it or watch it when it running to avoid the interruption.


4. Connect to horizon and ssh
Since I setup 2nd host-only Network adapter. The 1st NCI card is eth0 and 2nd should be eth1. You just try the command(# ifconfig) to get the eth1 IP address and should be able to connect to your juno lab via it.

Check 2nd NCI, eth1 via linux cli
# ifconfig

Use Host-only Adaptor's IP for horizon login




























Connect via SSH


















PS: SSH login via username demo and password devstack.
You can run source openrc admin admin to grant admin privilege for your command line test after you login.

here is the example.
# cd devstack
# source openrc admin admin

This is easier way I found so far, please free to share if you found the better way to setup the newest release openstack lab.

PS: the solution of the post has some issues, I listed as below fyi. For these issues, I will study and post the follow up solutions for it.

  • All OpenStack Modules works but SWIFT. 
I actually fixed the issue. Here is the solution which updated the localrc (the dropbox download has been updated) and add parameter as below. 


# SWIFT - Object Storage

ENABLED_SERVICES+=,s-proxy,s-object,s-container,s-account



Now, the swift is running ok , here is the example. I create on "Container1" and upload two files (objects).








  • After reboot, the virtualbox network configuration might corrupt. You might take a snapshot after your first installation and retrieve the status back.
I read some blogs mentioned about the services didn't up after reboot. Some people said it's a known issue and some people said it's not a "issue" but is that way by design. No matter how, I post the update as below which may helps you restart the devstack services.

Restart DevStack

1. First make sure your volume up.
Bring volume group online so that cinder-volume will start without errors

    ls demo@demo-juno:/opt/stack/data

double check your cinder-volume name. and you losetup to set up and control loop devices.
sudo losetup -f /opt/stack/data/stack-volumes-backing-file
2. Use rejoin-stack.sh to restart the DevStack
./rejoin-stack.sh

Sunday, November 9, 2014

Voice Recognition with Java and C#

In previous post, I mentioned AIML. It's an AI ChatBot to digest natural language chat. I am always think it's cool to combine with Voice Recognition. Thus, people can be not only asking the ChatBot quesion for the answer but also asking AI ChatBot to "do something". Here is an example that the Voice activation with system (US Pizza Papa John’s allows to order pizza via Voice System, same with their supply chain system :http://www.papajohns.com/ordering/mobile.shtm, http://www.mmh.com/article/papa_johns_fresh_take_on_wms_and_voice_technology )

I spent my weekend and try a little bit voice recognition on demo with Java and C#, here are the details.
(PS: It’s better you try this in Meeting Room by alone or at your home, otherwise when you test, you will look like idiot )    J

Java Version
---------------

Preparation: 
----------------
JDK 8 ( J2EE )
Eclipse SDK ( LUNA )
JSAPI ( Included in Sphinx 4 : jsapi.jar)

1.       Create a java project and add jars

2.       Test HelloWorld.jar

3.       Try Hello World Source Code

a.       HelloWorld.java
b.      hello.gram ( grammer file )
c.       helloworld.config.xml ( config file )

4.       I added new recognition grammer “Hey Johnny” in *.gram


Modified *.java showing in command line.


5.       I don’t wanna change config.xml now so I follow whatever in manifest/config first. ( add one more jar into UserLib ). Now it’s working


Last: I can duplicate this voice recognition to trigger “Check Vagrant Version” with my Java ChatBot. Then it will trigger check vagrant version cli.
-----------------------------------------------------------------------------------
C# version, here has full example.

add  System.Speech reference



Here is form1.cs example:


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Speech.Recognition;

namespace CSharpVoiceRecognition
{
    public partial class Form1 : Form
    {
        SpeechRecognitionEngine recEngine = new SpeechRecognitionEngine();
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            Choices commands = new Choices();
            commands.Add(new string[] { "Say Hello""Print My Name""Love You""Please Check My System" });
            GrammarBuilder gBuilder = new GrammarBuilder();
            gBuilder.Append(commands);
            Grammar grammer = new Grammar(gBuilder);

            recEngine.LoadGrammarAsync(grammer);
            recEngine.SetInputToDefaultAudioDevice();
            recEngine.SpeechRecognized +=recEngine_SpeechRecognized;
           
        }

        private void recEngine_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
        {
            switch (e.Result.Text)
            {
                case "Say Hello":
                    MessageBox.Show("Hello. How are you ?");
                    break;
                case "Print My Name":
                    richTextBox1.Text+="\nJohnny";
                    break;
                case "Love You":
                    richTextBox1.Text += "\nLove You Too!";
                    break;
                case "Please Check My System":
                    richTextBox1.Text += "\nNo Problem, I'm checking vagrant.";
                    break;
                default:
                    richTextBox1.Text = e.Result.Text;
                    break;
            }
            //throw new NotImplementedException();
        }

        private void btnEnable_Click(object sender, EventArgs e)
        {
            recEngine.RecognizeAsync(RecognizeMode.Multiple);
            richTextBox1.Text += "\nEnable Voice Recognition";
        }

        private void btnDisable_Click(object sender, EventArgs e)
        {
            recEngine.RecognizeAsyncStop();
            richTextBox1.Text += "\nDisable Voice Recognition";
        }
    }

}