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


##########
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:
   does this run when the bridge in private.network.device exists but has no 
ip? looks like it gets skipped, so the case in the description still fails



##########
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:
   what happens with a single management server? the agent saves it as 
ip@static, so this tries to reach that whole string and the lookup always fails



-- 
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