@@ -29,6 +29,13 @@ func PowerOn(c *cli.Context) error {
2929 return cli .Exit (fmt .Sprintf ("FAIL: Failed to login to BMC host %s: %v" , profile .Host , err ), 1 )
3030 }
3131
32+ defer func () {
33+ err = srv .Logout (profile .Host )
34+ if err != nil {
35+ lgr .Logger .Logf ("[WARN] Failed to logout from BMC host %s: %v" , profile .Host , err )
36+ }
37+ }()
38+
3239 err = srv .PowerOn (profile .Host )
3340 if err != nil {
3441 return cli .Exit (fmt .Sprintf ("FAIL: Failed to power on BMC host %s: %v" , profile .Host , err ), 1 )
@@ -74,6 +81,13 @@ func PowerOff(c *cli.Context) error {
7481 return cli .Exit (fmt .Sprintf ("FAIL: Failed to login to BMC host %s: %v" , profile .Host , err ), 1 )
7582 }
7683
84+ defer func () {
85+ err = srv .Logout (profile .Host )
86+ if err != nil {
87+ lgr .Logger .Logf ("[WARN] Failed to logout from BMC host %s: %v" , profile .Host , err )
88+ }
89+ }()
90+
7791 err = srv .PowerOff (profile .Host )
7892 if err != nil {
7993 return cli .Exit (fmt .Sprintf ("FAIL: Failed to power off BMC host %s: %v" , profile .Host , err ), 1 )
@@ -119,6 +133,13 @@ func PowerStatus(c *cli.Context) error {
119133 return cli .Exit (fmt .Sprintf ("FAIL: Failed to login to BMC host %s: %v" , profile .Host , err ), 1 )
120134 }
121135
136+ defer func () {
137+ err = srv .Logout (profile .Host )
138+ if err != nil {
139+ lgr .Logger .Logf ("[WARN] Failed to logout from BMC host %s: %v" , profile .Host , err )
140+ }
141+ }()
142+
122143 status , err := srv .ChassisStatus (profile .Host )
123144 if err != nil {
124145 return cli .Exit (fmt .Sprintf ("FAIL: Failed to get power status for BMC host %s: %v" , profile .Host , err ), 1 )
0 commit comments