woensdag 24 november 2010

OpenFiler iSCSI target

OpenFiler
 (downloaded Virtual Appliance from openfiler.com)

Configure your virtual machine with storage to be used
for clients that will be provided with storage.
I find it usefull not to make the storage on the root
disk of the Virtual Machine but to add a different disk
to the VM where we put the storage on.

Edit Settings
  Add ..
   HardDisk
Create new Virtual Disk

Start Virtual Machine

If the Virtual Machine has started it will have port 446 available
for you to connect to :

http://192.168.2.9:446

Login: openfiler
Password: password

Goto TAB : Volumes

On the right hand side you will find menu option: Block Device

Check to find if the added disk is present (propably /dev/sdb)

Under Edit Disk there are links to the disks. Click on /dev/sdb
to create a partition.

Next click on menu (right hand side) Volume Group

Create a Volume Name on the Volume Group: volumegroupy
Add Volume menu action
Create a volume in ‘volumegroupy
  Volume Name:      volumenamy
  Space:                 16384
  FileSystem:           iSCSI

We now have a volume to be used with iSCSI:



Enable iSCSI from the SERVICES tab

Next make sure we listen to a network:

System Tab
Network Access Configuration
'completenetwork' 192.168.2.0/255.255.255.0 share

Now we can create a volume for the iscsi target to use
iSCSI Targets menu
Now MAP the volume name you created to the iSCSI target in the LUN Mapping TAB.


Make sure the network is configured

iSCSI Targets
Network ACL TAB
Allow Access
update




RAID 5 array

For a RAID 5 containing multiple RAW Devices use these
steps:

Volumes
 Block Devices
  *Edit Disk*
   Mode: Primary
   Type: Raid Array Member
   [create]
Repeat for all disks
These Raid Member disks should be combined into a RAID 5 array
Software RAID
  Create Array whith at least 3 raid-members checked to creat a RAID5 array
  Select RAID array type: RAID 5 (parity)
  [Add Array]
Now make a Volume Group on this array.
Volume group name: volumegroupy
Selct /dev/md0 (raid5) [add volume group]


dinsdag 23 november 2010

Storage Foundation Installation

Download the free basic version from symantec.com :
search :
download storage foundation basic
which gives you the freeware version of the storage solution.

Version: 4.1.02.0
This version works with CentOS 4.8 (5.4 is too new !)
(Download from centos.org)

I used vmware player 3.0 to make a virtual machine with centos 4.8

Copy the tar.gz with storage foundation and unpack using
gzip -d sf*basic*
tar xvf sf*basic*

cd rhel*
cd sf*basic*
cd storage*


installsf
Answer the questions
Host : 127.0.0.1
or give the name of the system.

You can ignore the SSH connection when installing to the
same host.

Once installed you propably want to have some shared storage
available to the system.

For this I use OpenFiler virtual machine that has iSCSI target
in it. [See : OpenFiler iSCSI Target]

To access the iSCSI target using an iscsi initiator we download the utils:

yum install iscsi-initator-utils

vi /etc/initiatorname.iscsi
InitiatorName=iqn.myLinuxInitiator.here
# or change to your own prefered name
vi /etc/iscsi.conf
DiscoveryAddress=192.168.2.9
# 192.168.2.9 is my OpenFiler environment

/etc/init.d/iscsi restart



You now can use storage foundation commands.
If you want to use Veritas Enterprise Administrator you
should either have a X-Windows environment in the Virtual
Machine or you can use another computer to display the
gui.


Suppose your system 192.168.2.1 has X-Windows (mine has X-cygwin)
Login as root to 192.168.2.1 and use:
xhost +
(This allows use of the X-Windows environment to your vm)


On the centos machine use:


export DISPLAY=192.168.2.1:0
cd /opt/VRTS/bin
./vea


To restart VEA services on machine:
/opt/VRTS/bin/vxsvcctrl restart


zaterdag 30 oktober 2010

Calling Java from Javascript and calling Javascript from Java




This little sample shows that we can call javascript doAlert from Java.
Also we show that calling the function display will be received in Java with
data from Javascript.


applet.java


import java.applet.*;
import java.net.*;


public class applet extends Applet{
public void init(){
Display("start of java");
}
public void Display(String txt){
try{
getAppletContext().showDocument(new URL("javascript:doAlert(\""+txt+"\")"));
}catch(Exception e){}
}
}

index.html



<HTML>
<SCRIPT>
function doAlert(s) {
   alert(s);
}
</SCRIPT>
<APPLET CODE="applet.class" NAME="applet"  MAYSCRIPT >
</APPLET>
<INPUT type="button" value="Java.Display" onClick="document.applet.Display('hi')">
</HTML>

zondag 24 oktober 2010

Ultimate Deployment Appliance 2.0 install and setup

Ultimate Deployment Appliance or UDA is an installation environment
with which you can install (virtual) machines for a range of operating
systems.

Download UDA 2.0 from http://www.ultimatedeployment.org/

In my case I used VMware Player 3.0.1 to run it on my local computer.
The appliance has all the stuff in it, but I used an NFS server to hold
the storage for the ISOs

Install Steps:

Fixed IP address: 192.168.2.19
DHCP  + PXE checked for the client installations
root password: password

The Web Login (http://192.168.2.19) is admin with password : password

Storage - New Storage
  NFS     192.168.2.250
  /Volumes/SAMSUNG/    <- 1.5 Terra Byte USB disk
Mount

You need to put ISOs for the Operating Systems you want to install
on the NFS storage in order for UDA to
use them. These ISOs do not have to be bootable.
In one case I had a network directory which hold all the data
from the DVD.
I created an ISO from it using CDBurner XP (dragging the files to the
profile and used File - compile iso )

Once you have the ISOs in place go to the OS menu

OS
Give a name to the OS (max 8 character)
Select type of install (Linux, Windows ..)
Type in the path of the ISO on the NFS server

For the client to get a menu of operating systems to
choose for there must be templates.

In my case I used a virtual machine to install Windows XP on.
VMware Player started and selected 'Create new Virtual Machine'
Name the VM and Select No DVD or Image to install from
When the Virtual Machine starts Press F12
The machine will now do a PXE boot and if your UDA is the
only one who gives out DHCP addresses it will react on this
installation request.
In case you have a network environment where there is another
DHCP server you have to isolate your environment from it.
In case of using Virtual Machines just unplug your network cable.
With Physical Machines you propably have to use a switch or hub.
In some cases it could work just fine because the first DHCP
server who responses is the one that will be used. But keep
in mind that it is not wise to have this kind of setup active
long so that other clients who rely on the other (corporate) DHCP server
are not effected!

Write down the MAC address of your client. It is the address that
is shown when it is looking for a DHCP server

Template
 Name: MyComp
 MAC: 00-0C-29-xx-xx-xx  (VMware Player MAC address)
 OS: winxp
Finish

Press F12 again on the client and it should be presented with a menu
to choose the Operating System.

The standard setup program should start. Basically that is all you need
to do.

Changing TEMPLATEs

Default passwords and other setup configuration that the template makes
can be found in this location on the machine that runs UDA.

Login as root to UDA (password in my case is password)
cd /var/public/www/templates
Here you can find the default templates that your templates rely on.
vi [templatefile]
The password can be found in section:
[GuiUnattended]
AdminPassword
From WI2K3 into ...

Manually mount ISO on UDA

In case you want to have another ISO mounted on the server
to access it from the client you can do this:

(login as root to UDA)
Make mount point:
mkdir /var/public/tftproot/windows5/myown
Mount the ISO
mount -o loop /var/public/smbmount/[samsung]/myown.iso /var/public/tftproot/windows5/myown

Now this can be used inside the Operating System (Windows for instance:)
net use k: \\192.168.2.19\reminst\windows5\myown /user:guest ""

zaterdag 23 oktober 2010

JGame : Dynamically change contents of the background

For my project I wanted to put something on the background which should
not be a sprite and using getBufferGraphics() the image would appear on top
of other sprites. 
In fact I wanted to change a predefined Image from the engine.


The following steps were made to make this happen. Maybe there
is a better method, but this worked for me..



Modify

edit : src-jre\jgame\platform\JREImage.java

public class  JREImage

instead of class JREImage

and make both of the constructor public as well:

public JREImage(....
public JREImage()

===================================

edit src-base\jgame\JGImage.java
On the top :

package ..
import java.awt.*;
(add to the bottom .. before last } <= which is from the class)
public Image getImage();
public void setImage(Image img);


======================================

Edit src-jre\jgame\platform\JREImage.java
(add to the bottom .. before last } <= which is from the class)

public Image getImage(){
return this.img;
}


public void setImage(Image img){
this.img=img;
}


======================================

Edit src-jre\jgame\platform\JGEngine.java

Add this before another defined defineImage function ..


public void defineImage(String imgname,  
JGImage jig){
el.defineImage(imgname,jig);
}




Edit src-base\jgame\impl\EngineLogic.java

Add this before another defineImage function ..

// replace definedImage with new image
public void defineImage(String name, JGImage img){
String imgfile=name;


if (images_loaded.containsKey(name)) {
imgfile=(String)images_loaded.get(name);
undefineImage(name);
}
defineImage(name,"p", 0, img,"-",0,0,0,0);
if(imgfile.length() <1)imgfile=name;
images_loaded.put(name,imgfile);


}





===

Some sample code (modify for example the other JGame code and put the action after a keypress)

public Image readImage(String imagestring){
                String inputLine;
Image retval=null;
                try{


                   URL Url = new URL(getCodeBase().toString()+imagestring);
   retval = ImageIO.read(Url);
                }catch(Exception readfile){
//System.out.println("Read File exception: "+readfile.toString());
}
return retval;


}


// Image load
Image a=readImage(theimage);


// This retrieves JGImage from the background defined image
JGImage bgimg=getImage("background");


// Our own routine to create an Image object from it
java.awt.Image img=bgimg.getImage();


// Make an image to draw stuff on
GraphicsEnvironment ge =
GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice gs = ge.getDefaultScreenDevice();
GraphicsConfiguration gc = gs.getDefaultConfiguration();
// always use bitmask transparency

BufferedImage buf = gc.createCompatibleImage(img.getWidth(this),img.getHeight(this),Transparency.BITMASK);
Graphics gg=buf.getGraphics();
gg.drawImage(img,0,0,this);






// on top of background draw our own thing
gg.drawImage(a, imagex, imagey, this);


setBGImage("background");


// Make our own JREImage
JREImage je=new JREImage((Image)buf);
// Call our own routine to replace the defined image with the composed image
defineImage("background",(JGImage)je);

// Set the new background
setBGImage("background");



==================================================================



To recompile the jar file:

make-base

Copy the JAR file to your project directory..

dinsdag 19 oktober 2010

Dynamic HTML page using PHP and DOM

For a project I wanted to make a property system that
could connect to MySQL to retrieve and set properties
which would be entered on a HTML page.

Interaction between form elements and php scripts that
eventually would connect to a database to get and set
all the data.

Mouse coordinates are shown on the board, but the next
step which would involve setting the property isn't
implemented.




frames.php

<?php


echo <<<HTML


<iframe name="editor" id="editor" scrolling="auto" width=800 height=600 
src="edit.php?cmd=board" style = "position:absolute;left:1px;top:1px">
</iframe>


<iframe name="properties" id="properties" scrolling="auto"  marginheight="14" 
src="edit.php?cmd=properties" style = "position:relative;left:800px;top:1px;">
</iframe>


<iframe name="data" id="data" scrolling="auto"  src="edit.php?cmd=data"
 style = "position:relative;left:900px;top:1px;">
</iframe>


HTML;
?>


board.php



<?php


echo <<<HTML
<head>
<link rel="stylesheet" href="css/mycss.css">
</head>
<form name="Show">
<div class="game_area" width=800px height=600px>
</div>
</form>
<script>
var IE = document.all?true:false;
if (!IE){
         document.captureEvents(Event.MOUSEMOVE)
         document.captureEvents(Event.MOUSECLICK)
}
document.onmousemove = getMouseXY;
document.onmousedown = getMouseClick;
var tempX = 0;
var tempY = 0;
function getMouseXY(e) {
        if (IE) {
                tempX = event.clientX + document.body.scrollLeft;
                tempY = event.clientY + document.body.scrollTop;
        }
        else {
                tempX = e.pageX;
                tempY = e.pageY;
        }
        if (tempX < 0){tempX = 0;}
        if (tempY < 0){tempY = 0;}
if(IE){
parent.document.getElementById('properties').contentWindow.document.getElementById('x').value=tempX;
parent.document.getElementById('properties').contentWindow.document.getElementById('y').value=tempY;
}else{
parent.document.getElementById('properties').contentDocument.getElementById('x').value=tempX;
parent.document.getElementById('properties').contentDocument.getElementById('y').value=tempY;
}
return true;
}
function getMouseClick(e){
        if (IE) {
                if(event.button > 0)
parent.document.getElementById('properties').contentWindow.document.getElementById('button').value=event.button;
        }else{
                if(event.which > 0)
parent.document.getElementById('properties').contentDocument.getElementById('button').value=event.which;
        }
return true;
}
</script>
HTML;


?>



mycss.css


.game_area {
        background-color: #08000d;
        width: 800px;
        height: 600px;


}









properties.php

The database button COULD run a PHP script that uses a MySQL database.
<?php
        echo <<<HTML
        <FORM name=properties>
                X <input type=text id="x" name="x"><br>
                Y <input type=text id="y" name="y"><br>
                B <input type=text id="button"name="button"><br>
                <input value="database" type=button 
onclick="javascript:parent.document.getElementById('data').src='edit.php?cmd=data';"><br>
        </FORM>
HTML;
?>


data.php

But we do not connect to a database for this demonstration. We just retrieve
the x coordinate and show it.

<?php
        echo <<<HTML


        <script>
                function onload(){
                        var IE = document.all?true:false;
HTML;




        echo "if (!IE){";
                // chrome:
                echo "alert(' Not Internet Explorer '+parent.document.getElementById('properties').
contentDocument.getElementById('x').value+'');";
        echo "}else{";
                // IE
                echo "alert(' Internet Explorer  '+parent.document.getElementById('properties').
contentWindow.document.getElementById('x').value+'');";
        echo "}";


        // Complete function
        echo <<<HTML
                        return true;
                }
        </script>
        <body onload='onload();'>
        </body>
HTML;


?>