Damans227 commented on code in PR #13603:
URL: https://github.com/apache/cloudstack/pull/13603#discussion_r4389197102


##########
core/src/main/java/com/cloud/resource/ServerResourceBase.java:
##########
@@ -75,6 +80,12 @@ public boolean configure(final String name, Map<String, 
Object> params) throws C
 
         defineResourceNetworkInterfaces(params);
 
+        if (privateNic == null) {
+            checkForPrivateInterfaceDefinedByIp(params);

Review Comment:
   @EduFrazao on kvm the bridge name comes straight from agent.properties, so a 
bridge that exists gets picked even with no ip. then the new lookups never run 
and the agent fails to start. can we also run them when the picked bridge has 
no usable ip?



##########
core/src/main/java/com/cloud/resource/ServerResourceBase.java:
##########
@@ -106,8 +117,74 @@ protected void defineResourceNetworkInterfaces(Map<String, 
Object> params) {
         this.storageNic2 = NetUtils.getNetworkInterface(storageNic2);
     }
 
+    private void checkForPrivateInterfaceDefinedByIp(Map<String, Object> 
params) {
+        final String ifAddr = StringUtils.trimToNull((String) 
params.get("private.network.address"));
+        if (ifAddr != null) {
+            logger.debug(String.format("Trying to use private address to 
resolve interface: [%s]", ifAddr));
+            try {
+                InetAddress rawAddr = 
InetAddress.getByAddress(InetAddress.getByName(ifAddr).getAddress());
+                final NetworkInterface nic = 
NetworkInterface.getByInetAddress(rawAddr);
+                if (nic != null) {
+                    logger.info("Using NIC [{}] as private NIC. Source: 
InterfaceAddress [{}]", nic, ifAddr);
+                    privateNic = nic;
+                } else {
+                    logger.info("Unable to found private NIC with defined ip 
[{}]", ifAddr);
+                }
+            } catch (Exception e) {
+                 // Logging only, if this method was unable to find a valid 
interface, iteration will be tested
+                logger.info("Unable to use private address to get the 
management interface: [{}]", e.getMessage());
+            }
+        }
+    }
+
+    private String[] collectMgmtHostIp(Map<String, Object> params) {
+        final String hosts = (String) params.get("host");
+        if (hosts != null && hosts.trim().length() > 0) {
+            logger.info(String.format("Parsing host setting: [%s]", hosts));
+            final Set<String> hostCollection = new LinkedHashSet<String>();
+            if (hosts.contains(",")) {
+                for(final String ip : hosts.split(",")) {
+                    final String h = ip.contains("@") ? ip.split("@")[0] : ip;
+                    hostCollection.add(h.trim());
+                }
+            } else {
+                hostCollection.add(hosts.trim());

Review Comment:
   that covers it, thanks



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to