You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cloudstack.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2017/10/25 05:28:00 UTC

[jira] [Commented] (CLOUDSTACK-10047) DVSwitch improvements

    [ https://issues.apache.org/jira/browse/CLOUDSTACK-10047?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16218116#comment-16218116 ] 

ASF GitHub Bot commented on CLOUDSTACK-10047:
---------------------------------------------

rhtyd commented on a change in pull request #2293: CLOUDSTACK-10047: DVSwitch fixes and improvements
URL: https://github.com/apache/cloudstack/pull/2293#discussion_r146757782
 
 

 ##########
 File path: utils/src/main/java/com/cloud/utils/UriUtils.java
 ##########
 @@ -391,4 +391,57 @@ public static InputStream getInputStreamFromUrl(String url, String user, String
             return null;
         }
     }
+
+    /**
+     * Expands a given vlan URI to a list of vlan IDs
+     * @param vlanAuthority the URI part without the vlan:// scheme
+     * @return returns list of vlan integer ids
+     */
+    public static List<Integer> expandVlanUri(final String vlanAuthority) {
+        final List<Integer> expandedVlans = new ArrayList<>();
+        if (vlanAuthority == null || vlanAuthority.isEmpty()) {
+            return expandedVlans;
+        }
+        for (final String vlanPart: vlanAuthority.split(",")) {
+            if (vlanPart == null || vlanPart.isEmpty()) {
+                continue;
+            }
+            final String[] range = vlanPart.split("-");
+            if (range.length == 2) {
+                Integer start = NumbersUtil.parseInt(range[0], -1);
+                Integer end = NumbersUtil.parseInt(range[1], -1);
+                if (start <= end && end > -1 && start > -1) {
+                    while (start <= end) {
+                        expandedVlans.add(start++);
+                    }
+                }
+            } else {
+                final Integer value = NumbersUtil.parseInt(range[0], -1);
+                if (value > -1) {
+                    expandedVlans.add(value);
+                }
+            }
+        }
+        return expandedVlans;
+    }
+
+    /**
+     * Checks if given vlan URI authorities overlap
+     * @param vlanRange1
+     * @param vlanRange2
+     * @return true if they overlap
+     */
+    public static boolean checkVlanUriOverlap(final String vlanRange1, final String vlanRange2) {
+        final List<Integer> vlans1 = expandVlanUri(vlanRange1);
+        final List<Integer> vlans2 = expandVlanUri(vlanRange2);
+        if (vlans1 == null || vlans2 == null) {
 
 Review comment:
   @fmaximus fixed.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


> DVSwitch improvements
> ---------------------
>
>                 Key: CLOUDSTACK-10047
>                 URL: https://issues.apache.org/jira/browse/CLOUDSTACK-10047
>             Project: CloudStack
>          Issue Type: Bug
>      Security Level: Public(Anyone can view this level - this is the default.) 
>            Reporter: Rohit Yadav
>            Assignee: Rohit Yadav
>             Fix For: Future, 4.11.0.0
>
>
> All vlan trunking and list of vlan id/range, along with security policy settings on dvswitches.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)