Installing OpenStack on AWS

1. Prerequisites – Minimal requirements for hosting in AWS, but not limited to:

  • Ubuntu Server 14.04.3 LTS – 64bit
  • Minimum 2VCPU – Cores
  • Minimum 8 GB RAM for just OpenStack (m4.large), Minimum 16 GB RAM for Sahara and clustering (m4.xlarge)
  • Atleast 40 GB of diskspace

2. Install Ubuntu if you dont have one

3. Verify installed version using

lsb_release -d
free -m
df -h

4. Update to the latest binaries

sudo apt-get update

5. Create a SUDO user – alternatively you can use the /devstack/tools/create-stack-user.sh to create a user after step 8

sudo -i
adduser stack			
	Enter new UNIX password:
	Retype new UNIX password:
	passwd: password updated successfully
	Changing the user information for username
	Enter the new value, or press ENTER for the default
	Full Name []:stack
	Room Number []:
	Work Phone []:
	Home Phone []:
	Other []:
	Is the information correct? [Y/n] Y

6. Add user to SUDOERs group

usermod -aG sudo stack 
echo "stack ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers

7. Switch to the new stack user

su - stack
check if the user can do sudo operations without password prompts
sudo ls -la /root

8. Switch to user home and install GIT and checkout devstack

cd ~
sudo apt-get install git
git clone https://github.com/openstack-dev/devstack

9. Configure devstack – update local.config and move to /devstack

cd /devstack
cp sample/local.conf .

* Update the passwords for the accounts

ADMIN_PASSWORD=St@ckNewPwd1
DATABASE_PASSWORD=St@ckNewPwd1
RABBIT_PASSWORD=St@ckNewPwd1
SERVICE_PASSWORD=St@ckNewPwd1

* If you are running on a physical machine with a static IP you can update the following property. On AWS its better to leave it commented as the local IP will be changed on each restart, unless the Elastic IP is assigned to the instance

HOST_IP=172.31.26.172

* And add the following line at the end of the file. These entries will add the Sahara plugin (Data Processing) in OpenStack UI

echo "enable_plugin sahara git://github.com/openstack/sahara" >> local.conf
echo "enable_plugin sahara-dashboard git://github.com/openstack/sahara-dashboard" >> local.conf
echo "enable_plugin ceilometer git://github.com/openstack/ceilometer" >> local.conf

10. Start the stack services

./stack.sh

* This takes up sometime and logs will be available at /opt/stack/logs. On successful completion you will find details something similar as below.

=========================
DevStack Component Timing
=========================
Total runtime         1169
run_process            57
test_with_retry         3
apt-get-update          3
pip_install           299
restart_apache_server  10
wait_for_service       11
git_timed             244
apt-get                69
=========================

This is your host IP address: 172.31.26.172
This is your host IPv6 address: ::1
Horizon is now available at http://172.31.26.172/dashboard
Keystone is serving at http://172.31.26.172/identity/
The default users are: admin and demo
The password: St@ckNewPwd1
stack@ip-172-31-26-172:~/devstack$

11. To access the dashboard hit http://172.31.26.172/dashboard in browser (with the ip as displayed in the above step). If you are running in local PC you can directly access with the above url. But if you are running on AWS, this is the internal IP and will not be available to the outside world. In this case, allow HTTP access on 80 port for the outside world and access the service with the Public IP or DNS hostname allocated to your instance. This in my case http://54.23.123.43/dashboard.

Enable Registration in WordPress

In WordPress custom installations, the option for Registration of new users is disabled by default. To enable the registrations and allow logins for public you can follow the below steps.

Single site installation:

As soon as the installation is completed go to the WordPress Dashboard -> Settings

You will find an option Allow new registrations, you may need to select the Default Role for the newly registered members.

wp-user-registeration-single-site

Multi-site/Network installation:

In case if you have installed WordPress in Multi site mode go to the Network Admin -> Settings and select the options under Allow new registrations section.

wp-user-registeration-multi-site

Once the registration is enabled it may be needed to add login options at places to find it easily. Follow these methods to do the same.

Method 1:

Add Meta widget in the sidebars or in footers. Select Appearance -> Widgets and select the Meta Widget.  Note that the menu will be available in Individual Site Dashboard, not in the Network Admin dashboard in case of Multi-site installation.

wp-user-login-widget

 

Method 2:

Add the login link in your Posts/Pages and it should be in the pattern, http(s)://HOSTNAME(:PORT)/(SUBDOMAINS)/wp-login.php.

Examples:

  1. http://itechgenie.com/myblog/wp-login.php – MultiSite installation
  2. http://itechgenie.com/wp-login.php – SingleSite installation

Errors running builder ‘JavaScript Validator’ on project

I got this annoying exception on every auto build of my Dynamic Web Project.

“Errors occurred during the build.
Errors running builder ‘JavaScript Validator’ on project ‘GenieAlert’.
java.lang.NullPointerException”

I was trying to stop the validation of Javascript in the Eclipse properties with the following options,

Windows -> Preferences -> Validation -> Client-side JavaScript Validator -> Checked Manual & Unchecked Build.

This option didn’t work out, then I realized that it happens only on the Build time. The following option came in handy to do that.

Project -> Properties -> Builders -> Unchecked ‘Javascript Validator’

Sometimes when you try to run the Web projects from eclipse on servers these JavaScript validation stops the deployment of the project on servers stating “JavaScript Validation Exception found”. I hope the above solutions will help in those situations too.

Famous Short URL services

URL shortening is a technique used to make the URLs substantially shorter in length and still direct to the required page. This is achieved by using an HTTP Redirect on a domain name that is very short in length, which links to the web page that has a long URL.

URL shortening is also used for beautify a link, track the url activity, in some cases to used to disguise the underlying address for legitimate purposes.

Some of the famous URL shortening services are follows:

1. Adf.ly
2. Bit.ly
3. Goo.gl
4. Is.gd
5. Tinyurl.com
6. V.gd

Create Web Services using Axis Java2WSDL, WSDL2Java and Eclipse for all Servers manually – Part 2

With all the basic configurations done as specified in the last Article we continue to develop the Business logic.

  1. Create a class named Calculator.java, place four public methods add, subtract, multiply and delete and place the appropriate logics in it.
    package com.itechgenie.services.impl;
    public class Calculator {
    	public int add(int a, int b) {
    		return a+b  ;
    	}
    
    	public int subtract(int a, int b) {
    		return a-b ;
    	}
    
    	public int multiply(int a, int b) {
    		return a * b ;
    	}
    
    	public int divide(int a, int b) throws ArithmeticException {
    		return a /b ;
    	}
    }
  2. This is the class that has to be exposed as the Web Service and we write the funky TestRunner.java class to do all out operations like creating WSDL file, creating stub file etc.
  3. Generate WSDL file using Java2WSDL: Axis has a tool called Java2WSDL, which generates a WSDL file for a web service using a Java class. Java2WSDL file takes the following arguments.
    1. o – name for WSDL file -> calculator.wsdl
    2. n – target namespace -> mx:com.itechgenie.services.Calculator
    3. l – url of web service -> http://<host:port>/<Project-Name>/services/calculator

    Summing up the above arguments the following command line arguments is created.

    String java2wsdlArgs[] = {"-ocalculator.wsdl", "-nmx:com.itechgenie.services.Calculator", "-v", "-lhttp://localhost:8080/axis/services/calculator", "com.itechgenie.services.Calculator"} ;

    Read this Article on how to run the command line java tools from Eclipse.
    You can run the Java2WSDL as follows in the TestRunner class. Naah, don’t ask how, just put the following lines the main method and press CTRL + F11.

    try {
    	Java2WSDL.main(java2wsdlArgs) ;
    } catch (Exception e) {
    	e.printStackTrace() ;
    }

    The Java2WSDL class has the System.exit(0); method called from inside. So lines after the Java2WSDL will not be executed. To get the other arguments supported you can just run Java2WSDL.main(new String[0]) ;. This will display all the arguments supported by Java2WSDL Utility and this works for other utilities also.
    After running this Utility you will find the calculator.wsdl file created in the root folder of the Project.

  4. Generate Server side and Client side codes using WSDL2Java: WSDL2Java is another tools provided by the AXIS, which can generate server side and client side Java classes using a WSDL file. These classes are needed for deploying the web service and also for accessing the web service using a Java client. This tool expects the following argument which includes the WSDL file generated in the last step.
    1. o – output folder -> src
    2. p – package for generated classes -> mx:com.itechgenie.services. generated
    3. s – generate server side classes as well
    4. *.wsdl – WSDL file of any web service

    Summing up the above arguments the following command line arguments is created.

    String wsdl2javaArgs[] = {"-osrc", "-pcom.itechgenie.generated.service", "-s", "calculator.wsdl", "-v"} ;

    Read this Article on how to run the command line java tools from Eclipse.
    Now run the WSDL2Java utility as follows.

    try {
    	WSDL2Java.main(wsdl2javaArgs) ;
    } catch (Exception e) {
    	e.printStackTrace() ;
    }

    Once the above command is run, Just refresh the project in eclipse, you will find the following files created inside the “com.itechgenie.generated.service” package.

    1. Calculator.java
    2. CalculatorService.java
    3. CalculatorServiceLocator.java
    4. CalculatorSoapBindingImpl.java
    5. CalculatorSoapBindingStub.java
    6. deploy.wsdd
    7. undeploy.wsdd

    The above files can be used in both Server and Clients side as Skeleton (CalculatorSoapBindingImpl.java) and the Stub (CalculatorSoapBindingStub.java) respectively.

  5. Binding the business logic with the Skeleton: Take the Skeleton file and you will find the exact methods that were available in our Business logic class (Calculator.java.).
    Create a instance of the Business class and invoke the appropriate method from the skeleton as follows (Find the lines highlighted in yellow.).

    package com.itechgenie.generated.service;
    
    import com.itechgenie.services.Calculator;
    
    public class CalculatorSoapBindingImpl implements com.itechgenie.generated.service.Calculator{
    
    	Calculator calculatorImpl = new Calculator() ;
    
        public int add(int in0, int in1) throws java.rmi.RemoteException {
        	return calculatorImpl.add(in0, in1) ;
        }
    
        public int subtract(int in0, int in1) throws java.rmi.RemoteException {
        	return calculatorImpl.subtract(in0, in1) ;
        }
    
        public int divide(int in0, int in1) throws java.rmi.RemoteException {
        	return calculatorImpl.divide(in0, in1) ;
        }
    
        public int multiply(int in0, int in1) throws java.rmi.RemoteException {
        	return calculatorImpl.multiply(in0, in1) ;
        }
    
    }

    That’s it; we are now done with the development part of the Web Service. All we have to do is to configure to make the service up and running.

  6. Last configurations to make our service available: Open the server-config.wsdd file inside the WEB-INF folder. You will find the following lines.
      <!--  Your Service from the deploy.wsdd file - Starts here -->
    
      <!--  Your Service from the deploy.wsdd file - Ends here -->

    Keep the file aside and open the deploy.wsdd from the WSDL2Java generated files. Copy the <service> … </service> tag completely and paste in between the comments said above.

  7. Conclusion: You can follow the steps 6 to 11 and create as many services as you want and paste them in the server-config.wsdd.
    With this the configurations for the Web Service is over. Export the Project as a War and deploy it in Web Server and point to the URL http://<host:port>/<Project-Name>/services
  8. This URL should display all the services generated from steps 6 to 11 with the links the WSDL files for the above.

    Click here to download the sample project.

Create Web Services using Axis Java2WSDL, WSDL2Java and Eclipse for all Servers manually – Part 1

There a lot of Web Service implementations available in market. The most widely used among them is the Axis way of implementation. There are a lot of Examples available in the web to create expose, consume the Web services using the Axis packages. But it is not feasible to work get the Axis complete packages inside corporate offices all of a sudden and yes I faced the same situation.

After some investment of time I found some funky stuff in web to create a Web Service with just a couple of jars in hand and off-course with the help of Eclipse.

Prerequisites:

  1. Eclipse, any version should be ok, but I was using the Eclipse Indigo with Ant installed in it.
  2. The set of jars needed. Jars are included in the Project sample.
    1. axis.jar
    2. commons-discovery-0.2.jar
    3. commons-logging.jar
    4. jaxrpc.jar
    5. log4j-1.2.15.jar
    6. saaj.jar
    7. wsdl4j.jar
    8. The sample web.xml, server-config.wsdd (These will be used later in the development steps).

Steps to develop Web Services:

  1. Create a Dynamic Web Project “SampleWebService” in Eclipse.
  2. Place the above said jars in the WEB-INF/jars folder.
  3. Open the Web.xml file and copy the following contents into it somewhere between tags. These contents are available in the sample attached.
      <servlet>
        <display-name>Apache-Axis Servlet</display-name>
        <servlet-name>AxisServlet</servlet-name>
        <servlet-class>org.apache.axis.transport.http.AxisServlet</servlet-class>
      </servlet>
      <servlet-mapping>
        <servlet-name>AxisServlet</servlet-name>
        <url-pattern>/servlet/AxisServlet</url-pattern>
      </servlet-mapping>
      <servlet-mapping>
        <servlet-name>AxisServlet</servlet-name>
        <url-pattern>*.jws</url-pattern>
      </servlet-mapping>
      <servlet-mapping>
        <servlet-name>AxisServlet</servlet-name>
        <url-pattern>/services/*</url-pattern>
      </servlet-mapping>
      <servlet>
        <display-name>Axis Admin Servlet</display-name>
        <servlet-name>AdminServlet</servlet-name>
        <servlet-class>org.apache.axis.transport.http.AdminServlet</servlet-class>
        <load-on-startup>100</load-on-startup>
      </servlet>
      <servlet-mapping>
        <servlet-name>AdminServlet</servlet-name>
        <url-pattern>/servlet/AdminServlet</url-pattern>
      </servlet-mapping>
  4. Copy the server-config.wsdd next to web.xml file. We will reuse this file once again after complete the business logic of the server.
  5. Now the basic configurations are complete, we have to develop the business logic for the Web Service. In my example I have taken the Old school Calculator sample.
    Click here to go to the next Part of this article.

Simple methods to Create, Read and Delete Cookies using JavaScript

Usage:

1. createCookie(name,value,days) – Void function.

name – Name for the cookie to be created
value – Value of the cookie
days(INT – Non Madatory) – Number of days to keep the cookie in browser. If not specified the cookie will expire as soon as soon the browser is closed.

2. readCookie(name) – Returns the value of the cookie.

name – Name given at the time of creation

3. eraseCookie(name) – Void function.

Dependency – createCookie method should be in place.

function createCookie(name,value,days) {
if (days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else var expires = "";
document.cookie = name+"="+value+expires+"; path=/";
}
function readCookie(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i &lt; ca.length;i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0)
return c.substring(nameEQ.length,c.length);
}
return null;
}
function eraseCookie(name) {
createCookie(name,"",-1);
}

Printing Complex Layouts in Adobe Flex – FlexPrintJob

I have come across a basic need for printing a complex layout in the Adobe Flex. After a long search i thought the following will be helpful to all if shared.

Requirements:

1. My layout has the following. Header (Fixed, to be shown in all page.), First Page Header (Displayed only in single page), DataGrid with data rolling out to more than one page, Fixed footer following the DataGrid and a Footer that come only in last page of the Printed output.
2. I am given only the outer most component object and list of all ids of the following components.
3. No server side support is available.

Problems:

1. My DataGrid is not accessible directly.
2. Complex layout and needed Paginationrn3. Fixed, floating header and footers.

Solution:

With reference to the Adobe Live docs, the solutions is almost near except to the complex structure.
rnI have created a Template that holds all the data to be iterated in the report. I contains the sections like Fixed Header, Floating Header, DataGrid, Fixed Footer, Floating Footer as follows.

1. PrintTemplate.mxml

<s:VGroup id="allPageHeader" width="100%" />
< s:VGroup id="firstPageHeader" width="100%" />
< mx:PrintDataGrid id="printDataGrid" width="100%" />
< s:VGroup id="allPageFooter" width="100%" />
< s:VGroup id="lastPagefooter" width="100%" />

2. PrintSample.mxml

protected function doPrint(outerGroup:DisplayObjectContainer, fixedHeaderIDs:ArrayCollection, floatHeaderIDs:ArrayCollection, dataGridId:String, floatFooterIDs:ArrayCollection , fixedFooterIDs:ArrayCollection):void{...}

Here we have to pass the list of IDs of the sections as we need to the doPrint method as follows.

doPrint(outerGroup, fixedHeaderIDs, floatHeaderIDs, dataGridId, fixedFooterIDs, floatFooterIDs);Completing the rendering the print object will be sent to printer and a popup will be shown.

Source Code: Printing in Adobe Flex

Update:

In the above example, if the Printout is taken with the printAsBitmap set to false, then there will be thick line under the header of the DataGrid ie, the PrintDataGrid. To solve this problem you have to use a Header Renderer and set a background color or Image for the header as follows.

<?xml version="1.0" encoding="utf-8"?>
< s:SparkSkin xmlns:fx="http:/s.adobe.com/mxml/2009" xmlns:s="library:/s.adobe.com/flex/spark" xmlns:mx="library:/s.adobe.com/flex/mx" > < s:Rect left="0" right="0" top="0"> < s:fill> < s:BitmapFill source="@Embed(''header.png'')"/> 
< /s:fill> < s:stroke> < s:SolidColorStroke color="grey" /> 
< /s:stroke> < /s:Rect>< /s:SparkSkin>

Save the file as SampleSkin and add this skin to the headerBackroundSkin property of PrintDataGrid in the PrintTemplate as follows.

<mx:PrintDataGrid id="printDataGrid" width="100%" headerBackgroundSkin="SampleSkin" />

This will resolve the issue and set a neat header to the DataGrid in the print.

God Mode in Windows 7

It may be hyperbolically named, but Windows 7’s God Mode is indeed
omnipresent. It conveniently puts hundreds of settings from all around
the operating system all in one place.
To turn on God Mode, create a new folder on your desktop, or anywhere
you’d like, and name it: GodMode.{ED7BA470-8E54-465E-825C-99712043E01C}.
Don’t include the final period. The resulting folder will contain 270
items, representing virtually every configurable option in Windows 7.

Regards,
Admin

Run multiple instances of messengers – Gtalk, Skype, Yahoo

Here are the ways that may help you use the messengers to login in more than one account.

For Gtalk :

1. Create  a shortcut for the Gtalk in the desktop and an extra arugument “/nomutex” in the ‘Target’ text box.

2. Now use the shortcut and run multiple instances of Gtalk as you like.

For Skype  :

1. You can do this in two ways for Skype. Create a shortcut for the skype in the desktop and add an extra argument “/secondary” in the ”Target’ , save the shortcut and run instances.

2. Skype can run an instance for every individual users. So create two or more users and use the following commmand from the shell to run instances. ‘ runas /user:XXX “C:Program FilesSkypeSkype.exe” ‘, where XXX is the username in your pc.

3. The above said way can also be done by right-clicking the shortcut and selecting the “Run As” command from the context menu.

For Yahoo :

1. Open the regedit ( Start -> Run -> regedit ), traverse to “HKEY_CURRENT_USERSoftwareyahoopagerTest”.

2. Create a DWORD registry value named “Plural” by right clicking the right hand side window.

3. Double click the new DWORD entry and set the value to 1.

Thats it. Run multiple instances of your favourite messengers and have fun. 😉