samuel
Committed by Gerrit Code Review

[ONOS-1959][ONOS-2007][ONOS-2008][ONOS-2009][ONOS-2010][ONOS-2011][ONOS-2016][ONOS-2017][ONOS-2018]

1.fix bug in query subscription command in Tunnel management
2.add RemoveTunnelByIdCommand
3.add UpdateTunnelBandWithCommand
4.add QueryAllTunnelsCommand
5.add queryAllTunnels api in TunnelService and TunnelStore
6.store the Path of the tunnel in the store
7.remove to check parameters iif they are null in the construtors of
DefaultTunnel.e.g
8.add the method of querying in SB
9.Fix the bug that the src/dst end point of Vlan-type tunnel is the
instance of OpticalTunnelEndPoint
10. invert the verb-noun into noun-verb for tunnel commands and label
commands

Change-Id: I90378b37c2bc73b58e6f8f234f009d64f07f758e
Showing 37 changed files with 440 additions and 262 deletions
/*
* Copyright 2014-2015 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.cli.net;
import java.util.Collection;
......@@ -10,9 +25,9 @@ import org.onosproject.incubator.net.resource.label.DefaultLabelResource;
import org.onosproject.incubator.net.resource.label.LabelResource;
import org.onosproject.incubator.net.resource.label.LabelResourceService;
@Command(scope = "onos", name = "apply-global-label-resource-pool",
@Command(scope = "onos", name = "global-label-apply",
description = "Apply global labels from global resource pool")
public class ApplyGlobalLabelResourceCommand extends AbstractShellCommand {
public class GlobalLabelApplyCommand extends AbstractShellCommand {
@Argument(index = 0, name = "applyNum",
description = "Applying number means how many labels applications want to use.",
required = true, multiValued = false)
......
/*
* Copyright 2014-2015 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.cli.net;
import org.apache.karaf.shell.commands.Command;
......@@ -5,9 +20,9 @@ import org.onosproject.cli.AbstractShellCommand;
import org.onosproject.incubator.net.resource.label.LabelResourcePool;
import org.onosproject.incubator.net.resource.label.LabelResourceService;
@Command(scope = "onos", name = "get-global-label-resource-pool",
@Command(scope = "onos", name = "global-label-pool",
description = "Gets global label resource pool information.")
public class GetGlobalLabelResourceCommand extends AbstractShellCommand {
public class GlobalLabelCommand extends AbstractShellCommand {
private static final String FMT = "deviceid=%s, beginLabel=%s,"
+ "endLabel=%s, totalNum=%s, usedNum=%s, currentUsedMaxLabelId=%s,"
+ "releaseLabelIds=%s";
......
/*
* Copyright 2014-2015 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.cli.net;
import org.apache.karaf.shell.commands.Argument;
......@@ -9,9 +24,9 @@ import org.onosproject.incubator.net.resource.label.LabelResourceId;
/**
* create label resource pool by specific device id.
*/
@Command(scope = "onos", name = "create-global-label-resource-pool",
@Command(scope = "onos", name = "global-label-pool-create",
description = "Creates global label resource pool.")
public class CreateGlobalLabelResourcePoolCommand extends AbstractShellCommand {
public class GlobalLabelPoolCreateCommand extends AbstractShellCommand {
@Argument(index = 0, name = "beginLabel",
description = "The first label of global label resource pool.",
required = true, multiValued = false)
......
/*
* Copyright 2014-2015 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.cli.net;
import org.apache.karaf.shell.commands.Command;
import org.onosproject.cli.AbstractShellCommand;
import org.onosproject.incubator.net.resource.label.LabelResourceAdminService;
@Command(scope = "onos", name = "destroy-global-label-resource-pool",
@Command(scope = "onos", name = "global-label-pool-destroy",
description = "Destroys global label resource pool")
public class DestroyGlobalLabelResourcePoolCommand extends AbstractShellCommand {
public class GlobalLabelPoolDestoryCommand extends AbstractShellCommand {
@Override
protected void execute() {
LabelResourceAdminService lrs = get(LabelResourceAdminService.class);
......
/*
* Copyright 2014-2015 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.cli.net;
import java.util.HashSet;
......@@ -9,9 +24,9 @@ import org.onosproject.cli.AbstractShellCommand;
import org.onosproject.incubator.net.resource.label.LabelResourceId;
import org.onosproject.incubator.net.resource.label.LabelResourceService;
@Command(scope = "onos", name = "release-global-label-resource-pool",
@Command(scope = "onos", name = "global-label-release",
description = "Releases labels to global label resource pool.")
public class ReleaseGlobalLabelResourceCommand extends AbstractShellCommand {
public class GlobalLabelReleaseCommand extends AbstractShellCommand {
@Argument(index = 0, name = "releaseLabelIds",
description = "Represents for the label ids that are released. They are splited by dot symbol",
required = true, multiValued = false)
......
/*
* Copyright 2014-2015 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.cli.net;
import java.util.Collection;
......@@ -11,9 +26,9 @@ import org.onosproject.incubator.net.resource.label.DefaultLabelResource;
import org.onosproject.incubator.net.resource.label.LabelResource;
import org.onosproject.incubator.net.resource.label.LabelResourceService;
@Command(scope = "onos", name = "apply-label-resource-pool",
@Command(scope = "onos", name = "label-apply",
description = "Apply label resource from device pool by specific device id")
public class ApplyLabelResourceCommand extends AbstractShellCommand {
public class LabelApplyCommand extends AbstractShellCommand {
@Argument(index = 0, name = "deviceId",
description = "Device identity",
required = true, multiValued = false)
......
/*
* Copyright 2014-2015 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.cli.net;
import org.apache.karaf.shell.commands.Argument;
......@@ -10,9 +25,9 @@ import org.onosproject.incubator.net.resource.label.LabelResourceId;
/**
* create label resource pool by specific device id.
*/
@Command(scope = "onos", name = "create-label-resource-pool",
@Command(scope = "onos", name = "label-pool-create",
description = "Creates label resource pool by a specific device id")
public class CreateLabelResourcePoolCommand extends AbstractShellCommand {
public class LabelPoolCreateCommand extends AbstractShellCommand {
@Argument(index = 0, name = "deviceId", description = "Device identity", required = true, multiValued = false)
String deviceId = null;
@Argument(index = 1, name = "beginLabel",
......
/*
* Copyright 2014-2015 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.cli.net;
import org.apache.karaf.shell.commands.Argument;
......@@ -6,9 +21,9 @@ import org.onosproject.cli.AbstractShellCommand;
import org.onosproject.net.DeviceId;
import org.onosproject.incubator.net.resource.label.LabelResourceAdminService;
@Command(scope = "onos", name = "destroy-label-resource-pool",
@Command(scope = "onos", name = "label-pool-destroy",
description = "Destroys label resource pool by a specific device id")
public class DestroyLabelResourcePoolCommand extends AbstractShellCommand {
public class LabelPoolDestroyCommand extends AbstractShellCommand {
@Argument(index = 0, name = "deviceId", description = "Device identity", required = true, multiValued = false)
String deviceId = null;
......
/*
* Copyright 2014-2015 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.cli.net;
import org.apache.karaf.shell.commands.Argument;
......@@ -12,9 +27,9 @@ import org.onosproject.incubator.net.resource.label.LabelResourceService;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Multimap;
@Command(scope = "onos", name = "release-label-resource-pool",
@Command(scope = "onos", name = "label-release",
description = "Releases label ids to label resource pool by a specific device id")
public class ReleaseLabelResourceCommand extends AbstractShellCommand {
public class LabelReleaseCommand extends AbstractShellCommand {
@Argument(index = 0, name = "deviceId",
description = "Device identity",
required = true, multiValued = false)
......
/*
* Copyright 2014-2015 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.cli.net;
import org.apache.karaf.shell.commands.Argument;
......@@ -7,9 +22,9 @@ import org.onosproject.net.DeviceId;
import org.onosproject.incubator.net.resource.label.LabelResourcePool;
import org.onosproject.incubator.net.resource.label.LabelResourceService;
@Command(scope = "onos", name = "get-label-resource-pool",
@Command(scope = "onos", name = "label-pool",
description = "Gets label resource pool information by a specific device id")
public class GetLabelResourceCommand extends AbstractShellCommand {
public class LabelResourceCommand extends AbstractShellCommand {
@Argument(index = 0, name = "deviceId",
description = "Device identity", required = true, multiValued = false)
String deviceId = null;
......
/*
* Copyright 2014-2015 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.cli.net;
import java.util.Optional;
import org.apache.karaf.shell.commands.Argument;
import org.apache.karaf.shell.commands.Command;
import org.onlab.packet.IpAddress;
import org.onosproject.cli.AbstractShellCommand;
import org.onosproject.net.DeviceId;
import org.onosproject.net.PortNumber;
import org.onosproject.net.provider.ProviderId;
import org.onosproject.incubator.net.tunnel.DefaultOpticalTunnelEndPoint;
import org.onosproject.incubator.net.tunnel.IpTunnelEndPoint;
import org.onosproject.incubator.net.tunnel.OpticalLogicId;
import org.onosproject.incubator.net.tunnel.OpticalTunnelEndPoint;
import org.onosproject.incubator.net.tunnel.TunnelAdminService;
import org.onosproject.incubator.net.tunnel.TunnelEndPoint;
/**
* Supports for deleting all tunnels by using IP address and optical as tunnel
* end point now. It's used by consumers.
*/
@Command(scope = "onos", name = "delete-tunnels", description = "Supports for deleting all tunnels by using IP address"
+ " and optical as tunnel end point now. It's used by consumers.")
public class TunnelDeleteCommand extends AbstractShellCommand {
static String applicationId = "DEFAULT_APP_ID";
@Argument(index = 0, name = "src", description = "Source tunnel point."
+ " Only supports for IpTunnelEndPoint and OpticalTunnelEndPoint as end point now."
+ " If deletess a ODUK or OCH type tunnel, the formatter of this argument is DeviceId-PortNumber."
+ " Otherwise src means IP address.", required = true, multiValued = false)
String src = null;
@Argument(index = 1, name = "dst", description = "Destination tunnel point."
+ " Only supports for IpTunnelEndPoint and OpticalTunnelEndPoint as end point now."
+ " If deletess a ODUK or OCH type tunnel, the formatter of this argument is DeviceId-PortNumber."
+ " Otherwise dst means IP address.", required = true, multiValued = false)
String dst = null;
@Argument(index = 2, name = "type", description = "The type of tunnels,"
+ " It includes MPLS, VLAN, VXLAN, GRE, ODUK, OCH", required = true, multiValued = false)
String type = null;
@Override
protected void execute() {
TunnelAdminService adminService = get(TunnelAdminService.class);
ProviderId producerName = new ProviderId("default",
"org.onosproject.provider.tunnel.default");
TunnelEndPoint srcPoint = null;
TunnelEndPoint dstPoint = null;
if ("MPLS".equals(type) || "VLAN".equals(type) || "VXLAN".equals(type) || "GRE".equals(type)) {
srcPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(src));
dstPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(dst));
} else if ("ODUK".equals(type) || "OCH".equals(type)) {
String[] srcArray = src.split("-");
String[] dstArray = dst.split("-");
srcPoint = new DefaultOpticalTunnelEndPoint(
producerName,
Optional.of(DeviceId
.deviceId(srcArray[0])),
Optional.of(PortNumber
.portNumber(srcArray[1])),
null,
OpticalTunnelEndPoint.Type.LAMBDA,
OpticalLogicId
.logicId(0),
true);
dstPoint = new DefaultOpticalTunnelEndPoint(
producerName,
Optional.of(DeviceId
.deviceId(dstArray[0])),
Optional.of(PortNumber
.portNumber(dstArray[1])),
null,
OpticalTunnelEndPoint.Type.LAMBDA,
OpticalLogicId
.logicId(0),
true);
} else {
print("Illegal tunnel type. Please input MPLS, VLAN, VXLAN, GRE, ODUK or OCH.");
return;
}
adminService.removeTunnels(srcPoint, dstPoint, producerName);
}
}
......@@ -29,7 +29,7 @@ import org.onosproject.incubator.net.tunnel.TunnelSubscription;
* Query all tunnel subscriptions of consumer by consumer id.
* It's used by consumers.
*/
@Command(scope = "onos", name = "query-tunnel-subscriptions",
@Command(scope = "onos", name = "tunnel-subscriptions",
description = "Query all request orders of consumer by consumer id. It's used by consumers.")
public class TunnelQuerySubscriptionCommand extends AbstractShellCommand {
@Argument(index = 0, name = "consumerId",
......
......@@ -338,40 +338,37 @@
</command>
<command>
<action class="org.onosproject.cli.net.GetGlobalLabelResourceCommand"/>
<action class="org.onosproject.cli.net.GlobalLabelCommand"/>
</command>
<command>
<action class="org.onosproject.cli.net.GetLabelResourceCommand"/>
<action class="org.onosproject.cli.net.LabelResourceCommand"/>
</command>
<command>
<action class="org.onosproject.cli.net.CreateGlobalLabelResourcePoolCommand"/>
<action class="org.onosproject.cli.net.GlobalLabelPoolCreateCommand"/>
</command>
<command>
<action class="org.onosproject.cli.net.CreateLabelResourcePoolCommand"/>
<action class="org.onosproject.cli.net.LabelPoolCreateCommand"/>
</command>
<command>
<action class="org.onosproject.cli.net.DestroyGlobalLabelResourcePoolCommand"/>
<action class="org.onosproject.cli.net.GlobalLabelPoolDestoryCommand"/>
</command>
<command>
<action class="org.onosproject.cli.net.DestroyGlobalLabelResourcePoolCommand"/>
<action class="org.onosproject.cli.net.LabelPoolDestroyCommand"/>
</command>
<command>
<action class="org.onosproject.cli.net.ReleaseGlobalLabelResourceCommand"/>
<action class="org.onosproject.cli.net.GlobalLabelReleaseCommand"/>
</command>
<command>
<action class="org.onosproject.cli.net.ReleaseLabelResourceCommand"/>
<action class="org.onosproject.cli.net.LabelReleaseCommand"/>
</command>
<command>
<action class="org.onosproject.cli.net.ApplyGlobalLabelResourceCommand"/>
<action class="org.onosproject.cli.net.GlobalLabelApplyCommand"/>
</command>
<command>
<action class="org.onosproject.cli.net.ApplyLabelResourceCommand"/>
<action class="org.onosproject.cli.net.LabelApplyCommand"/>
</command>
<!-- tunnel commands -->
<command>
<action class="org.onosproject.cli.net.TunnelDeleteCommand"/>
</command>
<command>
<action class="org.onosproject.cli.net.TunnelBorrowCommand"/>
</command>
<command>
......
......@@ -15,7 +15,6 @@
*/
package org.onosproject.incubator.net.tunnel;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.MoreObjects.toStringHelper;
import java.util.Objects;
......@@ -55,9 +54,6 @@ public class DefaultOpticalTunnelEndPoint extends AbstractModel implements Optic
Optional<PortNumber> number, Optional<OpticalTunnelEndPoint> parentPoint,
Type type, OpticalLogicId id, boolean isGlobal, Annotations... annotations) {
super(providerId, annotations);
checkNotNull(type, "type cannot be null");
checkNotNull(id, "id cannot be null");
checkNotNull(isGlobal, "isGlobal cannot be null");
this.elementId = elementId;
this.portNumber = number;
this.parentPoint = parentPoint;
......
/*
* Copyright 2015 Open Networking Laboratory
* Copyright 2014-2015 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -13,10 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.incubator.net.tunnel;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.MoreObjects.toStringHelper;
import java.util.Objects;
......@@ -25,6 +23,7 @@ import org.onosproject.core.DefaultGroupId;
import org.onosproject.net.AbstractModel;
import org.onosproject.net.Annotations;
import org.onosproject.net.NetworkResource;
import org.onosproject.net.Path;
import org.onosproject.net.provider.ProviderId;
/**
......@@ -43,6 +42,7 @@ public final class DefaultTunnel extends AbstractModel implements Tunnel {
private final TunnelId tunnelId; // tunnel identify generated by
// ONOS as primary key
private final TunnelName tunnelName; // name of a tunnel
private final Path path;
/**
* Creates an active infrastructure tunnel using the supplied information.
......@@ -54,14 +54,15 @@ public final class DefaultTunnel extends AbstractModel implements Tunnel {
* @param groupId groupId
* @param tunnelId tunnelId
* @param tunnelName tunnel name
* @param path the path of tunnel
* @param annotations optional key/value annotations
*/
public DefaultTunnel(ProviderId producerName, TunnelEndPoint src,
TunnelEndPoint dst, Type type, DefaultGroupId groupId,
TunnelId tunnelId, TunnelName tunnelName,
TunnelId tunnelId, TunnelName tunnelName, Path path,
Annotations... annotations) {
this(producerName, src, dst, type, Tunnel.State.ACTIVE, groupId,
tunnelId, tunnelName, annotations);
tunnelId, tunnelName, path, annotations);
}
/**
......@@ -75,18 +76,14 @@ public final class DefaultTunnel extends AbstractModel implements Tunnel {
* @param groupId groupId
* @param tunnelId tunnelId
* @param tunnelName tunnel name
* @param path the path of tunnel
* @param annotations optional key/value annotations
*/
public DefaultTunnel(ProviderId producerName, TunnelEndPoint src,
TunnelEndPoint dst, Type type, State state,
DefaultGroupId groupId, TunnelId tunnelId,
TunnelName tunnelName, Annotations... annotations) {
TunnelName tunnelName, Path path, Annotations... annotations) {
super(producerName, annotations);
checkNotNull(producerName, "producerName cannot be null");
checkNotNull(src, "src cannot be null");
checkNotNull(dst, "dst cannot be null");
checkNotNull(type, "type cannot be null");
checkNotNull(state, "state cannot be null");
this.src = src;
this.dst = dst;
this.type = type;
......@@ -94,6 +91,7 @@ public final class DefaultTunnel extends AbstractModel implements Tunnel {
this.groupId = groupId;
this.tunnelId = tunnelId;
this.tunnelName = tunnelName;
this.path = path;
}
@Override
......@@ -136,10 +134,16 @@ public final class DefaultTunnel extends AbstractModel implements Tunnel {
return tunnelName;
}
@Override
public Path path() {
return path;
}
@Override
public int hashCode() {
return Objects.hash(src, dst, type, groupId, tunnelId, tunnelName,
state);
state, path);
}
@Override
......@@ -155,7 +159,8 @@ public final class DefaultTunnel extends AbstractModel implements Tunnel {
&& Objects.equals(this.groupId, other.groupId)
&& Objects.equals(this.tunnelId, other.tunnelId)
&& Objects.equals(this.tunnelName, other.tunnelName)
&& Objects.equals(this.state, other.state);
&& Objects.equals(this.state, other.state)
&& Objects.equals(this.path, other.path);
}
return false;
}
......@@ -165,7 +170,7 @@ public final class DefaultTunnel extends AbstractModel implements Tunnel {
return toStringHelper(this).add("src", src).add("dst", dst)
.add("type", type).add("state", state).add("groupId", groupId)
.add("producerTunnelId", tunnelId)
.add("tunnelName", tunnelName).toString();
.add("tunnelName", tunnelName)
.add("path", path).toString();
}
}
......
......@@ -13,12 +13,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.incubator.net.tunnel;
import static com.google.common.base.Preconditions.checkNotNull;
import org.onosproject.core.DefaultGroupId;
import org.onosproject.net.AbstractDescription;
import org.onosproject.net.Path;
import org.onosproject.net.SparseAnnotations;
import org.onosproject.net.provider.ProviderId;
......@@ -39,6 +38,7 @@ public class DefaultTunnelDescription extends AbstractDescription
// tunnel producer
private final ProviderId producerName; // tunnel producer name
private final TunnelName tunnelName; // name of a tunnel
private final Path path;
/**
* Creates a tunnel description using the supplied information.
......@@ -50,6 +50,7 @@ public class DefaultTunnelDescription extends AbstractDescription
* @param groupId groupId
* @param producerName tunnel producer
* @param tunnelName tunnel name
* @param path the path of tunnel
* @param annotations optional key/value annotations
*/
public DefaultTunnelDescription(TunnelId id, TunnelEndPoint src,
......@@ -57,12 +58,9 @@ public class DefaultTunnelDescription extends AbstractDescription
DefaultGroupId groupId,
ProviderId producerName,
TunnelName tunnelName,
Path path,
SparseAnnotations... annotations) {
super(annotations);
checkNotNull(producerName, "producerName cannot be null");
checkNotNull(src, "src cannot be null");
checkNotNull(dst, "dst cannot be null");
checkNotNull(type, "type cannot be null");
this.tunnelId = id;
this.src = src;
this.dst = dst;
......@@ -70,6 +68,7 @@ public class DefaultTunnelDescription extends AbstractDescription
this.groupId = groupId;
this.producerName = producerName;
this.tunnelName = tunnelName;
this.path = path;
}
@Override
......@@ -107,6 +106,12 @@ public class DefaultTunnelDescription extends AbstractDescription
return tunnelName;
}
@Override
public Path path() {
return path;
}
@Override
public String toString() {
return MoreObjects.toStringHelper(this)
......@@ -117,7 +122,7 @@ public class DefaultTunnelDescription extends AbstractDescription
.add("tunnelName", tunnelName())
.add("producerName", producerName())
.add("groupId", groupId())
.add("path", path)
.toString();
}
}
......
......@@ -13,12 +13,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.incubator.net.tunnel;
import org.onosproject.core.DefaultGroupId;
import org.onosproject.net.Annotated;
import org.onosproject.net.NetworkResource;
import org.onosproject.net.Path;
import org.onosproject.net.Provided;
/**
......@@ -144,4 +144,10 @@ public interface Tunnel extends Annotated, Provided, NetworkResource {
*/
NetworkResource resource();
/**
* Returns the path of the tunnel.
*
* @return the path of the tunnel
*/
Path path();
}
......
......@@ -13,14 +13,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.incubator.net.tunnel;
import org.onosproject.core.DefaultGroupId;
import org.onosproject.incubator.net.tunnel.Tunnel.Type;
import org.onosproject.net.Annotated;
import org.onosproject.net.Description;
import org.onosproject.net.Path;
import org.onosproject.net.provider.ProviderId;
import org.onosproject.incubator.net.tunnel.Tunnel.Type;
/**
* Describes a tunnel.
......@@ -75,4 +75,11 @@ public interface TunnelDescription extends Description, Annotated {
* @return Tunnel Name
*/
TunnelName tunnelName();
/**
* Returns the path of the tunnel.
*
* @return the path of the tunnel
*/
Path path();
}
......
......@@ -16,7 +16,6 @@
package org.onosproject.incubator.net.tunnel;
import static com.google.common.base.Preconditions.checkArgument;
/**
* Representation of a Tunnel Id.
......@@ -35,8 +34,7 @@ public final class TunnelId {
}
public static TunnelId valueOf(String value) {
checkArgument(value.startsWith("0x"));
return new TunnelId(Long.parseLong(value.substring("0x".length()), 16));
return new TunnelId(Long.parseLong(value));
}
/**
......
......@@ -102,4 +102,12 @@ public interface TunnelProvider extends Provider {
* @param tunnel tunnel information
*/
void tunnelUpdated(TunnelDescription tunnel);
/**
* Signals that the a tunnel was queried.
* It's used by producers.
* @param tunnelId tunnel identity
* @return tunnel entity
*/
Tunnel tunnelQueryById(TunnelId tunnelId);
}
......
......@@ -45,4 +45,12 @@ public interface TunnelProviderService extends ProviderService<TunnelProvider> {
*/
void tunnelUpdated(TunnelDescription tunnel);
/**
* Signals that the a tunnel was queried.
*
* @param tunnelId tunnel identity
* @return tunnel entity
*/
Tunnel tunnelQueryById(TunnelId tunnelId);
}
......
......@@ -13,12 +13,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.incubator.net.tunnel;
import java.util.Collection;
import org.onosproject.core.ApplicationId;
import org.onosproject.incubator.net.tunnel.Tunnel.Type;
import org.onosproject.net.Annotations;
/**
......@@ -83,7 +83,7 @@ public interface TunnelService {
* @return collection of available Tunnels
*/
Collection<Tunnel> borrowTunnel(ApplicationId consumerId, TunnelEndPoint src,
TunnelEndPoint dst, Tunnel.Type type,
TunnelEndPoint dst, Type type,
Annotations... annotations);
/**
......@@ -122,7 +122,7 @@ public interface TunnelService {
* @return success or fail
*/
boolean returnTunnel(ApplicationId consumerId, TunnelEndPoint src,
TunnelEndPoint dst, Tunnel.Type type,
TunnelEndPoint dst, Type type,
Annotations... annotations);
/**
......@@ -160,7 +160,7 @@ public interface TunnelService {
* @param type tunnel type
* @return Collection of tunnels
*/
Collection<Tunnel> queryTunnel(Tunnel.Type type);
Collection<Tunnel> queryTunnel(Type type);
/**
* Returns all tunnels between source point and destination point.
......@@ -174,6 +174,13 @@ public interface TunnelService {
/**
* Returns all tunnels.
*
* @return Collection of tunnels
*/
Collection<Tunnel> queryAllTunnels();
/**
* Returns all tunnels.
*
* @return all tunnels
*/
int tunnelCount();
......
......@@ -13,15 +13,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.incubator.net.tunnel;
import java.util.Collection;
import org.onosproject.core.ApplicationId;
import org.onosproject.incubator.net.tunnel.Tunnel.Type;
import org.onosproject.net.Annotations;
import org.onosproject.net.provider.ProviderId;
import org.onosproject.incubator.net.tunnel.Tunnel.Type;
import org.onosproject.store.Store;
/**
......@@ -215,6 +214,13 @@ public interface TunnelStore extends Store<TunnelEvent, TunnelStoreDelegate> {
/**
* Returns all tunnels.
*
* @return Collection of tunnels
*/
Collection<Tunnel> queryAllTunnels();
/**
* Returns all tunnels.
* @return all tunnels
*/
int tunnelCount();
......
/*
* Copyright 2015 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.incubator.net.tunnel;
import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
......@@ -50,13 +34,13 @@ public class DefaultTunnelTest {
ProviderId producerName2 = new ProviderId("producer2", "13");
Tunnel p1 = new DefaultTunnel(producerName1, src, dst, Tunnel.Type.VXLAN,
Tunnel.State.ACTIVE, groupId, tunnelId,
tunnelName);
tunnelName, null);
Tunnel p2 = new DefaultTunnel(producerName1, src, dst, Tunnel.Type.VXLAN,
Tunnel.State.ACTIVE, groupId, tunnelId,
tunnelName);
tunnelName, null);
Tunnel p3 = new DefaultTunnel(producerName2, src, dst, Tunnel.Type.OCH,
Tunnel.State.ACTIVE, groupId, tunnelId,
tunnelName);
tunnelName, null);
new EqualsTester().addEqualityGroup(p1, p2).addEqualityGroup(p3)
.testEquals();
}
......
/*
* Copyright 2015 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.incubator.net.tunnel;
import static org.hamcrest.MatcherAssert.assertThat;
......@@ -53,7 +37,7 @@ public class TunnelEventTest {
ProviderId producerName1 = new ProviderId("producer1", "13");
Tunnel p1 = new DefaultTunnel(producerName1, src, dst, Tunnel.Type.VXLAN,
Tunnel.State.ACTIVE, groupId, tunnelId,
tunnelName);
tunnelName, null);
TunnelEvent e1 = new TunnelEvent(TunnelEvent.Type.TUNNEL_ADDED, p1);
assertThat(e1, is(notNullValue()));
assertThat(e1.type(), is(TunnelEvent.Type.TUNNEL_ADDED));
......
......@@ -91,9 +91,9 @@ public class LabelResourceManager
checkNotNull(deviceId, "deviceId is not null");
checkNotNull(beginLabel, "beginLabel is not null");
checkNotNull(endLabel, "beginLabel is not null");
checkArgument(beginLabel.labelId() < 0 || endLabel.labelId() < 0,
checkArgument(beginLabel.labelId() >= 0 || endLabel.labelId() >= 0,
"The value of beginLabel and the value of endLabel must be both positive number.");
checkArgument(beginLabel.labelId() > endLabel.labelId(),
checkArgument(beginLabel.labelId() <= endLabel.labelId(),
"The value of endLabel must be greater than the value of endLabel.");
return store.createDevicePool(deviceId, beginLabel, endLabel);
}
......@@ -103,10 +103,10 @@ public class LabelResourceManager
LabelResourceId endLabel) {
checkNotNull(beginLabel, "beginLabel is not null");
checkNotNull(endLabel, "beginLabel is not null");
checkArgument(beginLabel.labelId() < 0 || endLabel.labelId() < 0,
"The value of beginLabel and the value of endLabel must be both positive number.");
checkArgument(beginLabel.labelId() > endLabel.labelId(),
"The value of endLabel must be greater than the value of endLabel.");
checkArgument(beginLabel.labelId() >= 0 && endLabel.labelId() >= 0,
"The value of beginLabel and the value of endLabel must be both positive number.");
checkArgument(beginLabel.labelId() <= endLabel.labelId(),
"The value of endLabel must be greater than the value of endLabel.");
return store.createGlobalPool(beginLabel, endLabel);
}
......
......@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.incubator.net.tunnel.impl;
import static com.google.common.base.Preconditions.checkNotNull;
......@@ -31,14 +30,9 @@ import org.apache.felix.scr.annotations.Service;
import org.onosproject.core.ApplicationId;
import org.onosproject.event.EventDeliveryService;
import org.onosproject.event.ListenerRegistry;
import org.onosproject.net.Annotations;
import org.onosproject.net.Path;
import org.onosproject.net.provider.AbstractProviderRegistry;
import org.onosproject.net.provider.AbstractProviderService;
import org.onosproject.net.provider.ProviderId;
import org.onosproject.incubator.net.tunnel.DefaultTunnel;
import org.onosproject.incubator.net.tunnel.Tunnel;
import org.onosproject.incubator.net.tunnel.Tunnel.Type;
import org.onosproject.incubator.net.tunnel.Tunnel;
import org.onosproject.incubator.net.tunnel.TunnelAdminService;
import org.onosproject.incubator.net.tunnel.TunnelDescription;
import org.onosproject.incubator.net.tunnel.TunnelEndPoint;
......@@ -53,6 +47,11 @@ import org.onosproject.incubator.net.tunnel.TunnelService;
import org.onosproject.incubator.net.tunnel.TunnelStore;
import org.onosproject.incubator.net.tunnel.TunnelStoreDelegate;
import org.onosproject.incubator.net.tunnel.TunnelSubscription;
import org.onosproject.net.Annotations;
import org.onosproject.net.Path;
import org.onosproject.net.provider.AbstractProviderRegistry;
import org.onosproject.net.provider.AbstractProviderService;
import org.onosproject.net.provider.ProviderId;
import org.slf4j.Logger;
/**
......@@ -277,6 +276,12 @@ public class TunnelManager
return store.queryTunnel(src, dst);
}
@Override
public Collection<Tunnel> queryAllTunnels() {
return store.queryAllTunnels();
}
@Override
public int tunnelCount() {
return store.tunnelCount();
......@@ -313,6 +318,7 @@ public class TunnelManager
tunnel.groupId(),
tunnel.id(),
tunnel.tunnelName(),
tunnel.path(),
tunnel.annotations());
return store.createOrUpdateTunnel(storedTunnel);
}
......@@ -325,6 +331,7 @@ public class TunnelManager
tunnel.groupId(),
tunnel.id(),
tunnel.tunnelName(),
tunnel.path(),
tunnel.annotations());
store.createOrUpdateTunnel(storedTunnel);
}
......@@ -333,18 +340,28 @@ public class TunnelManager
public void tunnelRemoved(TunnelDescription tunnel) {
if (tunnel.id() != null) {
store.deleteTunnel(tunnel.id());
return;
}
if (tunnel.src() != null && tunnel.dst() != null
&& tunnel.type() != null) {
store.deleteTunnel(tunnel.src(), tunnel.dst(), tunnel.type(),
provider().id());
return;
}
if (tunnel.src() != null && tunnel.dst() != null
&& tunnel.type() == null) {
store.deleteTunnel(tunnel.src(), tunnel.dst(), provider().id());
return;
}
}
@Override
public Tunnel tunnelQueryById(TunnelId tunnelId) {
return store.queryTunnel(tunnelId);
}
}
private class InternalStoreDelegate implements TunnelStoreDelegate {
......@@ -355,4 +372,5 @@ public class TunnelManager
}
}
}
}
......
/*
* Copyright 2015 Open Networking Laboratory
* Copyright 2014-2015 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.incubator.store.tunnel.impl;
import static org.slf4j.LoggerFactory.getLogger;
......@@ -37,8 +36,6 @@ import org.onosproject.cluster.ClusterService;
import org.onosproject.core.ApplicationId;
import org.onosproject.core.CoreService;
import org.onosproject.core.IdGenerator;
import org.onosproject.net.Annotations;
import org.onosproject.net.provider.ProviderId;
import org.onosproject.incubator.net.tunnel.DefaultTunnel;
import org.onosproject.incubator.net.tunnel.Tunnel;
import org.onosproject.incubator.net.tunnel.Tunnel.Type;
......@@ -49,6 +46,10 @@ import org.onosproject.incubator.net.tunnel.TunnelName;
import org.onosproject.incubator.net.tunnel.TunnelStore;
import org.onosproject.incubator.net.tunnel.TunnelStoreDelegate;
import org.onosproject.incubator.net.tunnel.TunnelSubscription;
import org.onosproject.net.Annotations;
import org.onosproject.net.DefaultAnnotations;
import org.onosproject.net.SparseAnnotations;
import org.onosproject.net.provider.ProviderId;
import org.onosproject.store.AbstractStore;
import org.onosproject.store.app.GossipApplicationStore.InternalState;
import org.onosproject.store.cluster.messaging.ClusterCommunicationService;
......@@ -126,6 +127,10 @@ public class DistributedTunnelStore
.<Tunnel.Type, Set<TunnelId>>eventuallyConsistentMapBuilder()
.withName("type_tunnel").withSerializer(serializer)
.withClockService(new WallclockClockManager<>()).build();
orderRelationship = storageService
.<ApplicationId, Set<TunnelSubscription>>eventuallyConsistentMapBuilder()
.withName("type_tunnel").withSerializer(serializer)
.withClockService(new WallclockClockManager<>()).build();
idGenerator = coreService.getIdGenerator(runnelOpTopoic);
log.info("Started");
}
......@@ -148,13 +153,15 @@ public class DistributedTunnelStore
log.info("This tunnel[" + tunnel.tunnelId() + "] is not available.");
return tunnel.tunnelId();
}
Tunnel newT = new DefaultTunnel(tunnel.providerId(), tunnel.src(),
tunnel.dst(), tunnel.type(),
tunnel.state(), tunnel.groupId(),
DefaultAnnotations oldAnno = (DefaultAnnotations) old.annotations();
SparseAnnotations newAnno = (SparseAnnotations) tunnel.annotations();
Tunnel newT = new DefaultTunnel(old.providerId(), old.src(),
old.dst(), old.type(),
old.state(), old.groupId(),
old.tunnelId(),
tunnel.tunnelName(),
tunnel.annotations());
tunnelIdAsKeyStore.remove(tunnel.tunnelId());
old.tunnelName(),
old.path(),
DefaultAnnotations.merge(oldAnno, newAnno));
tunnelIdAsKeyStore.put(tunnel.tunnelId(), newT);
TunnelEvent event = new TunnelEvent(
TunnelEvent.Type.TUNNEL_UPDATED,
......@@ -168,6 +175,7 @@ public class DistributedTunnelStore
tunnel.state(), tunnel.groupId(),
tunnelId,
tunnel.tunnelName(),
tunnel.path(),
tunnel.annotations());
TunnelKey key = TunnelKey.tunnelKey(tunnel.src(), tunnel.dst());
tunnelIdAsKeyStore.put(tunnelId, newT);
......@@ -463,6 +471,11 @@ public class DistributedTunnelStore
}
@Override
public Collection<Tunnel> queryAllTunnels() {
return tunnelIdAsKeyStore.values();
}
@Override
public int tunnelCount() {
return tunnelIdAsKeyStore.size();
}
......@@ -515,5 +528,4 @@ public class DistributedTunnelStore
.add("dst", dst).toString();
}
}
}
......
......@@ -67,14 +67,12 @@ public class DefaultTunnelProvider extends AbstractProvider
@Activate
public void activate(ComponentContext context) {
cfgService.registerProperties(getClass());
service = tunnelProviderRegistry.register(this);
log.info("Started");
}
@Deactivate
public void deactivate(ComponentContext context) {
cfgService.unregisterProperties(getClass(), false);
tunnelProviderRegistry.unregister(this);
log.info("Stopped");
}
......@@ -130,4 +128,9 @@ public class DefaultTunnelProvider extends AbstractProvider
service.tunnelUpdated(tunnel);
}
@Override
public Tunnel tunnelQueryById(TunnelId tunnelId) {
return service.tunnelQueryById(tunnelId);
}
}
......
......@@ -15,20 +15,14 @@
*/
package org.onosproject.provider.tunnel.cli;
import static com.google.common.base.Preconditions.checkArgument;
import java.util.Optional;
import org.apache.karaf.shell.commands.Argument;
import org.apache.karaf.shell.commands.Command;
import org.apache.karaf.shell.commands.Option;
import org.onlab.packet.IpAddress;
import org.onosproject.cli.AbstractShellCommand;
import org.onosproject.core.DefaultGroupId;
import org.onosproject.net.DefaultAnnotations;
import org.onosproject.net.DeviceId;
import org.onosproject.net.PortNumber;
import org.onosproject.net.SparseAnnotations;
import org.onosproject.net.provider.ProviderId;
import org.onosproject.incubator.net.tunnel.DefaultOpticalTunnelEndPoint;
import org.onosproject.incubator.net.tunnel.DefaultTunnelDescription;
import org.onosproject.incubator.net.tunnel.IpTunnelEndPoint;
......@@ -40,40 +34,45 @@ import org.onosproject.incubator.net.tunnel.TunnelEndPoint;
import org.onosproject.incubator.net.tunnel.TunnelId;
import org.onosproject.incubator.net.tunnel.TunnelName;
import org.onosproject.incubator.net.tunnel.TunnelProvider;
import org.onosproject.net.DefaultAnnotations;
import org.onosproject.net.DeviceId;
import org.onosproject.net.PortNumber;
import org.onosproject.net.SparseAnnotations;
import org.onosproject.net.provider.ProviderId;
/**
* Supports for creating a tunnel by using IP address and optical as tunnel end
* point.
*/
@Command(scope = "onos", name = "create-tunnels",
@Command(scope = "onos", name = "tunnel-create",
description = "Supports for creating a tunnel by using IP address and optical as tunnel end point now.")
public class CreateTunnelCommand extends AbstractShellCommand {
public class TunnelCreateCommand extends AbstractShellCommand {
@Argument(index = 0, name = "src", description = "Source tunnel point."
+ " Only supports for IpTunnelEndPoint and OpticalTunnelEndPoint as end point now."
+ " If creates a ODUK or OCH type tunnel, the formatter of this argument is DeviceId-PortNumber."
+ " If creates a ODUK or OCH or VLAN type tunnel, the formatter of this argument is DeviceId-PortNumber."
+ " Otherwise src means IP address.", required = true, multiValued = false)
String src = null;
@Argument(index = 1, name = "dst", description = "Destination tunnel point."
+ " Only supports for IpTunnelEndPoint and OpticalTunnelEndPoint as end point now."
+ " If creates a ODUK or OCH type tunnel, the formatter of this argument is DeviceId-PortNumber."
+ " If creates a ODUK or OCH or VLAN type tunnel, the formatter of this argument is DeviceId-PortNumber."
+ " Otherwise dst means IP address.", required = true, multiValued = false)
String dst = null;
@Argument(index = 2, name = "type", description = "The type of tunnels,"
+ " It includes MPLS, VLAN, VXLAN, GRE, ODUK, OCH", required = true, multiValued = false)
String type = null;
@Argument(index = 3, name = "groupId",
description = "Group flow table id which a tunnel match up", required = true, multiValued = false)
@Option(name = "-g", aliases = "--groupId",
description = "Group flow table id which a tunnel match up", required = false, multiValued = false)
String groupId = null;
@Argument(index = 4, name = "tunnelName",
@Option(name = "-n", aliases = "--tunnelName",
description = "The name of tunnels", required = false, multiValued = false)
String tunnelName = null;
@Argument(index = 5, name = "bandWith",
description = "The bandWith attribute of tunnel", required = false, multiValued = false)
String bandWith = null;
@Option(name = "-b", aliases = "--bandwidth",
description = "The bandwidth attribute of tunnel", required = false, multiValued = false)
String bandwidth = null;
private static final String FMT = "The tunnel identity is %s";
......@@ -91,8 +90,30 @@ public class CreateTunnelCommand extends AbstractShellCommand {
dstPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(dst));
} else if ("VLAN".equals(type)) {
trueType = Tunnel.Type.VLAN;
srcPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(src));
dstPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(dst));
String[] srcArray = src.split("-");
String[] dstArray = dst.split("-");
srcPoint = new DefaultOpticalTunnelEndPoint(
producerName,
Optional.of(DeviceId
.deviceId(srcArray[0])),
Optional.of(PortNumber
.portNumber(srcArray[1])),
null,
null,
OpticalLogicId
.logicId(0),
true);
dstPoint = new DefaultOpticalTunnelEndPoint(
producerName,
Optional.of(DeviceId
.deviceId(dstArray[0])),
Optional.of(PortNumber
.portNumber(dstArray[1])),
null,
null,
OpticalLogicId
.logicId(0),
true);
} else if ("VXLAN".equals(type)) {
trueType = Tunnel.Type.VXLAN;
srcPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(src));
......@@ -103,10 +124,8 @@ public class CreateTunnelCommand extends AbstractShellCommand {
dstPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(dst));
} else if ("ODUK".equals(type)) {
trueType = Tunnel.Type.ODUK;
String[] srcArray = src.split("||");
checkArgument(srcArray.length < 2, "Illegal src formatter.");
String[] dstArray = dst.split("||");
checkArgument(dstArray.length < 2, "Illegal dst formatter.");
String[] srcArray = src.split("-");
String[] dstArray = dst.split("-");
srcPoint = new DefaultOpticalTunnelEndPoint(
producerName,
Optional.of(DeviceId
......@@ -140,7 +159,7 @@ public class CreateTunnelCommand extends AbstractShellCommand {
Optional.of(PortNumber
.portNumber(srcArray[1])),
null,
OpticalTunnelEndPoint.Type.LAMBDA,
OpticalTunnelEndPoint.Type.TIMESLOT,
OpticalLogicId
.logicId(0),
true);
......@@ -151,7 +170,7 @@ public class CreateTunnelCommand extends AbstractShellCommand {
Optional.of(PortNumber
.portNumber(dstArray[1])),
null,
OpticalTunnelEndPoint.Type.LAMBDA,
OpticalTunnelEndPoint.Type.TIMESLOT,
OpticalLogicId
.logicId(0),
true);
......@@ -162,7 +181,7 @@ public class CreateTunnelCommand extends AbstractShellCommand {
SparseAnnotations annotations = DefaultAnnotations
.builder()
.set("bandWith", bandWith == null && "".equals(bandWith) ? "0" : bandWith)
.set("bandwidth", bandwidth == null && "".equals(bandwidth) ? "0" : bandwidth)
.build();
TunnelDescription tunnel = new DefaultTunnelDescription(
null,
......@@ -175,6 +194,7 @@ public class CreateTunnelCommand extends AbstractShellCommand {
producerName,
TunnelName
.tunnelName(tunnelName),
null,
annotations);
TunnelId tunnelId = service.tunnelAdded(tunnel);
print(FMT, tunnelId.id());
......
/*
* Copyright 2014-2015 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.provider.tunnel.cli;
import org.apache.karaf.shell.commands.Argument;
import org.apache.karaf.shell.commands.Command;
import org.apache.karaf.shell.commands.Option;
import org.onosproject.cli.AbstractShellCommand;
import org.onosproject.incubator.net.tunnel.DefaultTunnelDescription;
import org.onosproject.incubator.net.tunnel.TunnelDescription;
import org.onosproject.incubator.net.tunnel.TunnelId;
import org.onosproject.incubator.net.tunnel.TunnelProvider;
import org.onosproject.net.DefaultAnnotations;
import org.onosproject.net.SparseAnnotations;
/**
* Supports for updating a tunnel by tunnel identity.
* It's used by producers.
*/
@Command(scope = "onos", name = "tunnel-update",
description = "Supports for updating a tunnel by tunnel identity."
+ " It's used by producers.")
public class TunnelUpdateCommand extends AbstractShellCommand {
@Argument(index = 0, name = "tunnelId", description = "the tunnel identity.",
required = true, multiValued = false)
String tunnelId = null;
@Option(name = "-b", aliases = "--bandwidth",
description = "The bandwidth attribute of tunnel", required = false, multiValued = false)
String bandwidth = null;
@Override
protected void execute() {
TunnelProvider service = get(TunnelProvider.class);
TunnelId id = TunnelId.valueOf(tunnelId);
SparseAnnotations annotations = DefaultAnnotations
.builder()
.set("bandwidth", bandwidth)
.build();
TunnelDescription tunnel = new DefaultTunnelDescription(id, null,
null,
null, null,
null,
null, null, annotations);
service.tunnelUpdated(tunnel);
}
}
......@@ -17,10 +17,13 @@
<command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.1.0">
<command>
<action class="org.onosproject.provider.tunnel.cli.CreateTunnelCommand"/>
<action class="org.onosproject.provider.tunnel.cli.TunnelCreateCommand"/>
</command>
<command>
<action class="org.onosproject.provider.tunnel.cli.RemoveTunnelCommand"/>
<action class="org.onosproject.provider.tunnel.cli.TunnelRemoveCommand"/>
</command>
<command>
<action class="org.onosproject.provider.tunnel.cli.TunnelUpdateCommand"/>
</command>
</command-bundle>
</blueprint>
......