Friday, 20 June 2014

Exalogic Virtual Tea Break Snippets - Pythonised SimpleExaCli

Having completed the CreateAssembly (Create Assets) re-write of the SimpleExaCli I decided it was time to migrate some of the additional functionality I use and enhancing the outputs to match my requirements. This quick blog entry will describe the currently migrated commands and their new output structure. In accordance with my previous CreateAssembly blog I have split the functions into smaller commands and subsequently wrapped calls to these into a top level SimplePythonExaCli.sh. Although this is not a full re-write the list of functions will grow but currently comprise of the following:
Each will be described in more detail but all follow the same underlying principles on parameter requirements and processing described below.

Download

SimplePythonExaCli.sh

This script is simply a pass through wrapper that inspects its first, command,, parameter and calls the appropriate sub-script passing all remaining parameters without inspecting them.

[root@PythonEchoUtilityServer ~]# SimplePythonExaCli.sh -?

usage: SimplePythonExaCli.sh  

Commands

          --list-accounts
          --list-vservers
          --list-vnets | --list-networks
          --list-distgroups | --list-distribution-groups
          --list-volumes
          --list-templates
          --create-assets | --create-assemblies
          --capture-vserver
          --convert-vserver-to-template | --create-template

Parameters passed directly onto sub command.

For command specific help execute  --help.


[root@PythonEchoUtilityServer ~]#
while [ $# -gt 0 ]
do
  case "$1" in  
# Commands
    --list-accounts) shift; $DIRNAME/ListAccounts.sh "$@";;
    --list-vservers) shift; $DIRNAME/ListVServers.sh "$@";;
    --list-vnets | --list-networks) shift; $DIRNAME/ListNetworks.sh "$@";;
    --list-distgroups | --list-distribution-groups) shift; $DIRNAME/ListDistributionGroups.sh "$@";;
    --list-templates) shift; $DIRNAME/ListTemplates.sh "$@";;
    --list-volumes) shift; $DIRNAME/ListVolumes.sh "$@";;
    --create-assets | --create-assemblies) shift; $DIRNAME/CreateAssembly.sh "$@";;
    --capture-vserver) shift; $DIRNAME/CaptureVServer.sh "$@";;
    --convert-vserver-to-template | --create-template) shift; $DIRNAME/ConvertVServerToTemplate.sh "$@";;
    
    *) usage;;
  esac
  break
done

Common Processing Functionality

All the functions within the new functions require the following mandatory parameters:
  • -u, --user : Username to be used to access the EMOC via the IaaS Cli.
  • -p, --passwordFile : Name of the file containing the password associated with the user, this file will contain just the password.
  • --url : URL to access EMOC.
In addition they take the following optional parameters:
  • -f, --assemblyFile : JSON file to which output will be written.
  • -a, --account : Name of the Account to be processed.
  • --verbose : Prints verbose output during execution.
Given these are optional the underlying processing will change depending of if they are specified. If the user specifies an Assembly File (-f, --assemblyFile) then the output of the command will be written to the specified file in a JSON format similar to that required for the Create Assembly functionality. When the optional Account name is specified (-a, --account) then the commands execute for a single Account if it is not specified then they will execute for the whole vDC iterating through the accounts.

List Accounts 

The List Accounts function will take the specified account and list all the assets that are defined within the specified account and can be considered an amalgamation of the following List commands. In it's default format this is a simple list of the assets:
[root@PythonEchoUtilityServer ~]# ListAccounts.sh -u root -p root.pwd -a andrew --url https://172.16.0.5:9443

Connecting to account andrew
DistributionGroups in Account: andrew
     dgWLS
     dgOTD
Networks in Account: andrew
     EoIB-external-mgmt
     scae09-eoib1
     IPoIB-vserver-shared-storage
     vNetWLS
     vNetOTD
Templates in Account: andrew
     UtilityVServerTemplate
     ECHO_Guest_Template_2_0_6_0_0
     NavstarBaseGuestTemplate
     EchoBaseGuestTemplate
     OTDTestTemplate
     WLSTestTemplate
Volumes in Account: andrew
     TestVol3
     TestSharedVol1
     TestVol2
     TestSharedVol2
     TestVol1
Disconnecting from account
Connecting to account andrew
vServers in Account: andrew
     EchoUtilityServer
     otdNode2
     PythonEchoUtilityServer
     OTDTemplateServer
     otdAdminServer
     Test
     NavstarUtilityServer
     otdNode1
     wlsManagedServer2
     wlsManagedServer1
     wlsAdminServer
Disconnecting from account
Specifying the --verbose option will cause the function to drill down into the components and expand its output into a more human readable form.
[root@PythonEchoUtilityServer ~]# ListAccounts.sh -u root -p root.pwd -a andrew --url https://172.16.0.5:9443 --verbose

Connecting to account andrew
DistributionGroups in Account: andrew
     dgWLS
        Size              : 8
            VServer       : wlsManagedServer2
            VServer       : wlsAdminServer
            VServer       : wlsManagedServer1
        Status            : OK
     dgOTD
        Size              : 8
            VServer       : otdNode1
            VServer       : otdNode2
            VServer       : otdAdminServer
        Status            : OK
Networks in Account: andrew
     EoIB-external-mgmt
        Range/CIDR        : 10.128.38.0/23
        Status            : OK
     scae09-eoib1
        Range/CIDR        : 10.128.36.0/24
        Status            : OK
..........
Templates in Account: andrew
     UtilityVServerTemplate
        Description       : Import URLs: [http://192.168.21.5/shares/export/common/images/vServerTemplates/el_template_PythonEchoUtilityServer.tgz]
        Public            : true
        Status            : OK
     ECHO_Guest_Template_2_0_6_0_0
        Description       : Echo Guest Vservers Template  2 0 6 0 0
        Public            : true
        Status            : OK
..........
Volumes in Account: andrew
     TestVol3
        Size              : 16.0
        Shared            : false
            VServer       : EchoUtilityServer
        Status            : OK
..........
Disconnecting from account
Connecting to account andrew
vServers in Account: andrew
     EchoUtilityServer
        Description       : Oracle VM Virtual Machine
        Template          : Removed
        HA                : false
        Type              : SMALL
        Distribution Group:
        Network           : EoIB-external-mgmt 10.128.38.31
        Network           : IPoIB-vserver-shared-storage 172.17.0.45
        Volume            : TestVol3
     otdNode2
        Description       : OTD Node 2 vServer
        Template          : OTDTestTemplate
        HA                : true
        Type              : SMALL
        Distribution Group: dgOTD
        Network           : vNetWLS 192.168.3.168
        Network           : scae09-eoib1 10.128.36.204
        Network           : vNetOTD 192.168.4.57
        Network           : IPoIB-vserver-shared-storage 172.17.0.44
..........
Disconnecting from account

List Distribution Groups 

Simply Lists the distribution groups declared within an account when the --verbose parameter is specified the list will include more tetailed information including which vServers are members of the distribution group.
[root@PythonEchoUtilityServer ~]# ListDistributionGroups.sh -u root -p root.pwd -a andrew --url https://172.16.0.5:9443 --verbose

Connecting to account andrew
DistributionGroups in Account: andrew
     dgWLS
        Size              : 8
            VServer       : wlsManagedServer2
            VServer       : wlsAdminServer
            VServer       : wlsManagedServer1
        Status            : OK
     dgOTD
        Size              : 8
            VServer       : otdNode1
            VServer       : otdNode2
            VServer       : otdAdminServer
        Status            : OK
Disconnecting from account

Overall Execution Time  : 0:00:15

List Networks 

In its simple for the list networks command will display a plain list of the networks associated with the account. When verbose is specified we can see the IP/CIDR for the networks as well.

[root@PythonEchoUtilityServer ~]# ListNetworks.sh -u root -p root.pwd -a andrew --url https://172.16.0.5:9443 --verbose


Connecting to account andrew
Networks in Account: andrew
     EoIB-external-mgmt
        Range/CIDR        : 10.128.38.0/23
        Status            : OK
     scae09-eoib1
        Range/CIDR        : 10.128.36.0/24
        Status            : OK
     IPoIB-vserver-shared-storage
        Range/CIDR        : 172.17.0.0/16
        Status            : OK
     vNetWLS
        Range/CIDR        : 192.168.3.0/24
        Status            : OK
     vNetOTD
        Range/CIDR        : 192.168.4.0/24
        Status            : OK
Disconnecting from account

Overall Execution Time  : 0:00:12

List Templates 

The List Templates by default will simply display a list of all templates that are accessible within the specified account. This includes any that have been declared as public in another account. When the --verbose flag is used it will display the extra information about the public status of the template.

[root@PythonEchoUtilityServer ~]# ListTemplates.sh -u root -p root.pwd -a andrew --url https://172.16.0.5:9443 --verbose

Connecting to account andrew
Templates in Account: andrew
     UtilityVServerTemplate
        Description       : Import URLs: [http://192.168.21.5/shares/export/common/images/vServerTemplates/el_template_PythonEchoUtilityServer.tgz]
        Public            : true
        Status            : OK
     ECHO_Guest_Template_2_0_6_0_0
        Description       : Echo Guest Vservers Template  2 0 6 0 0
        Public            : true
        Status            : OK
     NavstarBaseGuestTemplate
        Description       : Import URLs: [http://192.168.21.5/shares/export/common/images/el_base_linux_guest_vm_template_2.0.4.0.0_64.tgz]
        Public            : true
        Status            : OK
     EchoBaseGuestTemplate
        Description       : Import URLs: [http://192.168.21.5/shares/export/common/images/el_base_linux_guest_vm_template_2.0.6.0.0_64.tgz]
        Public            : true
        Status            : OK
     OTDTestTemplate
        Description       : Import URLs: [http://172.17.0.5/shares/export/common/images/vServerTemplates/el_template_OTDTemplateServer.tgz]
        Public            : false
        Status            : OK
     WLSTestTemplate
        Description       : Import URLs: [http://172.17.0.5/shares/export/common/images/vServerTemplates/el_template_WLSTemplateServer.tgz]
        Public            : false
        Status            : OK
Disconnecting from account

Overall Execution Time  : 0:00:12

List Volumes 

The default output for the List Volumes is a simple list of volume names. When the --verbose is supplied additional information about each volume will be displayed including, if attached, the vServers using attaching the volume.

[root@PythonEchoUtilityServer ~]# ListVolumes.sh -u root -p root.pwd -a andrew --url https://172.16.0.5:9443 --verbose


Connecting to account andrew
Volumes in Account: andrew
     TestVol3
        Size              : 16.0
        Shared            : false
            VServer       : wlsAdminServer
        Status            : OK
     TestSharedVol1
        Size              : 8.0
        Shared            : true
        Status            : OK
     TestVol2
        Size              : 32.0
        Shared            : false
            VServer       : otdAdminServer
        Status            : OK
     TestSharedVol2
        Size              : 16.0
        Shared            : true
        Status            : OK
     TestVol1
        Size              : 16.0
        Shared            : false
            VServer       : otdAdminServer
        Status            : OK
Disconnecting from account

Overall Execution Time  : 0:00:16

List vServers

Displays a simple list of vServer names but when the --verbose is used this list is expanded to include information about distribution groups, networks etc.

[root@PythonEchoUtilityServer ~]# ListVServers.sh -u root -p root.pwd -a andrew --url https://172.16.0.5:9443 --verbose


Connecting to account andrew
vServers in Account: andrew
     EchoUtilityServer
        Description       : Oracle VM Virtual Machine
        Template          : Removed
        HA                : false
        Type              : SMALL
        Distribution Group:
        Network           : EoIB-external-mgmt 10.128.38.31
        Network           : IPoIB-vserver-shared-storage 172.17.0.45
     otdNode2
        Description       : OTD Node 2 vServer
        Template          : OTDTestTemplate
        HA                : true
        Type              : SMALL
        Distribution Group: dgOTD
        Network           : vNetWLS 192.168.3.168
        Network           : scae09-eoib1 10.128.36.204
        Network           : vNetOTD 192.168.4.57
        Network           : IPoIB-vserver-shared-storage 172.17.0.44
     PythonEchoUtilityServer
        Description       : Oracle VM Virtual Machine
        Template          : Removed
        HA                : false
        Type              : SMALL
        Distribution Group:
        Network           : EoIB-external-mgmt 10.128.38.37
        Network           : IPoIB-vserver-shared-storage 172.17.0.32
     OTDTemplateServer
        Description       : Oracle VM Virtual Machine
        Template          : Removed
        HA                : false
        Type              : SMALL
        Distribution Group:
        Network           : scae09-eoib1 10.128.36.210
        Network           : IPoIB-vserver-shared-storage 172.17.0.36
     otdAdminServer
        Description       : OTD Admin vServer
        Template          : OTDTestTemplate
        HA                : true
        Type              : SMALL
        Distribution Group: dgOTD
        Network           : vNetWLS 192.168.3.169
        Network           : vNetOTD 192.168.4.55
        Network           : IPoIB-vserver-shared-storage 172.17.0.42
        Network           : scae09-eoib1 10.128.36.202
        Volume            : TestVol2
        Volume            : TestVol1
     Test
        Description       : Oracle VM Virtual Machine
        Template          : EchoBaseGuestTemplate
        HA                : false
        Type              : SMALL
        Distribution Group:
        Network           : scae09-eoib1 10.128.36.211
        Network           : IPoIB-vserver-shared-storage 172.17.0.26
     NavstarUtilityServer
        Description       : Oracle VM Virtual Machine
        Template          : Removed
        HA                : false
        Type              : SMALL
        Distribution Group:
        Network           : IPoIB-vserver-shared-storage 172.17.0.41
        Network           : EoIB-external-mgmt 10.128.38.36
     otdNode1
        Description       : OTD Node 1 vServer
        Template          : OTDTestTemplate
        HA                : true
        Type              : SMALL
        Distribution Group: dgOTD
        Network           : IPoIB-vserver-shared-storage 172.17.0.43
        Network           : scae09-eoib1 10.128.36.203
        Network           : vNetWLS 192.168.3.167
        Network           : vNetOTD 192.168.4.54
     wlsManagedServer2
        Description       : WLS Managed vServer 2
        Template          : WLSTestTemplate
        HA                : true
        Type              : SMALL
        Distribution Group: dgWLS
        Network           : vNetWLS 192.168.3.160
        Network           : IPoIB-vserver-shared-storage 172.17.0.48
     wlsManagedServer1
        Description       : WLS Managed vServer 1
        Template          : WLSTestTemplate
        HA                : true
        Type              : SMALL
        Distribution Group: dgWLS
        Network           : IPoIB-vserver-shared-storage 172.17.0.47
        Network           : vNetWLS 192.168.3.162
     wlsAdminServer
        Description       : WLS Admin vServer
        Template          : WLSTestTemplate
        HA                : true
        Type              : SMALL
        Distribution Group: dgWLS
        Network           : IPoIB-vserver-shared-storage 172.17.0.46
        Network           : vNetWLS 192.168.3.161
        Volume            : TestVol3
Disconnecting from account

Overall Execution Time  : 0:00:22

No comments:

Post a Comment