@@ -972,47 +972,57 @@ public boolean deleteHost(long hostId) {
972972 + host .getGuid ());
973973 }
974974
975- if (host .getType () == Type .Routing
976- && host .getHypervisorType () == HypervisorType .XenServer ) {
977- if (host .getClusterId () != null ) {
978- List <HostVO > hosts = _hostDao .listBy (Type .Routing ,
979- host .getClusterId (), host .getPodId (),
980- host .getDataCenterId ());
981- hosts .add (host );
982- boolean success = true ;
983- for (HostVO thost : hosts ) {
984- long thostId = thost .getId ();
985- PoolEjectCommand eject = new PoolEjectCommand (
986- host .getGuid ());
987- Answer answer = easySend (thostId , eject );
988- if (answer != null && answer .getResult ()) {
989- s_logger .debug ("Eject Host: " + hostId + " from "
990- + thostId + " Succeed" );
991- success = true ;
992- break ;
993- } else {
994- success = false ;
995- s_logger .debug ("Eject Host: "
996- + hostId
997- + " from "
998- + thostId
999- + " failed due to "
1000- + (answer != null ? answer .getDetails ()
1001- : "no answer" ));
1002- }
1003- }
1004- if (!success ) {
1005- String msg = "Unable to eject host "
1006- + host .getGuid ()
1007- + " due to there is no host up in this cluster, please execute xe pool-eject host-uuid="
1008- + host .getGuid () + "in this host "
1009- + host .getPrivateIpAddress ();
1010- s_logger .info (msg );
1011- _alertMgr .sendAlert (AlertManager .ALERT_TYPE_HOST ,
1012- host .getDataCenterId (), host .getPodId (),
1013- "Unable to eject host " + host .getGuid (), msg );
1014- }
1015- }
975+ if (host .getType () == Type .Routing ) {
976+ if (host .getHypervisorType () == HypervisorType .XenServer ) {
977+ if (host .getClusterId () != null ) {
978+ List <HostVO > hosts = _hostDao .listBy (Type .Routing ,
979+ host .getClusterId (), host .getPodId (),
980+ host .getDataCenterId ());
981+ hosts .add (host );
982+ boolean success = true ;
983+ for (HostVO thost : hosts ) {
984+ long thostId = thost .getId ();
985+ PoolEjectCommand eject = new PoolEjectCommand (
986+ host .getGuid ());
987+ Answer answer = easySend (thostId , eject );
988+ if (answer != null && answer .getResult ()) {
989+ s_logger .debug ("Eject Host: " + hostId + " from "
990+ + thostId + " Succeed" );
991+ success = true ;
992+ break ;
993+ } else {
994+ success = false ;
995+ s_logger .debug ("Eject Host: "
996+ + hostId
997+ + " from "
998+ + thostId
999+ + " failed due to "
1000+ + (answer != null ? answer .getDetails ()
1001+ : "no answer" ));
1002+ }
1003+ }
1004+ if (!success ) {
1005+ String msg = "Unable to eject host "
1006+ + host .getGuid ()
1007+ + " due to there is no host up in this cluster, please execute xe pool-eject host-uuid="
1008+ + host .getGuid () + "in this host "
1009+ + host .getPrivateIpAddress ();
1010+ s_logger .info (msg );
1011+ _alertMgr .sendAlert (AlertManager .ALERT_TYPE_HOST ,
1012+ host .getDataCenterId (), host .getPodId (),
1013+ "Unable to eject host " + host .getGuid (), msg );
1014+ }
1015+ }
1016+ } else if (host .getHypervisorType () == HypervisorType .KVM ) {
1017+ try {
1018+ ShutdownCommand cmd = new ShutdownCommand (ShutdownCommand .DeleteHost , null );
1019+ send (host .getId (), cmd );
1020+ } catch (AgentUnavailableException e ) {
1021+ s_logger .debug ("Sending ShutdownCommand failed: " + e .toString ());
1022+ } catch (OperationTimedoutException e ) {
1023+ s_logger .debug ("Sending ShutdownCommand failed: " + e .toString ());
1024+ }
1025+ }
10161026 }
10171027 txn .start ();
10181028
0 commit comments