Legacy HDS Forums

Configuration automation with expect

Discussion created by Legacy HDS Forums on Sep 6, 2006
Latest reply on Sep 8, 2006 by Legacy HDS Forums

Originally posted by: liho



I?m not expert in expect, but I?ve been asked how to automate different configuration steps. This example provides logging to AU, creation of LU, deletion of LU and logging out. No any input is required from user (all passwords are hard coded).

[code]# cat test.exp
spawn echo "### Logging to Array Unit"
spawn aulogin -unit 9570V-1
expect "Password: "
send "test\r"
expect "User ID for array unit : "
send "test\r"
expect "Password for array unit : "
send "test\r"
interact

spawn echo "### Referencing Logical Units"
spawn auluref -unit 9570V-1 -g
interact

spawn echo "### Creating Logical Unit"
spawn auluadd -unit 9570V-1 -lu 57 -rg 5 -size 1g -ctl1
expect "Password: "
send "test\r"
interact

spawn echo "### Referencing Logical Units"
spawn auluref -unit 9570V-1 -g
interact

spawn echo "### Removing Logical Unit"
spawn auludel -unit 9570V-1 -last
expect "Password: "
send "test\r"
expect "delete the last defined logical unit 57"
send "y\r"
interact

spawn echo "### Logging out from Array Unit"
spawn aulogout -unit 9570V-1
expect "Password: "
send "test\r"
interact[/code]

[code]# expect test.exp
spawn echo ### Logging to Array Unit
spawn aulogin -unit 9570V-1
Password:

User ID for array unit : test
Password for array unit :
spawn echo ### Referencing Logical Units
spawn auluref -unit 9570V-1 -g
          Capacity                RAID  RAID
   LU     [Gbyte] C-CTL D-CTL Group Level Type Status
     0          0.0      0      0      0      5 FC   Normal
     1       251.5      1      1      0      5 FC   Normal
   11        30.0      0      0      1   1+0 FC   Normal
   12        30.0      0      0      1   1+0 FC   Normal
   13        30.0      0      0      1   1+0 FC   Normal
   14        42.8      1      1      1   1+0 FC   Normal
   20          0.0      1      1      2      5 FC   Normal
   21        14.0      1      1      2      5 FC   Normal
   22       251.5      1      1      2      5 FC   Normal
   31        60.0      1      1      3      5 FC   Normal
   32       140.0      0      0      3      5 FC   Normal
   41        10.0      0      0      4      1 FC   Normal
   50          0.0      0      0      5      1 FC   Normal
   51          0.0      0      0      5      1 FC   Normal
   52          0.0      0      0      5      1 FC   Normal
   53          0.0      0      0      5      1 FC   Normal
   54          0.0      0      0      5      1 FC   Normal
   55          0.0      0      0      5      1 FC   Normal
   56          0.0      0      0      5      1 FC   Normal
spawn echo ### Creating Logical Unit
spawn auluadd -unit 9570V-1 -lu 57 -rg 5 -size 1g -ctl1
Password:
spawn echo ### Referencing Logical Units
spawn auluref -unit 9570V-1 -g
          Capacity                RAID  RAID
   LU     [Gbyte] C-CTL D-CTL Group Level Type Status
     0          0.0      0      0      0      5 FC   Normal
     1       251.5      1      1      0      5 FC   Normal
   11        30.0      0      0      1   1+0 FC   Normal
   12        30.0      0      0      1   1+0 FC   Normal
   13        30.0      0      0      1   1+0 FC   Normal
   14        42.8      1      1      1   1+0 FC   Normal
   20          0.0      1      1      2      5 FC   Normal
   21        14.0      1      1      2      5 FC   Normal
   22       251.5      1      1      2      5 FC   Normal
   31        60.0      1      1      3      5 FC   Normal
   32       140.0      0      0      3      5 FC   Normal
   41        10.0      0      0      4      1 FC   Normal
   50          0.0      0      0      5      1 FC   Normal
   51          0.0      0      0      5      1 FC   Normal
   52          0.0      0      0      5      1 FC   Normal
   53          0.0      0      0      5      1 FC   Normal
   54          0.0      0      0      5      1 FC   Normal
   55          0.0      0      0      5      1 FC   Normal
   56          0.0      0      0      5      1 FC   Normal
   57          1.0      1      1      5      1 FC   Unformat
spawn echo ### Removing Logical Unit
spawn auludel -unit 9570V-1 -last
Password:
Are you sure you want to delete the last defined logical unit 57? (y/n [n]): y
spawn echo ### Logging out from Array Unit
spawn aulogout -unit 9570V-1
Password:

# [/code]

Outcomes