Wednesday 14 August 2013

Exalogic Virtual Tea Break Snippets – Creating Assets with the Simplified Exalogic Cli (A SimpleExaCli.sh Tutorial)

In a previous blog entry I described a script for creating assets (Distribution Groups, vServers, etc) but since that initial script I have written and blogged about the Simple Exalogic Cli Script and therefore have decided to write this short tutorial on the "--create-asset" command option. This version is expanded from it's original release last September so I will run through all the features available within this command.

Command Options

--create-assets

Parameters
  • Required
    • -f <Asset Definition File>
  • Optional
    • -remove-ssh-key
Reads the specified Asset file and creates all the assets defined within it. If multiple projects are defined these are worked through. The file is processed sequentially and therefore must contain action in an appropriate sequence. Within the Asset file each line is a specific entry and has the following structure:
Account:Action|Asset Type|Parameters
Action Asset Type Parameters
Connect
  1. Username
  2. Password
Upload ServerTemplate
  1. Template Name
  2. URL to the template location.
Create VirtualNetwork
  1. Network Name
  2. Size
Create DistributionGroup
  1. Distribution Group Name
When creating Distribution Groups from the command line they will have a size of 50,000.
Create vServer
  1. vServer Name
  2. vServer Type Name
  3. Template Name
  4. Comma separated list of network names which the vServer will connect to.
  5. Comma separated list of IPs for the specified networks. If the IP is to be assigned automatically the a "*" should be entered.
  6. Distribution Group [Optional]
  7. Description [Optional]
  8. Post Creation Script [Optional]
Create Volume
  1. Volume Name
  2. Volume Size
Attach Volume
  1. vServer Name
  2. Comma separated list of volume names
Disconnect

Scenario

For this Tuttorial we will using the following scenario:

  • Account : SimplesTutorial
  • User : tutorialuser
  • vServer Type : SMALL & LARGE
We have a currently created account (account creation is a Cloud Admin function and can not be scripted with the cli) call SimplesTutorial within which we want to create 3 vServers based on a new template, we have previously created, (el_template_vsResizeTutorial) which we also need to import into the account. In addition the 3 vServers we will create need to run on separate physical nodes and hence to facilitate this we will create a distribution group (dgAssetTutorial)and place each of the within it.

The vServers will not be exact clones of each other but rather we will create 2 SMALL vServers and 1 LARGE vServer. The 2 smaller vServers will be required to access a specific share one the ZFS and hence we will need to run a post creation script to configure the appropriate mount point which the single LARGE vServer will require an additional 20 GB of Volume storage.

Finally all vServers must communicate of a private net work that is specific to them and the account.

Script to be Injected

#!/bin/bash
cp /etc/hosts ~
cp /etc/resolv.conf ~
cp /etc/fstab ~
mkdir -p /u01/common/images
echo "172.17.0.9:/export/common/images /u01/common/images nfs rsize=32768,wsize=32768,rw,intr,bg,hard,timeo=600,nfsvers=3,tcp,nolock,acregmin=0,acregmax=0" >> /etc/fstab
mount -a

mount

Logical Steps

If we were to create the Assets described above using the EMOC BUI then we would likely follow the following sequence:

  1. Import the Template.
  2. Create local Virtual Network
  3. Create Distribution Group
  4. Create Volume
  5. Create vServers / add Volumes.
Using the scripted method we essentially need to follow the same sequence but when using creating vServers with Volumes this is done as a 2 step approach. First we create the vServer then we add the volume to the vServer.

Within the Asset.in file the order of the lines defines the sequence in which the Assets will get created  / processed therefore to fullfil our required order we would create the following Asset.in input file.

SimplesTutorialAsset.in

SimplesTutorial:Connect|tutorialuser|welcome1|
SimplesTutorial:Upload|ServerTemplate|AssetTutorialTemplate|http://192.168.21.9/shares/export/common/images/vServerTemplates/el_template_vsResizeTutorial.tgz|
SimplesTutorial:Create|VirtualNetwork|vnAssetTutorial|14|
SimplesTutorial:Create|DistributionGroup|dgAssetTutorial|
SimplesTutorial:Create|Volume|volTutorialLarge|20|
SimplesTutorial:Create|vServer|vsTutorialLarge|LARGE|AssetTutorialTemplate|EoIB-network1-vlan112-10.242.96.0/21,IPoIB-vserver-shared-storage,vnAssetTutorial|*,*,*|dgAssetTutorial|VServer Asset Creation||
SimplesTutorial:Create|vServer|vsTutorialSmall1|SMALL|AssetTutorialTemplate|EoIB-network1-vlan112-10.242.96.0/21,IPoIB-vserver-shared-storage,vnAssetTutorial|*,*,*|dgAssetTutorial|VServer Asset Creation|TutorialMount.sh|
SimplesTutorial:Create|vServer|vsTutorialSmall2|SMALL|AssetTutorialTemplate|EoIB-network1-vlan112-10.242.96.0/21,IPoIB-vserver-shared-storage,vnAssetTutorial|*,*,*|dgAssetTutorial|VServer Asset Creation|TutorialMount.sh|
SimplesTutorial:Attach|Volume|vsTutorialLarge|volTutorialLarge|
SimplesTutorial:Disconnect|
We can see from the file that the first command to execute will be the Connect this causes the Script to connect to EMOC through the cli and is equivalent to logging in. The User specified must be a valid Cloud User with access to the account.

Once connected we will upload the template into the account and then create a simple Virtual Network followed by a Distribution Group. Once these have been successfully created we can then move onto the creation of the vServers.

It can be seen that we will first create the 2 SMALL (the vCPU / RAM / Disk is defined by the SMALL VServer Type) using the previously uploaded template and attaching them to 3 networks (External EoIB, storage & net Private VNet). Because we do not require specific IP addresses on these vServers we have specified "*" for the IP Address and this will cause the script to simple grab an available IP from the Auto Allocation pool. Finally once the vServers have been created and started the script will run the defined "TutorialMount.sh" script (above) to mount a shared location on the ZFS.

In addition to this we will create a LARGE vServer and then once it is running simply create a Volume and then attach it to the running vServer. Finally disconnecting when complete.

Example Run

To the assets we will execute the following:

./SimpleExaCli.sh --create-assets -f SimplesTutorialAsset.in -remove-ssh-key > SimplesTutorialAsset.in.log
Tailing the log file we will be able to follow the creation process below. In addition if we log into EMOC we will be able to see the Jobs as they are created and executed.

JAVA_HOME is not defined using /usr/java/latest

About to Execute : /opt/oracle/iaas/cli/bin/iaas-create-server-template-from-url --name AssetTutorialTemplate --url http://192.168.21.9/shares/export/common/images/vServerTemplates/el_template_vsResizeTutorial.tgz
Pausing until Template upload has completed
AssetTutorialTemplate SCHEDULED
Sleeping.......
AssetTutorialTemplate SCHEDULED
Sleeping.......
AssetTutorialTemplate SCHEDULED
Sleeping.......
AssetTutorialTemplate SCHEDULED
Sleeping.......
AssetTutorialTemplate SCHEDULED
Sleeping.......
AssetTutorialTemplate SCHEDULED
Sleeping.......
AssetTutorialTemplate SCHEDULED
Sleeping.......
AssetTutorialTemplate OK
About to Execute : /opt/oracle/iaas/cli/bin/iaas-create-vnet --name vnAssetTutorial --size 14
Pausing until Virtual Network creation has completed
vnAssetTutorial SCHEDULED
Sleeping.......
About to Execute : /opt/oracle/iaas/cli/bin/iaas-create-distribution-group --name dgAssetTutorial
About to Execute : /opt/oracle/iaas/cli/bin/iaas-create-volume --name volTutorialLarge --size 20
Creating vServer vsTutorialLarge
About to Execute : /opt/oracle/iaas/cli/bin/iaas-run-vserver --name vsTutorialLarge --key-name SimplesTutorial.20130814-0814.19825.cli.asset.create --vserver-type 2007 --server-template-id TMPL-f9a69dee-ea6e-4397-bf28-3a92e531101f --vnets VNET-2544e1e2-7f9b-44ea-9696-d244c956563f,VNET-73452bf7-1341-4508-a49a-4536922d485b,VNET-1d748844-374a-453e-b1bd-18159a65a5d2 --ip-addresses 10.242.96.142,172.17.1.37,192.168.0.87 --dist-group DG-34e10ed2-4e22-4c73-82f6-f61f4a18418d --desc "VServer Asset Creation"
Pausing until vServer is Running
vsTutorialLarge SCHEDULED
Sleeping.......
vsTutorialLarge SCHEDULED
Sleeping.......
vsTutorialLarge SCHEDULED
Sleeping.......
vsTutorialLarge SCHEDULED
Sleeping.......
vsTutorialLarge SCHEDULED
Sleeping.......
vsTutorialLarge SCHEDULED
Sleeping.......
vsTutorialLarge SCHEDULED
Sleeping.......
vsTutorialLarge SCHEDULED
Sleeping.......
vsTutorialLarge SCHEDULED
Sleeping.......
vsTutorialLarge RUNNING
Just Waiting 45 Seconds......
10.242.96.142 Address works for ssh to vsTutorialLarge
10.242.96.142 Address works for ssh to vsTutorialLarge

Removing ssh key requirement for vsTutorialLarge on 10.242.96.142
Stopping sshd: [ OK ]
Starting sshd: [ OK ]
Removed ssh key requirement for vsTutorialLarge
vServer vsTutorialLarge has been created
Creating vServer vsTutorialSmall1
About to Execute : /opt/oracle/iaas/cli/bin/iaas-run-vserver --name vsTutorialSmall1 --key-name SimplesTutorial.20130814-0814.19825.cli.asset.create --vserver-type 2006 --server-template-id TMPL-f9a69dee-ea6e-4397-bf28-3a92e531101f --vnets VNET-2544e1e2-7f9b-44ea-9696-d244c956563f,VNET-73452bf7-1341-4508-a49a-4536922d485b,VNET-1d748844-374a-453e-b1bd-18159a65a5d2 --ip-addresses 10.242.96.145,172.17.1.36,192.168.0.88 --dist-group DG-34e10ed2-4e22-4c73-82f6-f61f4a18418d --desc "VServer Asset Creation"
Pausing until vServer is Running
vsTutorialSmall1 SCHEDULED
Sleeping.......
vsTutorialSmall1 SCHEDULED
Sleeping.......
vsTutorialSmall1 SCHEDULED
Sleeping.......
vsTutorialSmall1 SCHEDULED
Sleeping.......
vsTutorialSmall1 SCHEDULED
Sleeping.......
vsTutorialSmall1 SCHEDULED
Sleeping.......
vsTutorialSmall1 SCHEDULED
Sleeping.......
vsTutorialSmall1 SCHEDULED
Sleeping.......
vsTutorialSmall1 SCHEDULED
Sleeping.......
vsTutorialSmall1 RUNNING
Just Waiting 45 Seconds......
10.242.96.145 Address works for ssh to vsTutorialSmall1
10.242.96.145 Address works for ssh to vsTutorialSmall1

Executing TutorialMount.sh on vsTutorialSmall1 on 10.242.96.145
/dev/xvda2 on / type ext3 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
/dev/xvda1 on /boot type ext3 (rw)
tmpfs on /dev/shm type tmpfs (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)

Removing ssh key requirement for vsTutorialSmall1 on 10.242.96.145
Stopping sshd: [ OK ]
Starting sshd: [ OK ]
Removed ssh key requirement for vsTutorialSmall1
vServer vsTutorialSmall1 has been created
Creating vServer vsTutorialSmall2
About to Execute : /opt/oracle/iaas/cli/bin/iaas-run-vserver --name vsTutorialSmall2 --key-name SimplesTutorial.20130814-0814.19825.cli.asset.create --vserver-type 2006 --server-template-id TMPL-f9a69dee-ea6e-4397-bf28-3a92e531101f --vnets VNET-2544e1e2-7f9b-44ea-9696-d244c956563f,VNET-73452bf7-1341-4508-a49a-4536922d485b,VNET-1d748844-374a-453e-b1bd-18159a65a5d2 --ip-addresses 10.242.96.144,172.17.1.39,192.168.0.94 --dist-group DG-34e10ed2-4e22-4c73-82f6-f61f4a18418d --desc "VServer Asset Creation"
Pausing until vServer is Running
vsTutorialSmall2 SCHEDULED
Sleeping.......
vsTutorialSmall2 SCHEDULED
Sleeping.......
vsTutorialSmall2 SCHEDULED
Sleeping.......
vsTutorialSmall2 SCHEDULED
Sleeping.......
vsTutorialSmall2 SCHEDULED
Sleeping.......
vsTutorialSmall2 SCHEDULED
Sleeping.......
vsTutorialSmall2 SCHEDULED
Sleeping.......
vsTutorialSmall2 SCHEDULED
Sleeping.......
vsTutorialSmall2 RUNNING
Just Waiting 45 Seconds......
10.242.96.144 Address works for ssh to vsTutorialSmall2

Executing TutorialMount.sh on vsTutorialSmall2 on 10.242.96.144
/dev/xvda2 on / type ext3 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
/dev/xvda1 on /boot type ext3 (rw)
tmpfs on /dev/shm type tmpfs (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)

Removing ssh key requirement for vsTutorialSmall2 on 10.242.96.144
Stopping sshd: [ OK ]
Starting sshd: [ OK ]
Removed ssh key requirement for vsTutorialSmall2
vServer vsTutorialSmall2 has been created
About to Execute : /opt/oracle/iaas/cli/bin/iaas-attach-volumes-to-vserver --vserver-id VSRV-17cf3896-2e1c-47fd-9771-c804d986e52e --volume-ids VOL-10421d60-f800-4735-9672-36662d2360b9
Just Waiting 45 Seconds......

No comments:

Post a Comment