mirror of
				https://github.com/apache/cloudstack.git
				synced 2025-10-26 08:42:29 +01:00 
			
		
		
		
	bug 9997:
put copy scripts in SetupCommand, 1. initiate returns host version, 2. if it doesn't match with DB, update DB, and reconnect the host. status 9997: resolved fixed
This commit is contained in:
		
							parent
							
								
									fc94196920
								
							
						
					
					
						commit
						055e5c82c7
					
				| @ -23,10 +23,20 @@ public class SetupCommand extends Command { | ||||
| 
 | ||||
|     HostEnvironment env; | ||||
|     boolean multipath; | ||||
|     boolean needSetup; | ||||
|      | ||||
|     public boolean needSetup() { | ||||
|         return needSetup; | ||||
|     } | ||||
| 
 | ||||
|     public void setNeedSetup(boolean setup) { | ||||
|         this.needSetup = setup; | ||||
|     } | ||||
| 
 | ||||
|     public SetupCommand(HostEnvironment env) { | ||||
|         this.env = env; | ||||
|         this.multipath = false; | ||||
|         this.needSetup = false; | ||||
|     } | ||||
|      | ||||
|     public HostEnvironment getEnvironment() { | ||||
|  | ||||
| @ -262,7 +262,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe | ||||
|     protected IAgentControl _agentControl; | ||||
| 
 | ||||
|     final int _maxWeight = 256; | ||||
| 
 | ||||
|     protected int _heartbeatInterval = 60; | ||||
|     protected final XsHost _host = new XsHost(); | ||||
| 
 | ||||
|     // Guest and Host Performance Statistics | ||||
| @ -1214,10 +1214,6 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     protected SetupAnswer execute(SetupCommand cmd) { | ||||
|         return new SetupAnswer(cmd, false); | ||||
|     } | ||||
| 
 | ||||
|     protected SetPortForwardingRulesAnswer execute(SetPortForwardingRulesCommand cmd) { | ||||
|         Connection conn = getConnection(); | ||||
|          | ||||
| @ -3685,9 +3681,6 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe | ||||
|             _privateNetworkName = privateNic.getNetworkRecord(conn).nameLabel; | ||||
|             _host.privatePif = privateNic.getPifRecord(conn).uuid; | ||||
|             _host.privateNetwork = privateNic.getNetworkRecord(conn).uuid;            | ||||
|              | ||||
|             _canBridgeFirewall = can_bridge_firewall(conn); | ||||
|              | ||||
|             _host.systemvmisouuid = null; | ||||
|              | ||||
|             XsLocalNetwork guestNic = null; | ||||
| @ -3861,7 +3854,6 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe | ||||
|     @Override | ||||
|     public StartupCommand[] initialize() throws IllegalArgumentException{ | ||||
|         Connection conn = getConnection(); | ||||
|         setupServer(conn); | ||||
|         if (!getHostInfo(conn)) { | ||||
|             s_logger.warn("Unable to get host information for " + _host.ip); | ||||
|             return null; | ||||
| @ -3888,8 +3880,169 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe | ||||
|         return new StartupCommand[] { cmd }; | ||||
|     } | ||||
|      | ||||
|     protected void setupServer(Connection conn) { | ||||
|         String version = CitrixResourceBase.class.getPackage().getImplementationVersion(); | ||||
|     private void cleanupTemplateSR(Connection conn) { | ||||
|         Set<PBD> pbds = null; | ||||
|         try { | ||||
|             Host host = Host.getByUuid(conn, _host.uuid); | ||||
|             pbds = host.getPBDs(conn); | ||||
|         } catch (XenAPIException e) { | ||||
|             s_logger.warn("Unable to get the SRs " + e.toString(), e); | ||||
|             throw new CloudRuntimeException("Unable to get SRs " + e.toString(), e); | ||||
|         } catch (Exception e) { | ||||
|             throw new CloudRuntimeException("Unable to get SRs " + e.getMessage(), e); | ||||
|         } | ||||
|         for (PBD pbd : pbds) { | ||||
|             SR sr = null; | ||||
|             SR.Record srRec = null; | ||||
|             try { | ||||
|                 sr = pbd.getSR(conn); | ||||
|                 srRec = sr.getRecord(conn); | ||||
|             } catch (Exception e) { | ||||
|                 s_logger.warn("pbd.getSR get Exception due to " + e.toString()); | ||||
|                 continue; | ||||
|             } | ||||
|             String type = srRec.type; | ||||
|             if (srRec.shared) { | ||||
|                 continue; | ||||
|             } | ||||
|             if (SRType.NFS.equals(type) || (SRType.ISO.equals(type) && srRec.nameDescription.contains("template"))) { | ||||
|                 try { | ||||
|                     pbd.unplug(conn); | ||||
|                     pbd.destroy(conn); | ||||
|                     sr.forget(conn); | ||||
|                 } catch (Exception e) { | ||||
|                     s_logger.warn("forget SR catch Exception due to " + e.toString()); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|      | ||||
|     protected SetupAnswer execute(SetupCommand cmd) { | ||||
|         Connection conn = getConnection(); | ||||
|         setupServer(conn); | ||||
|         try { | ||||
|             if (!setIptables(conn)) { | ||||
|                 s_logger.warn("set xenserver Iptable failed"); | ||||
|                 return null; | ||||
|             } | ||||
|             _canBridgeFirewall = can_bridge_firewall(conn); | ||||
|              | ||||
|             String result = callHostPluginPremium(conn, "heartbeat", "host", _host.uuid, "interval", Integer | ||||
|                     .toString(_heartbeatInterval)); | ||||
|             if (result == null || !result.contains("> DONE <")) { | ||||
|                 s_logger.warn("Unable to launch the heartbeat process on " + _host.ip); | ||||
|                 return null; | ||||
|             } | ||||
|             cleanupTemplateSR(conn); | ||||
|             Host host = Host.getByUuid(conn, _host.uuid); | ||||
|             try { | ||||
|                 if (cmd.useMultipath()) { | ||||
|                     // the config value is set to true | ||||
|                     host.addToOtherConfig(conn, "multipathing", "true"); | ||||
|                     host.addToOtherConfig(conn, "multipathhandle", "dmp"); | ||||
|                 } | ||||
| 
 | ||||
|             } catch (Types.MapDuplicateKey e) { | ||||
|                 s_logger.debug("multipath is already set"); | ||||
|             } | ||||
|             if (cmd.needSetup() ) { | ||||
|                 result = callHostPlugin(conn, "vmops", "setup_iscsi", "uuid", _host.uuid); | ||||
|                 if (!result.contains("> DONE <")) { | ||||
|                     s_logger.warn("Unable to setup iscsi: " + result); | ||||
|                     return new SetupAnswer(cmd, result); | ||||
|                 } | ||||
|      | ||||
|                 Pair<PIF, PIF.Record> mgmtPif = null; | ||||
|                 Set<PIF> hostPifs = host.getPIFs(conn); | ||||
|                 for (PIF pif : hostPifs) { | ||||
|                     PIF.Record rec = pif.getRecord(conn); | ||||
|                     if (rec.management) { | ||||
|                         if (rec.VLAN != null && rec.VLAN != -1) { | ||||
|                             String msg = new StringBuilder( | ||||
|                                     "Unsupported configuration.  Management network is on a VLAN.  host=").append( | ||||
|                                     _host.uuid).append("; pif=").append(rec.uuid).append("; vlan=").append(rec.VLAN) | ||||
|                                     .toString(); | ||||
|                             s_logger.warn(msg); | ||||
|                             return new SetupAnswer(cmd, msg); | ||||
|                         } | ||||
|                         if (s_logger.isDebugEnabled()) { | ||||
|                             s_logger.debug("Management network is on pif=" + rec.uuid); | ||||
|                         } | ||||
|                         mgmtPif = new Pair<PIF, PIF.Record>(pif, rec); | ||||
|                         break; | ||||
|                     } | ||||
|                 } | ||||
|      | ||||
|                 if (mgmtPif == null) { | ||||
|                     String msg = "Unable to find management network for " + _host.uuid; | ||||
|                     s_logger.warn(msg); | ||||
|                     return new SetupAnswer(cmd, msg); | ||||
|                 } | ||||
|      | ||||
|                 Map<Network, Network.Record> networks = Network.getAllRecords(conn); | ||||
|                 for (Network.Record network : networks.values()) { | ||||
|                     if (network.nameLabel.equals("cloud-private")) { | ||||
|                         for (PIF pif : network.PIFs) { | ||||
|                             PIF.Record pr = pif.getRecord(conn); | ||||
|                             if (_host.uuid.equals(pr.host.getUuid(conn))) { | ||||
|                                 if (s_logger.isDebugEnabled()) { | ||||
|                                     s_logger.debug("Found a network called cloud-private. host=" + _host.uuid | ||||
|                                             + ";  Network=" + network.uuid + "; pif=" + pr.uuid); | ||||
|                                 } | ||||
|                                 if (pr.VLAN != null && pr.VLAN != -1) { | ||||
|                                     String msg = new StringBuilder( | ||||
|                                             "Unsupported configuration.  Network cloud-private is on a VLAN.  Network=") | ||||
|                                             .append(network.uuid).append(" ; pif=").append(pr.uuid).toString(); | ||||
|                                     s_logger.warn(msg); | ||||
|                                     return new SetupAnswer(cmd, msg); | ||||
|                                 } | ||||
|                                 if (!pr.management && pr.bondMasterOf != null && pr.bondMasterOf.size() > 0) { | ||||
|                                     if (pr.bondMasterOf.size() > 1) { | ||||
|                                         String msg = new StringBuilder( | ||||
|                                                 "Unsupported configuration.  Network cloud-private has more than one bond.  Network=") | ||||
|                                                 .append(network.uuid).append("; pif=").append(pr.uuid).toString(); | ||||
|                                         s_logger.warn(msg); | ||||
|                                         return new SetupAnswer(cmd, msg); | ||||
|                                     } | ||||
|                                     Bond bond = pr.bondMasterOf.iterator().next(); | ||||
|                                     Set<PIF> slaves = bond.getSlaves(conn); | ||||
|                                     for (PIF slave : slaves) { | ||||
|                                         PIF.Record spr = slave.getRecord(conn); | ||||
|                                         if (spr.management) { | ||||
|                                             if (!transferManagementNetwork(conn, host, slave, spr, pif)) { | ||||
|                                                 String msg = new StringBuilder( | ||||
|                                                         "Unable to transfer management network.  slave=" + spr.uuid | ||||
|                                                                 + "; master=" + pr.uuid + "; host=" + _host.uuid) | ||||
|                                                         .toString(); | ||||
|                                                 s_logger.warn(msg); | ||||
|                                                 return new SetupAnswer(cmd, msg); | ||||
|                                             } | ||||
|                                             break; | ||||
|                                         } | ||||
|                                     } | ||||
|                                 } | ||||
|                             } | ||||
|                         } | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
|             return new SetupAnswer(cmd, false); | ||||
| 
 | ||||
|         } catch (XmlRpcException e) { | ||||
|             s_logger.warn("Unable to setup", e); | ||||
|             return new SetupAnswer(cmd, e.getMessage()); | ||||
|         } catch (XenAPIException e) { | ||||
|             s_logger.warn("Unable to setup", e); | ||||
|             return new SetupAnswer(cmd, e.getMessage()); | ||||
|         } catch (Exception e) { | ||||
|             s_logger.warn("Unable to setup", e); | ||||
|             return new SetupAnswer(cmd, e.getMessage()); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     /* return : if setup is needed */ | ||||
|     protected boolean setupServer(Connection conn) { | ||||
|         String version = this.getClass().getName() + "-" + CitrixResourceBase.class.getPackage().getImplementationVersion(); | ||||
| 
 | ||||
|         try { | ||||
|             Host host = Host.getByUuid(conn, _host.uuid); | ||||
| @ -3905,7 +4058,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe | ||||
|                 if (tag.startsWith("vmops-version-")) { | ||||
|                     if (tag.contains(version)) { | ||||
|                         s_logger.info(logX(host, "Host " + hr.address + " is already setup.")); | ||||
|                         return; | ||||
|                         return false; | ||||
|                     } else { | ||||
|                         it.remove(); | ||||
|                     } | ||||
| @ -3979,6 +4132,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe | ||||
|             } | ||||
|             hr.tags.add("vmops-version-" + version); | ||||
|             host.setTags(conn, hr.tags); | ||||
|             return true; | ||||
|         } catch (XenAPIException e) { | ||||
|             String msg = "Xen setup failed due to " + e.toString(); | ||||
|             s_logger.warn(msg, e); | ||||
| @ -4455,6 +4609,11 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe | ||||
|             if (details == null) { | ||||
|                 details = new HashMap<String, String>(); | ||||
|             } | ||||
|             details.put("product_brand", hr.softwareVersion.get("product_brand")); | ||||
|             details.put("product_version", hr.softwareVersion.get("product_version")); | ||||
|             if( hr.softwareVersion.get("product_version_text_short") != null ) { | ||||
|                 details.put("product_version_text_short", hr.softwareVersion.get("product_version_text_short")); | ||||
|             } | ||||
|             if (_privateNetworkName != null) { | ||||
|             details.put("private.network.device", _privateNetworkName); | ||||
|             } | ||||
| @ -4584,6 +4743,8 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe | ||||
|         _storageNetworkName1 = (String) params.get("storage.network.device1"); | ||||
|         _storageNetworkName2 = (String) params.get("storage.network.device2"); | ||||
| 
 | ||||
|         _heartbeatInterval = NumbersUtil.parseInt((String) params.get("xen.heartbeat.interval"), 60); | ||||
|          | ||||
|         String value = (String) params.get("wait"); | ||||
|         _wait = NumbersUtil.parseInt(value, 600); | ||||
| 
 | ||||
|  | ||||
| @ -40,8 +40,6 @@ import com.cloud.agent.api.FenceCommand; | ||||
| import com.cloud.agent.api.NetworkUsageAnswer; | ||||
| import com.cloud.agent.api.NetworkUsageCommand; | ||||
| import com.cloud.agent.api.PoolEjectCommand; | ||||
| import com.cloud.agent.api.SetupAnswer; | ||||
| import com.cloud.agent.api.SetupCommand; | ||||
| import com.cloud.agent.api.StartupCommand; | ||||
| import com.cloud.resource.ServerResource; | ||||
| import com.cloud.utils.NumbersUtil; | ||||
| @ -64,7 +62,6 @@ import com.xensource.xenapi.VM; | ||||
| @Local(value = ServerResource.class) | ||||
| public class XenServer56Resource extends CitrixResourceBase { | ||||
|     private final static Logger s_logger = Logger.getLogger(XenServer56Resource.class); | ||||
|     protected int _heartbeatInterval = 60; | ||||
| 
 | ||||
|     @Override | ||||
|     public Answer executeRequest(Command cmd) { | ||||
| @ -271,169 +268,10 @@ public class XenServer56Resource extends CitrixResourceBase { | ||||
|         return true; | ||||
|     } | ||||
|      | ||||
|     @Override | ||||
|     protected SetupAnswer execute(SetupCommand cmd) { | ||||
|         Connection conn = getConnection(); | ||||
|         try { | ||||
|             cleanupTemplateSR(conn); | ||||
|             Host host = Host.getByUuid(conn, _host.uuid); | ||||
|             try { | ||||
|                 if (cmd.useMultipath()) { | ||||
|                     // the config value is set to true | ||||
|                     host.addToOtherConfig(conn, "multipathing", "true"); | ||||
|                     host.addToOtherConfig(conn, "multipathhandle", "dmp"); | ||||
|                 } | ||||
| 
 | ||||
|             } catch (Types.MapDuplicateKey e) { | ||||
|                 s_logger.debug("multipath is already set"); | ||||
|             } | ||||
| 
 | ||||
|             String result = callHostPlugin(conn, "vmops", "setup_iscsi", "uuid", _host.uuid); | ||||
|             if (!result.contains("> DONE <")) { | ||||
|                 s_logger.warn("Unable to setup iscsi: " + result); | ||||
|                 return new SetupAnswer(cmd, result); | ||||
|             } | ||||
| 
 | ||||
|             Pair<PIF, PIF.Record> mgmtPif = null; | ||||
|             Set<PIF> hostPifs = host.getPIFs(conn); | ||||
|             for (PIF pif : hostPifs) { | ||||
|                 PIF.Record rec = pif.getRecord(conn); | ||||
|                 if (rec.management) { | ||||
|                     if (rec.VLAN != null && rec.VLAN != -1) { | ||||
|                         String msg = new StringBuilder( | ||||
|                                 "Unsupported configuration.  Management network is on a VLAN.  host=").append( | ||||
|                                 _host.uuid).append("; pif=").append(rec.uuid).append("; vlan=").append(rec.VLAN) | ||||
|                                 .toString(); | ||||
|                         s_logger.warn(msg); | ||||
|                         return new SetupAnswer(cmd, msg); | ||||
|                     } | ||||
|                     if (s_logger.isDebugEnabled()) { | ||||
|                         s_logger.debug("Management network is on pif=" + rec.uuid); | ||||
|                     } | ||||
|                     mgmtPif = new Pair<PIF, PIF.Record>(pif, rec); | ||||
|                     break; | ||||
|                 } | ||||
|             } | ||||
| 
 | ||||
|             if (mgmtPif == null) { | ||||
|                 String msg = "Unable to find management network for " + _host.uuid; | ||||
|                 s_logger.warn(msg); | ||||
|                 return new SetupAnswer(cmd, msg); | ||||
|             } | ||||
| 
 | ||||
|             Map<Network, Network.Record> networks = Network.getAllRecords(conn); | ||||
|             for (Network.Record network : networks.values()) { | ||||
|                 if (network.nameLabel.equals("cloud-private")) { | ||||
|                     for (PIF pif : network.PIFs) { | ||||
|                         PIF.Record pr = pif.getRecord(conn); | ||||
|                         if (_host.uuid.equals(pr.host.getUuid(conn))) { | ||||
|                             if (s_logger.isDebugEnabled()) { | ||||
|                                 s_logger.debug("Found a network called cloud-private. host=" + _host.uuid | ||||
|                                         + ";  Network=" + network.uuid + "; pif=" + pr.uuid); | ||||
|                             } | ||||
|                             if (pr.VLAN != null && pr.VLAN != -1) { | ||||
|                                 String msg = new StringBuilder( | ||||
|                                         "Unsupported configuration.  Network cloud-private is on a VLAN.  Network=") | ||||
|                                         .append(network.uuid).append(" ; pif=").append(pr.uuid).toString(); | ||||
|                                 s_logger.warn(msg); | ||||
|                                 return new SetupAnswer(cmd, msg); | ||||
|                             } | ||||
|                             if (!pr.management && pr.bondMasterOf != null && pr.bondMasterOf.size() > 0) { | ||||
|                                 if (pr.bondMasterOf.size() > 1) { | ||||
|                                     String msg = new StringBuilder( | ||||
|                                             "Unsupported configuration.  Network cloud-private has more than one bond.  Network=") | ||||
|                                             .append(network.uuid).append("; pif=").append(pr.uuid).toString(); | ||||
|                                     s_logger.warn(msg); | ||||
|                                     return new SetupAnswer(cmd, msg); | ||||
|                                 } | ||||
|                                 Bond bond = pr.bondMasterOf.iterator().next(); | ||||
|                                 Set<PIF> slaves = bond.getSlaves(conn); | ||||
|                                 for (PIF slave : slaves) { | ||||
|                                     PIF.Record spr = slave.getRecord(conn); | ||||
|                                     if (spr.management) { | ||||
|                                         if (!transferManagementNetwork(conn, host, slave, spr, pif)) { | ||||
|                                             String msg = new StringBuilder( | ||||
|                                                     "Unable to transfer management network.  slave=" + spr.uuid | ||||
|                                                             + "; master=" + pr.uuid + "; host=" + _host.uuid) | ||||
|                                                     .toString(); | ||||
|                                             s_logger.warn(msg); | ||||
|                                             return new SetupAnswer(cmd, msg); | ||||
|                                         } | ||||
|                                         break; | ||||
|                                     } | ||||
|                                 } | ||||
|                             } | ||||
|                         } | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
|             return new SetupAnswer(cmd, false); | ||||
| 
 | ||||
|         } catch (XmlRpcException e) { | ||||
|             s_logger.warn("Unable to setup", e); | ||||
|             return new SetupAnswer(cmd, e.getMessage()); | ||||
|         } catch (XenAPIException e) { | ||||
|             s_logger.warn("Unable to setup", e); | ||||
|             return new SetupAnswer(cmd, e.getMessage()); | ||||
|         } catch (Exception e) { | ||||
|             s_logger.warn("Unable to setup", e); | ||||
|             return new SetupAnswer(cmd, e.getMessage()); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     private void cleanupTemplateSR(Connection conn) { | ||||
|         Set<PBD> pbds = null; | ||||
|         try { | ||||
|             Host host = Host.getByUuid(conn, _host.uuid); | ||||
|             pbds = host.getPBDs(conn); | ||||
|         } catch (XenAPIException e) { | ||||
|             s_logger.warn("Unable to get the SRs " + e.toString(), e); | ||||
|             throw new CloudRuntimeException("Unable to get SRs " + e.toString(), e); | ||||
|         } catch (Exception e) { | ||||
|             throw new CloudRuntimeException("Unable to get SRs " + e.getMessage(), e); | ||||
|         } | ||||
|         for (PBD pbd : pbds) { | ||||
|             SR sr = null; | ||||
|             SR.Record srRec = null; | ||||
|             try { | ||||
|                 sr = pbd.getSR(conn); | ||||
|                 srRec = sr.getRecord(conn); | ||||
|             } catch (Exception e) { | ||||
|                 s_logger.warn("pbd.getSR get Exception due to " + e.toString()); | ||||
|                 continue; | ||||
|             } | ||||
|             String type = srRec.type; | ||||
|             if (srRec.shared) { | ||||
|                 continue; | ||||
|             } | ||||
|             if (SRType.NFS.equals(type) || (SRType.ISO.equals(type) && srRec.nameDescription.contains("template"))) { | ||||
|                 try { | ||||
|                     pbd.unplug(conn); | ||||
|                     pbd.destroy(conn); | ||||
|                     sr.forget(conn); | ||||
|                 } catch (Exception e) { | ||||
|                     s_logger.warn("forget SR catch Exception due to " + e.toString()); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     public StartupCommand[] initialize() { | ||||
|         pingXenServer(); | ||||
|         StartupCommand[] cmds = super.initialize(); | ||||
|         Connection conn = getConnection(); | ||||
|         if (!setIptables(conn)) { | ||||
|             s_logger.warn("set xenserver Iptable failed"); | ||||
|             return null; | ||||
|         } | ||||
| 
 | ||||
|         String result = callHostPluginPremium(conn, "heartbeat", "host", _host.uuid, "interval", Integer | ||||
|                 .toString(_heartbeatInterval)); | ||||
|         if (result == null || !result.contains("> DONE <")) { | ||||
|             s_logger.warn("Unable to launch the heartbeat process on " + _host.ip); | ||||
|             return null; | ||||
|         } | ||||
|         return cmds; | ||||
|     } | ||||
| 
 | ||||
| @ -464,14 +302,4 @@ public class XenServer56Resource extends CitrixResourceBase { | ||||
|         super(); | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     public boolean configure(String name, Map<String, Object> params) throws ConfigurationException { | ||||
|         super.configure(name, params); | ||||
| 
 | ||||
|         _heartbeatInterval = NumbersUtil.parseInt((String) params.get("xen.heartbeat.interval"), 60); | ||||
|         // xapi connection timeout 600 seconds | ||||
|         _wait = 600; | ||||
| 
 | ||||
|         return true; | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -515,9 +515,37 @@ public class XcpServerDiscoverer extends DiscovererBase implements Discoverer, L | ||||
|             s_logger.warn(msg); | ||||
|             throw new CloudRuntimeException(msg); | ||||
|         } | ||||
|         if (host.isSetup()) { | ||||
|             return; | ||||
|         String resource = null; | ||||
|         Map<String, String> details = startup.getHostDetails(); | ||||
|         String prodBrand = details.get("product_brand").trim(); | ||||
|         String prodVersion = details.get("product_version").trim(); | ||||
|          | ||||
|         if(prodBrand.equals("XenCloudPlatform") && prodVersion.equals("0.1.1")) { | ||||
|             resource = XcpServerResource.class.getName(); | ||||
|         } else if(prodBrand.equals("XenServer") && prodVersion.equals("5.6.0")) { | ||||
|             resource = XenServer56Resource.class.getName(); | ||||
|         } else if(prodBrand.equals("XenServer") && prodVersion.equals("5.6.100"))  { | ||||
|             String prodVersionTextShort = details.get("product_version_text_short").trim(); | ||||
|             if("5.6 SP2".equals(prodVersionTextShort)) { | ||||
|                 resource = XenServer56SP2Resource.class.getName(); | ||||
|             } else if("5.6 FP1".equals(prodVersionTextShort)) { | ||||
|                 resource = XenServer56FP1Resource.class.getName(); | ||||
|             } | ||||
|         } | ||||
|         if( resource == null ){ | ||||
|             String msg = "Only support XCP 0.1.1, XenServer 5.6,  XenServer 5.6 FP1 and XenServer 5.6 SP2, but this one is " + prodBrand + " " + prodVersion; | ||||
|             s_logger.debug(msg); | ||||
|             throw new RuntimeException(msg); | ||||
|         } | ||||
|         if (! resource.equals(host.getResource()) ) { | ||||
|             host.setResource(resource); | ||||
|             host.setSetup(false); | ||||
|             _hostDao.update(agentId, host); | ||||
|             String msg = "host " + host.getPrivateIpAddress() + " changed from " + host.getResource() + " to " + resource; | ||||
|             s_logger.debug(msg); | ||||
|             throw new RuntimeException(msg); | ||||
|         } | ||||
|          | ||||
|          | ||||
|         if (s_logger.isDebugEnabled()) { | ||||
|             s_logger.debug("Setting up host " + agentId); | ||||
| @ -528,6 +556,10 @@ public class XcpServerDiscoverer extends DiscovererBase implements Discoverer, L | ||||
|         if (_setupMultipath) { | ||||
|             setup.setMultipathOn(); | ||||
|         } | ||||
|         if (!host.isSetup()) { | ||||
|             setup.setNeedSetup(true); | ||||
|         } | ||||
|          | ||||
|         try { | ||||
|             SetupAnswer answer = (SetupAnswer)_agentMgr.send(agentId, setup); | ||||
|             if (answer != null && answer.getResult()) { | ||||
|  | ||||
| @ -197,6 +197,9 @@ public class StatsCollector { | ||||
| 				sc.addAnd("type", SearchCriteria.Op.NEQ, Host.Type.Storage.toString()); | ||||
| 				sc.addAnd("type", SearchCriteria.Op.NEQ, Host.Type.ConsoleProxy.toString()); | ||||
| 				sc.addAnd("type", SearchCriteria.Op.NEQ, Host.Type.SecondaryStorage.toString()); | ||||
|                 sc.addAnd("type", SearchCriteria.Op.NEQ, Host.Type.LocalSecondaryStorage.toString()); | ||||
|                 sc.addAnd("type", SearchCriteria.Op.NEQ, Host.Type.TrafficMonitor.toString()); | ||||
|                 sc.addAnd("type", SearchCriteria.Op.NEQ, Host.Type.SecondaryStorageVM.toString()); | ||||
| 				List<HostVO> hosts = _hostDao.search(sc, null); | ||||
| 				 | ||||
| 				for (HostVO host : hosts) { | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user