CORD-357 Fixed not to pop or push s-tag

And also remove vSG related rules when vSG VM destroyed

Change-Id: I3cecd558a0d84f882bea9ce849568a7be8380330
diff --git a/src/main/java/org/onosproject/cordvtn/CordVtnRuleInstaller.java b/src/main/java/org/onosproject/cordvtn/CordVtnRuleInstaller.java
index 877ec30..afd6b2c 100644
--- a/src/main/java/org/onosproject/cordvtn/CordVtnRuleInstaller.java
+++ b/src/main/java/org/onosproject/cordvtn/CordVtnRuleInstaller.java
@@ -213,7 +213,7 @@
     }
 
     /**
-     * Removes basic rules related to a given flow information.
+     * Removes all rules related to a given service VM host.
      *
      * @param host host to be removed
      */
@@ -236,6 +236,11 @@
                     processFlowRule(false, flowRule);
                     continue;
                 }
+
+                PortNumber output = getOutputFromTreatment(flowRule);
+                if (output != null && output.equals(host.location().port())) {
+                    processFlowRule(false, flowRule);
+                }
             }
 
             MacAddress dstMac = getDstMacFromTreatment(flowRule);
@@ -519,17 +524,7 @@
         if (!mastershipService.isLocalMaster(host.location().deviceId())) {
             return;
         }
-
-        for (FlowRule flowRule : flowRuleService.getFlowRulesById(appId)) {
-            if (flowRule.deviceId().equals(host.location().deviceId())) {
-                PortNumber port = getOutputFromTreatment(flowRule);
-                if (port != null && port.equals(host.location().port())) {
-                    processFlowRule(false, flowRule);
-                }
-            }
-
-            // TODO remove the other rules if mgmt network is not in use
-        }
+        // TODO remove management network specific rules
     }
 
     /**
@@ -549,11 +544,11 @@
 
         // for traffics with s-tag, strip the tag and take through the vSG VM
         TrafficSelector selector = DefaultTrafficSelector.builder()
+                .matchInPort(dpPort)
                 .matchVlanId(serviceVlan)
                 .build();
 
         TrafficTreatment treatment = DefaultTrafficTreatment.builder()
-                .popVlan()
                 .setOutput(vSgHost.location().port())
                 .build();
 
@@ -573,11 +568,10 @@
         // lower priority to avoid conflict with WAN tag
         selector = DefaultTrafficSelector.builder()
                 .matchInPort(vSgHost.location().port())
+                .matchVlanId(serviceVlan)
                 .build();
 
         treatment = DefaultTrafficTreatment.builder()
-                .pushVlan()
-                .setVlanId(serviceVlan)
                 .setOutput(dpPort)
                 .build();
 
@@ -585,7 +579,7 @@
                 .fromApp(appId)
                 .withSelector(selector)
                 .withTreatment(treatment)
-                .withPriority(LOW_PRIORITY)
+                .withPriority(DEFAULT_PRIORITY)
                 .forDevice(vSgHost.location().deviceId())
                 .forTable(TABLE_Q_IN_Q)
                 .makePermanent()