1616// under the License.
1717package com .cloud .hypervisor .xenserver .discoverer ;
1818
19+ import java .net .InetAddress ;
20+ import java .net .URI ;
21+ import java .net .UnknownHostException ;
22+ import java .util .HashMap ;
23+ import java .util .LinkedList ;
24+ import java .util .List ;
25+ import java .util .Map ;
26+ import java .util .Queue ;
27+ import java .util .Set ;
28+
29+ import javax .inject .Inject ;
30+ import javax .naming .ConfigurationException ;
31+ import javax .persistence .EntityExistsException ;
32+
33+ import org .apache .cloudstack .hypervisor .xenserver .XenserverConfigs ;
34+ import org .apache .log4j .Logger ;
35+ import org .apache .xmlrpc .XmlRpcException ;
36+
1937import com .cloud .agent .AgentManager ;
2038import com .cloud .agent .Listener ;
2139import com .cloud .agent .api .AgentControlAnswer ;
8199import com .xensource .xenapi .Types .SessionAuthenticationFailed ;
82100import com .xensource .xenapi .Types .UuidInvalid ;
83101import com .xensource .xenapi .Types .XenAPIException ;
84- import org .apache .cloudstack .hypervisor .xenserver .XenserverConfigs ;
85- import org .apache .log4j .Logger ;
86- import org .apache .xmlrpc .XmlRpcException ;
87-
88- import javax .inject .Inject ;
89- import javax .naming .ConfigurationException ;
90- import javax .persistence .EntityExistsException ;
91- import java .net .InetAddress ;
92- import java .net .URI ;
93- import java .net .UnknownHostException ;
94- import java .util .HashMap ;
95- import java .util .LinkedList ;
96- import java .util .List ;
97- import java .util .Map ;
98- import java .util .Queue ;
99- import java .util .Set ;
100102
101103
102104public class XcpServerDiscoverer extends DiscovererBase implements Discoverer , Listener , ResourceStateAdapter {
103105 private static final Logger s_logger = Logger .getLogger (XcpServerDiscoverer .class );
104- protected String _publicNic ;
105- protected String _privateNic ;
106- protected String _storageNic1 ;
107- protected String _storageNic2 ;
108- protected int _wait ;
109- protected XenServerConnectionPool _connPool ;
110- protected boolean _checkHvm ;
111- protected String _guestNic ;
112- protected boolean _setupMultipath ;
113- protected String _instance ;
106+ private int _wait ;
107+ private XenServerConnectionPool _connPool ;
108+ private boolean _checkHvm ;
109+ private boolean _setupMultipath ;
110+ private String _instance ;
114111
115112 @ Inject
116- protected AlertManager _alertMgr ;
113+ private AlertManager _alertMgr ;
117114 @ Inject
118- protected AgentManager _agentMgr ;
115+ private AgentManager _agentMgr ;
119116 @ Inject
120117 private VMTemplateDao _tmpltDao ;
121118 @ Inject
122119 private HostPodDao _podDao ;
123120
124- private static String XENSERVER_ISO_NAME = "xs-tools.iso" ;
125- private static String XENSERVER_ISO_DISPLAY_TEXT = "XenServer Tools Installer ISO (xen-pv-drv-iso)" ;
126-
121+ private final String XENSERVER_ISO_NAME = "xs-tools.iso" ;
122+ private final String XENSERVER_ISO_DISPLAY_TEXT = "XenServer Tools Installer ISO (xen-pv-drv-iso)" ;
123+
127124 protected XcpServerDiscoverer () {
128125 }
129126
@@ -201,8 +198,9 @@ protected boolean poolHasHotFix(Connection conn, String hostIp, String hotFixUui
201198
202199 ClusterVO cluster = _clusterDao .findById (clusterId );
203200 if (cluster == null || cluster .getHypervisorType () != HypervisorType .XenServer ) {
204- if (s_logger .isInfoEnabled ())
201+ if (s_logger .isInfoEnabled ()) {
205202 s_logger .info ("invalid cluster id or cluster is not for XenServer hypervisors" );
203+ }
206204 return null ;
207205 }
208206
@@ -240,7 +238,7 @@ protected boolean poolHasHotFix(Connection conn, String hostIp, String hotFixUui
240238 if (clusterHosts != null && clusterHosts .size () > 0 ) {
241239 if (!clu .getGuid ().equals (poolUuid )) {
242240 String msg = "Please join the host " + hostIp + " to XS pool "
243- + clu .getGuid () + " through XC/XS before adding it through CS UI" ;
241+ + clu .getGuid () + " through XC/XS before adding it through CS UI" ;
244242 s_logger .warn (msg );
245243 throw new DiscoveryException (msg );
246244 }
@@ -398,18 +396,18 @@ protected void addSamePool(Connection conn, Map<CitrixResourceBase, Map<String,
398396 protected CitrixResourceBase createServerResource (String prodBrand , String prodVersion , String prodVersionTextShort , String hotfix ) {
399397 // Xen Cloud Platform group of hypervisors
400398 if (prodBrand .equals ("XCP" ) && (prodVersion .equals ("1.0.0" ) || prodVersion .equals ("1.1.0" )
401- || prodVersion .equals ("5.6.100" ) || prodVersion .startsWith ("1.4" ) || prodVersion .startsWith ("1.6" ))) {
399+ || prodVersion .equals ("5.6.100" ) || prodVersion .startsWith ("1.4" ) || prodVersion .startsWith ("1.6" ))) {
402400 return new XcpServerResource ();
403401 } // Citrix Xenserver group of hypervisors
404- else if (prodBrand .equals ("XenServer" ) && prodVersion .equals ("5.6.0" ))
402+ else if (prodBrand .equals ("XenServer" ) && prodVersion .equals ("5.6.0" )) {
405403 return new XenServer56Resource ();
406- else if (prodBrand .equals ("XenServer" ) && prodVersion .equals ("6.0.0" ))
404+ } else if (prodBrand .equals ("XenServer" ) && prodVersion .equals ("6.0.0" )) {
407405 return new XenServer600Resource ();
408- else if (prodBrand .equals ("XenServer" ) && prodVersion .equals ("6.0.2" ))
406+ } else if (prodBrand .equals ("XenServer" ) && prodVersion .equals ("6.0.2" )) {
409407 return new XenServer600Resource ();
410- else if (prodBrand .equals ("XenServer" ) && prodVersion .equals ("6.1.0" ))
408+ } else if (prodBrand .equals ("XenServer" ) && prodVersion .equals ("6.1.0" )) {
411409 return new XenServer610Resource ();
412- else if (prodBrand .equals ("XenServer" ) && prodVersion .equals ("6.2.0" )) {
410+ } else if (prodBrand .equals ("XenServer" ) && prodVersion .equals ("6.2.0" )) {
413411 if (hotfix != null && hotfix .equals (XenserverConfigs .XSHotFix62ESP1004 )) {
414412 return new Xenserver625Resource ();
415413 } else if (hotfix != null && hotfix .equals (XenserverConfigs .XSHotFix62ESP1 )) {
@@ -467,22 +465,11 @@ public boolean configure(String name, Map<String, Object> params) throws Configu
467465 super .configure (name , params );
468466 serverConfig ();
469467
470- _publicNic = _params .get (Config .XenServerPublicNetwork .key ());
471- _privateNic = _params .get (Config .XenServerPrivateNetwork .key ());
472-
473- _storageNic1 = _params .get (Config .XenServerStorageNetwork1 .key ());
474- _storageNic2 = _params .get (Config .XenServerStorageNetwork2 .key ());
475-
476- _guestNic = _params .get (Config .XenServerGuestNetwork .key ());
477-
478468 String value = _params .get (Config .XapiWait .toString ());
479469 _wait = NumbersUtil .parseInt (value , Integer .parseInt (Config .XapiWait .getDefaultValue ()));
480470
481471 _instance = _params .get (Config .InstanceName .key ());
482472
483- value = _params .get (Config .XenServerSetupMultipath .key ());
484- Boolean .parseBoolean (value );
485-
486473 value = _params .get ("xenserver.check.hvm" );
487474 _checkHvm = Boolean .parseBoolean (value );
488475 _connPool = XenServerConnectionPool .getInstance ();
@@ -496,8 +483,9 @@ public boolean configure(String name, Map<String, Object> params) throws Configu
496483
497484 @ Override
498485 public boolean matchHypervisor (String hypervisor ) {
499- if (hypervisor == null )
486+ if (hypervisor == null ) {
500487 return true ;
488+ }
501489 return Hypervisor .HypervisorType .XenServer .toString ().equalsIgnoreCase (hypervisor );
502490 }
503491
0 commit comments