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


##########
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 = (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(String.format("Using NIC [%s] as private NIC. 
Source: InterfaceAddress [%s]", nic, ifAddr));
+                    privateNic = nic;
+                } else {
+                    logger.info(String.format("Unable to found private NIC 
with defined ip [%s]", ifAddr));
+                }
+            } catch (Throwable e) {
+                 // Logging only, if this method was unnable to find a valid 
interface, iteration will be tested
+                logger.info(String.format("Unable to use private address to 
get the management interface: [%s]", 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());
+            }
+            return hostCollection.isEmpty() ? null : 
hostCollection.toArray(new String[0]);
+        }
+        return null;
+    }
+
+    protected void 
tryToAutoDiscoverResourcePrivateNetworkInterfaceByRouteLookup(Map<String, 
Object> params) throws ConfigurationException {

Review Comment:
   > @EduFrazao , why make this protected (and not private)?
   
   Hi @DaanHoogland 
   I followed the design of tryToAutoDiscoverResourcePrivateNetworkInterface, 
but you are right, this is a local implementation only. I will change this 
access modifier and push this commit tonight.



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