Having worked with the Exalogic Command Line for a while I
decided to wrap some of the common functions in a simplified bash
script. This saves me creating the keys, connecting and
identifying the appropriate Ids. Instead I can simply specify the
Name and the script will do the rest of the work. This initial
version has just a few commands in it but as I add more the blog
entry will expand, as will the script, and document the new
functionality.
Commands
All the Command below will work against the whole vDC unless they are restricted to an Account by using the -a option or a vServer by using the -v option. For all actions the script requires a User and password to be passed.--list-vservers
This command will work through all the Accounts on a given vDC and display the vServers that are available within that Account. Issuing the command in it's simplest form, below, will display the following:[root@ec1-vm ~]# ./SimplifiedCli.sh -u root -p password --list-vservers JAVA_HOME is not defined using /usr/java/latest GlobalResources|LB-2 GlobalResources|nis-vserver-s GlobalResources|JOI28GB GlobalResources|nis-vserver-m GlobalResources|dns GlobalResources|LB-1 Andrew|VS002 Andrew|VS003 UliAccount|test-vm UliAccount|sc-tvm UliAccount|uliAdmin UliAccount|otd-tvm UliAccount|nis-tvm UliAccount|wcdb-vm UliAccount|lvm-tvm UliAccount|sc-vm1 UliAccount|wc-vm1 UliAccount|sc-vm3 UliAccount|sc-vm2 UliAccount|wc-vm2 FAPoc|FA-DB FAPoc|FA-01 FAPoc|OTD01 FAPoc|FA-02 FAPoc|FA-IDM FAPoc|FA-03Users can also specify that a Verbose format be used (--verbose) which will print the full set of information available for the given vServers as below.
[root@ec1-vm ~]# ./SimplifiedCli.sh -u root -p password --list-vservers --verbose -a Andrew JAVA_HOME is not defined using /usr/java/latest Andrew|VS002|VSRV-616bdf32-2a92-44e4-a9ea-862d0b97c0bb|VS002|Created By CreateAsset.sh|RUNNING|VNET-52a60524-d7e6-4e3f-8204-8cf8bb798ddb,VNET-1b2402d7-9010-45db-a887-4b955377584d|10.242.96.72,172.17.0.40|TMPL-a06a1406-cf5a-479d-a3ea-7c8657bb4013|ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCrGYXTkLFoahLbmc4AfCCGqjfwERUubU+TyBk5jyMq46L0eqILhQuRKBRwGp1YbvlEbeFFgQkoR11wJCw7L5wZCNXE99dY1Iya7cst68TgajMlRAunlyD7owGC2ICvTsR3aqzdOtZ6xdXPB6OEYkTI+HLBAKAdZsPdQdb6oI3eKiNzX0FcJHFT68WNuOiaD0aALV1Ct81tkAkDpLNRlag9Pt|2006|true Andrew|VS003|VSRV-5ab971c4-1bad-4cee-8575-7e80a68ef0b3|VS003|Created By CreateAsset.sh|RUNNING|VNET-1b2402d7-9010-45db-a887-4b955377584d,VNET-52a60524-d7e6-4e3f-8204-8cf8bb798ddb|172.17.0.36,10.242.96.75|TMPL-a06a1406-cf5a-479d-a3ea-7c8657bb4013|ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCrGYXTkLFoahLbmc4AfCCGqjfwERUubU+TyBk5jyMq46L0eqILhQuRKBRwGp1YbvlEbeFFgQkoR11wJCw7L5wZCNXE99dY1Iya7cst68TgajMlRAunlyD7owGC2ICvTsR3aqzdOtZ6xdXPB6OEYkTI+HLBAKAdZsPdQdb6oI3eKiNzX0FcJHFT68WNuOiaD0aALV1Ct81tkAkDpLNRlag9Pt|2006|true
--status-vservers
Issuing the status command will cause the script to loop through the vServers within the vDC Accounts and simply display the current status of the vServer.[root@ec1-vm ~]# ./SimplifiedCli.sh -u root -p password --status-vservers JAVA_HOME is not defined using /usr/java/latest GlobalResources|LB-2|RUNNING GlobalResources|nis-vserver-s|RUNNING GlobalResources|JOI28GB|SHUTDOWN GlobalResources|nis-vserver-m|RUNNING GlobalResources|dns|RUNNING GlobalResources|LB-1|RUNNING Andrew|VS002|RUNNING Andrew|VS003|RUNNING UliAccount|test-vm|RUNNING UliAccount|sc-tvm|SHUTDOWNDETACHED UliAccount|uliAdmin|RUNNING UliAccount|otd-tvm|RUNNING UliAccount|nis-tvm|RUNNING UliAccount|wcdb-vm|RUNNING UliAccount|lvm-tvm|RUNNING UliAccount|sc-vm1|RUNNING UliAccount|wc-vm1|RUNNING UliAccount|sc-vm3|RUNNING UliAccount|sc-vm2|RUNNING UliAccount|wc-vm2|RUNNING FAPoc|FA-DB|RUNNING FAPoc|FA-01|SHUTDOWNDETACHED FAPoc|OTD01|SHUTDOWNDETACHED FAPoc|FA-02|SHUTDOWNDETACHED FAPoc|FA-IDM|RUNNING FAPoc|FA-03|SHUTDOWNDETACHED
--stop-vservers
The stop-vservers will use the cli to force a shutdown of the vservers. By default this will loop through all vServers in the vDC an stop them on an Account by Account basis.--start-vservers
The start-vservers will use the cli to force a shutdown of the vservers. By default this will loop through all vServers in the vDC an start them on an Account by Account basis.--list-distgroups
This command will work through all the Accounts on a given vDC and display the Distribution Groups that are available within that Account. Issuing the command in it's simplest form, below, will display the following:[root@ec1-vm ~]# ./SimplifiedCli.sh -u root -p password -url https://localhost --list-distgroups JAVA_HOME is not defined using /usr/java/latest GlobalResources|NIS-GROUP| Andrew|test| UliAccount|uliCA1|
--list-vnets
This command will work through all the Accounts on a given vDC and display the Networks that are available within that Account. Issuing the command in it's simplest form, below, will display the following:[root@ec1-vm ~]# ./SimplifiedCli.sh -u root -p password -url https://localhost --list-vnets JAVA_HOME is not defined using /usr/java/latest GlobalResources|EoIB1-client-access|10.242.96.0/21 GlobalResources|IPoIB-default|192.168.48.0/21 GlobalResources|IPoIB-vserver-shared-storage|172.17.0.0/16 Andrew|IPoIB-default|192.168.48.0/21 Andrew|EoIB1-client-access|10.242.96.0/21 Andrew|VN002|192.168.2.0/24 Andrew|VN003|192.168.4.0/24 Andrew|IPoIB-vserver-shared-storage|172.17.0.0/16 Andrew|VN004|192.168.5.0/24 Andrew|EoIB-external-mgmt|10.242.80.0/21 Andrew|VN001|192.168.3.0/24 UliAccount|EoIB1-client-access|10.242.96.0/21 UliAccount|wc-privat|192.168.0.32/28 UliAccount|EoIB-external-mgmt|10.242.80.0/21 UliAccount|IPoIB-vserver-shared-storage|172.17.0.0/16 UliAccount|IPoIB-default|192.168.48.0/21 FAPoc|IPoIB-priv-fa|192.168.0.0/28 FAPoc|IPoIB-vserver-shared-storage|172.17.0.0/16 FAPoc|EoIB1-client-access|10.242.96.0/21
--list-volumes
This command will work through all the Accounts on a given vDC and display the Volumes that are available within that Account. Issuing the command in it's simplest form, below, will display the following:[root@ec1-vm ~]# ./SimplifiedCli.sh -u root -p password -url https://localhost --list-volumes JAVA_HOME is not defined using /usr/java/latest Andrew|VOL666|6.0 UliAccount|resizedVolume|4.0 UliAccount|SPMSVol1|16.0 UliAccount|db-u01|20.0 UliAccount|lvmVol1|16.0 UliAccount|adminVolume|32.0
--list-templates
This command will work through all the Accounts on a given vDC and display the Templates that are available within that Account. Issuing the command in it's simplest form, below, will display the following:[root@ec1-vm ~]# ./SimplifiedCli.sh -u root -p password -url https://localhost --list-templates JAVA_HOME is not defined using /usr/java/latest GlobalResources|NavstarDefaultTemplate GlobalResources|NavstarDefaultTemplate Andrew|NavstarDefaultTemplate Andrew|Navstar40GBTemplate UliAccount|NavstarDefaultTemplate UliAccount|LVM-CBT-v1_1 UliAccount|NavstarSingleImageLVMTemplate UliAccount|scTestTemplate2 UliAccount|WebCenter_Template UliAccount|scTestTemplate UliAccount|scTestTemplate3 FAPoc|NavstarDefaultTemplate FAPoc|FA-Testing-Template
Script
Usage
usage: ./SimplifiedCli.sh [-a <Account Name>] [-v <vServer Name>] -u <Account User> -p <Account Password> [--verbose] <Command> -a <Account Name> Name of the Account that contains the Specified vServer. -u <Account User> User that is allowed to access the specified account the default is root -p <Account Password> password of the specified user -v <vServer Name> vServer to be templatised or cloned. -h This message. Commands --list-vservers List all the vServers in the specified Account. If no Account is specified then it will loop through all Accounts within the vDC listing the vServers. To successfully achieve this the mandatory Username and Password must have access to all the accounts. If --verbose is also specified the all available vServer information will be listed. --status-vservers List the status all the vServers in the specified Account. If no Account is specified then it will loop through all Accounts within the vDC listing the vServers. To successfully achieve this the mandatory Username and Password must have access to all the accounts. --start-vservers Start all or the named -v vServer(s) in the specified Account. If no Account is specified then it will loop through all Accounts within the vDC starting the vServers. --stop-vservers Stop all or the named -v vServer(s) in the specified Account. If no Account is specified then it will loop through all Accounts within the vDC stoping the vServers.
Download
#!/bin/bash ################################################################################ # # Exalogic EL X2-2 2.0.0.4 (Linux x86-64) Configuration Script. # # HEADER START # # THIS SCRIPT IS PROVIDED ON AN �AS IS� BASIS, WITHOUT WARRANTY OF ANY KIND, # EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES THAT # THE COVERED SCRIPT IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR # PURPOSE OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE # OF THE COVERED SOFTWARE IS WITH YOU. SHOULD ANY COVERED SOFTWARE PROVE # DEFECTIVE IN ANY RESPECT, YOU (NOT THE INITIAL DEVELOPER OR ANY OTHER # CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY SERVICING, REPAIR OR CORRECTION. # NO USE OF ANY COVERED SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS # DISCLAIMER. # # When distributing this Code, include this HEADER in each file. # If applicable, add the following below this this HEADER, with the fields # enclosed by brackets "[]" replaced with your own identifying information: # Portions Copyright [yyyy] [name of copyright owner] # # HEADER END # # # Copyright 2011 Andrew Hopkinson, Oracle Corporation UK Ltd. # ################################################################################ export OCCLI=/opt/sun/occli/bin export IAAS_HOME=/opt/oracle/iaas/cli export IAAS_BASE_URL=https://localhost export BASE_IAAS_ACCESS_KEY_FILE=iaas_access.key export BASE_KEY_NAME=cli.asset.create export BASE_KEY_FILE=iaas_access.pub export RUN_DATE=`date +"%Y%m%d-%H%M"` #CloudUser used to create vServers & Volumes export IAAS_USER=root export IAAS_PASSWORD_FILE=root.pwd export INPUT_FILE=CreateAssets.in export ACCOUNTS_FILE=accounts.out export VOLUMES_FILE=volumes.out export DISTGRPS_FILE=distgrp.out export VNETS_FILE=vnets.out export VSERVER_TYPES_FILE=vstype.out export VSERVER_FILE=vserver.out export VSERVER_TEMPLATES=template.out export NETWORK_STATIC_IPS=staticips.out export KEY_PAIRS=keypairs.out function getAccounts() { accountsArray=( $($IAAS_HOME/bin/akm-describe-accounts --sep "|" | sed 's/ /_/g') ) } function getVServers() { vserversArray=( $($IAAS_HOME/bin/iaas-describe-vservers --sep "|" | sed 's/ /_/g') ) } function getNetworks() { vnetsArray=( $($IAAS_HOME/bin/iaas-describe-vnets --sep "|" | sed 's/ /_/g') ) } function getDistributionGroups() { distGrpsArray=( $($IAAS_HOME/bin/iaas-describe-distribution-groups --sep "|" | sed 's/ /_/g') ) } function getTemplates() { templatesArray=( $($IAAS_HOME/bin/iaas-describe-server-templates --sep "|" | sed 's/ /_/g') ) } function getVolumes() { volumesArray=( $($IAAS_HOME/bin/iaas-describe-volumes --sep "|" | sed 's/ /_/g') ) } function connectToAccount() { # Set run specific key information export IAAS_ACCESS_KEY_FILE=$ACCOUNT_NAME"."$RUN_DATE"."$BASE_IAAS_ACCESS_KEY_FILE export KEY_NAME=$ACCOUNT_NAME"."$RUN_DATE"."$BASE_KEY_NAME export KEY_FILE=$ACCOUNT_NAME"."$RUN_DATE"."$BASE_KEY_FILE #echo "IAAS_ACCESS_KEY_FILE=$IAAS_ACCESS_KEY_FILE" #echo "KEY_NAME=$KEY_NAME" #echo "KEY_FILE=$KEY_FILE" #echo "Found Account $line" AK=`$IAAS_HOME/bin/akm-create-access-key --account $ACCOUNT_ID --access-key-file $IAAS_ACCESS_KEY_FILE` KEYPAIR=`$IAAS_HOME/bin/iaas-create-key-pair --key-name $KEY_NAME --key-file $KEY_FILE` #echo "Connected to $ACCOUNT_NAME" } function disconnectFromAccount() { $IAAS_HOME/bin/iaas-delete-key-pair --key-name $KEY_NAME --access-key-file $IAAS_ACCESS_KEY_FILE $IAAS_HOME/bin/akm-delete-access-key $AK rm -f $KEY_FILE $IAAS_ACCESS_KEY_FILE } ############################################################# ## ## stopVServers ## ============ ## ## Stop one or more vServers running within the currently ## connected Account. If a specific vServer Name is passed in ## $VSERVER as specified on the command line using -v then ## this will be the one stopped. If no VSERVER is specified ## then all vServers in the Account will be stopped. ## ############################################################# function stopVServers() { getVServers VSERVER_IDS="" VSERVER_NAMES="" for vserver in "${vserversArray[@]}" do VSERVER_ID=${vserver%%|*} vserver=${vserver#*|} VSERVER_NAME=${vserver%%|*} if [[ "$VSERVER" == "" || "$VSERVER" == "$VSERVER_NAME" ]] then if [[ "$VSERVER_IDS" == "" ]] then VSERVER_IDS=$VSERVER_ID VSERVER_NAMES=$VSERVER_NAME else VSERVER_IDS=$VSERVER_IDS","$VSERVER_ID VSERVER_NAMES=$VSERVER_NAMES","$VSERVER_NAME fi fi done if [[ "$VSERVER_IDS" != "" ]] then echo "Stopping vServer(s) [$VSERVER_NAMES]" $IAAS_HOME/bin/iaas-stop-vservers --vserver-ids $VSERVER_IDS --force else echo "No vServers to stop" fi } ############################################################# ## ## startVServers ## ============= ## ## Start one or more vServers stopped within the currently ## connected Account. If a specific vServer Name is passed in ## $VSERVER as specified on the command line using -v then ## this will be the one started. If no VSERVER is specified ## then all vServers in the Account will be started. ## ############################################################# function startVServers() { getVServers VSERVER_IDS="" VSERVER_NAMES="" for vserver in "${vserversArray[@]}" do VSERVER_ID=${vserver%%|*} vserver=${vserver#*|} VSERVER_NAME=${vserver%%|*} if [[ "$VSERVER" == "" || "$VSERVER" == "$VSERVER_NAME" ]] then if [[ "$VSERVER_IDS" == "" ]] then VSERVER_IDS=$VSERVER_ID VSERVER_NAMES=$VSERVER_NAME else VSERVER_IDS=$VSERVER_IDS","$VSERVER_ID VSERVER_NAMES=$VSERVER_NAMES","$VSERVER_NAME fi fi done if [[ "$VSERVER_IDS" != "" ]] then echo "Starting vServer(s) [$VSERVER_NAMES]" $IAAS_HOME/bin/iaas-start-vservers --vserver-ids $VSERVER_IDS else echo "No vServers to start" fi } ############################################################# ## ## listVServers ## ============ ## ## List the vServers running on the specified Account is ## the verbose flag is set then all vServer details will be ## displayed otherwise simple the Acc and Name. ## ############################################################# function listVServers() { getVServers for vserver in "${vserversArray[@]}" do VSERVER_ID=${vserver%%|*} vserver=${vserver#*|} VSERVER_NAME=${vserver%%|*} if [[ "$VSERVER" == "" || "$VSERVER" == "$VSERVER_NAME" ]] then if [[ "$VERBOSE" == "true" ]] then echo "$ACCOUNT_NAME|$VSERVER_NAME|$VSERVER_ID|"$(echo $vserver | sed 's/_/ /g') else echo "$ACCOUNT_NAME|$VSERVER_NAME" fi fi done } ############################################################# ## ## listVServerStatus ## ================= ## ## List the Status of the vServers within an Account. ## ############################################################# function listVServerStatus() { getVServers for vserver in "${vserversArray[@]}" do VSERVER_ID=${vserver%%|*} vserver=${vserver#*|} VSERVER_NAME=${vserver%%|*} vserver=${vserver#*|} VSERVER_DESC=${vserver%%|*} vserver=${vserver#*|} VSERVER_STATUS=${vserver%%|*} if [[ "$VSERVER" == "" || "$VSERVER" == "$VSERVER_NAME" ]] then echo "$ACCOUNT_NAME|$VSERVER_NAME|$VSERVER_STATUS" fi done } ############################################################# ## ## listVNets ## ========= ## ## List the Networks within an Account. ## ############################################################# function listVNets() { getNetworks for vnet in "${vnetsArray[@]}" do VNET_ID=${vnet%%|*} vnet=${vnet#*|} VNET_NAME=${vnet%%|*} vnet=${vnet#*|} if [[ "$VERBOSE" == "true" ]] then echo "$ACCOUNT_NAME|$VNET_NAME|$VNET_ID|"$(echo $vnet | sed 's/_/ /g') else VNET_DESC=${vnet%%|*} vnet=${vnet#*|} VNET_STATUS=${vnet%%|*} vnet=${vnet#*|} VNET_IP=${vnet%%|*} echo "$ACCOUNT_NAME|$VNET_NAME|$VNET_IP" fi done } ############################################################# ## ## listDistributionGroups ## ====================== ## ## List the Distribution Groups within an Account. ## ############################################################# function listDistributionGroups() { getDistributionGroups for distGrp in "${distGrpsArray[@]}" do DG_ID=${distGrp%%|*} distGrp=${distGrp#*|} DG_NAME=${distGrp%%|*} distGrp=${distGrp#*|} if [[ "$VERBOSE" == "true" ]] then echo "$ACCOUNT_NAME|$DG_NAME|$DG_ID|"$(echo $distGrp | sed 's/_/ /g') else DG_DESC=${distGrp%%|*} distGrp=${distGrp#*|} DG_STATUS=${distGrp%%|*} echo "$ACCOUNT_NAME|$DG_NAME|$VNET_IP" fi done } ############################################################# ## ## listTemplates ## ============= ## ## List the Templates within an Account. ## ############################################################# function listTemplates() { getTemplates for template in "${templatesArray[@]}" do TEMPLATE_ID=${template%%|*} template=${template#*|} TEMPLATE_NAME=${template%%|*} template=${template#*|} if [[ "$VERBOSE" == "true" ]] then echo "$ACCOUNT_NAME|$TEMPLATE_NAME|$TEMPLATE_ID|"$(echo $template | sed 's/_/ /g') else TEMPLATE_DESC=${template%%|*} template=${template#*|} TEMPLATE_STATUS=${template%%|*} echo "$ACCOUNT_NAME|$TEMPLATE_NAME" fi done } ############################################################# ## ## listVolumes ## =========== ## ## List the Volumes within an Account. ## ############################################################# function listVolumes() { getVolumes for volume in "${volumesArray[@]}" do VOLUME_ID=${volume%%|*} volume=${volume#*|} VOLUME_NAME=${volume%%|*} volume=${volume#*|} if [[ "$VERBOSE" == "true" ]] then echo "$ACCOUNT_NAME|$VOLUME_NAME|$VOLUME_ID|"$(echo $volume | sed 's/_/ /g') else VOLUME_DESC=${volume%%|*} volume=${volume#*|} VOLUME_STATUS=${volume%%|*} volume=${volume#*|} VOLUME_SIZE=${volume%%|*} echo "$ACCOUNT_NAME|$VOLUME_NAME|$VOLUME_SIZE" fi done } ############################################################# ## ## usage ## ===== ## ## Show usage. ## ############################################################# function usage() { echo "" echo >&2 "usage: $0 [-a <Account Name>] [-v <vServer Name>] -u <Account User> -p <Account Password> [--verbose] <Command>" echo >&2 " -a <Account Name> Name of the Account that contains the Specified vServer." echo >&2 " -u <Account User> User that is allowed to access the specified account the default is root" echo >&2 " -p <Account Password> password of the specified user" echo >&2 " -v <vServer Name> vServer to be templatised or cloned." echo >&2 " -url <IAAS Base URL> URL to access the EMOC interface the default is https://localhost." echo >&2 " -h This message." echo >&2 " " echo >&2 "Commands " echo >&2 " " echo >&2 " --list-vservers" echo >&2 " List all the vServers in the specified Account. If no Account is specified then it" echo >&2 " will loop through all Accounts within the vDC listing the vServers. To successfully" echo >&2 " achieve this the mandatory Username and Password must have access to all the accounts." echo >&2 " If --verbose is also specified the all available vServer information will be listed." echo >&2 " " echo >&2 " --status-vservers" echo >&2 " List the status all the vServers in the specified Account. If no Account is specified then it" echo >&2 " will loop through all Accounts within the vDC listing the vServers. To successfully" echo >&2 " achieve this the mandatory Username and Password must have access to all the accounts." echo >&2 " " echo >&2 " --start-vservers" echo >&2 " Start all or the named -v vServer(s) in the specified Account. If no Account is specified" echo >&2 " then it will loop through all Accounts within the vDC starting the vServers." echo >&2 " " echo >&2 " --stop-vservers" echo >&2 " Stop all or the named -v vServer(s) in the specified Account. If no Account is specified" echo >&2 " then it will loop through all Accounts within the vDC stoping the vServers." echo >&2 " " echo >&2 " --list-vnets" echo >&2 " List all the vNets in the specified Account. If no Account is specified then it" echo >&2 " will loop through all Accounts within the vDC listing the vNets. To successfully" echo >&2 " achieve this the mandatory Username and Password must have access to all the accounts." echo >&2 " If --verbose is also specified the all available vNet information will be listed." echo >&2 " " echo >&2 " --list-distgroups" echo >&2 " List all the Distribution Groups in the specified Account. If no Account is specified then it" echo >&2 " will loop through all Accounts within the vDC listing the Distribution Groups. To successfully" echo >&2 " achieve this the mandatory Username and Password must have access to all the accounts." echo >&2 " If --verbose is also specified the all available Distribution Group information will be listed." echo >&2 " " echo >&2 " --list-volumes" echo >&2 " List all the Volumes in the specified Account. If no Account is specified then it" echo >&2 " will loop through all Accounts within the vDC listing the Volumes. To successfully" echo >&2 " achieve this the mandatory Username and Password must have access to all the accounts." echo >&2 " If --verbose is also specified the all available Volumes information will be listed." echo >&2 " " echo >&2 " --list-templates" echo >&2 " List all the Templates in the specified Account. If no Account is specified then it" echo >&2 " will loop through all Accounts within the vDC listing the Templates. To successfully" echo >&2 " achieve this the mandatory Username and Password must have access to all the accounts." echo >&2 " If --verbose is also specified the all available Template information will be listed." echo"" exit 1 } ############################################################### ## ## Simple start for the script that will extract the parameters ## and call the appriate start function. ## ############################################################### export ACCOUNT_USER="root" export ACCOUNT_PASSWORD="welcome1" export SYSTEMIMGDIR=/mnt/elsystem while [ $# -gt 0 ] do case "$1" in -a) ACCOUNT="$2"; shift;; -v) VSERVER="$2"; shift;; -u) ACCOUNT_USER="$2"; shift;; -p) ACCOUNT_PASSWORD="$2"; shift;; -url) IAAS_BASE_URL="$2"; shift;; --verbose) VERBOSE=true;; --list-vservers) LIST_VSERVERS=true;; --stop-vservers) STOP_VSERVERS=true;; --start-vservers) START_VSERVERS=true;; --status-vservers) STATUS_VSERVERS=true;; --list-vnets) LIST_VNETS=true;; --list-distgroups) LIST_DISTGRPS=true;; --list-templates) LIST_TEMPLATES=true;; --list-volumes) LIST_VOLUMES=true;; *) usage;; *) break;; esac shift done IAAS_USER=$ACCOUNT_USER echo "$ACCOUNT_PASSWORD" > $IAAS_PASSWORD_FILE # Check if the JAVA_HOME is set if [[ "$JAVA_HOME" == "" ]] then export JAVA_HOME=/usr/java/latest echo "JAVA_HOME is not defined using $JAVA_HOME" fi getAccounts for account in "${accountsArray[@]}" do ACCOUNT_ID=${account%%|*} account=${account#*|} ACCOUNT_NAME=${account%%|*} if [[ ("$ACCOUNT" == "" || "$ACCOUNT" == "$ACCOUNT_NAME") && "$ACCOUNT_ID" == ACC-* ]] then connectToAccount if [[ "$STOP_VSERVERS" == "true" ]] then stopVServers elif [[ "$START_VSERVERS" == "true" ]] then startVServers elif [[ "$LIST_VSERVERS" == "true" ]] then listVServers elif [[ "$STATUS_VSERVERS" == "true" ]] then listVServerStatus elif [[ "$LIST_VNETS" == "true" ]] then listVNets elif [[ "$LIST_DISTGRPS" == "true" ]] then listDistributionGroups elif [[ "$LIST_TEMPLATES" == "true" ]] then listTemplates elif [[ "$LIST_VOLUMES" == "true" ]] then listVolumes fi disconnectFromAccount fi done
No comments:
Post a Comment