blob: 4a9d6fc5a1f3d7d0d29dac876e18463f4347f17a [file] [log] [blame]
jiangrui7d2d7fb2015-08-11 18:43:57 +08001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2015-present Open Networking Foundation
jiangrui7d2d7fb2015-08-11 18:43:57 +08003 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.onosproject.vtnrsc.cli.network;
17
18import java.util.Set;
19
20import org.apache.karaf.shell.commands.Argument;
21import org.apache.karaf.shell.commands.Command;
22import org.apache.karaf.shell.commands.Option;
23import org.onosproject.cli.AbstractShellCommand;
24import org.onosproject.vtnrsc.DefaultTenantNetwork;
25import org.onosproject.vtnrsc.PhysicalNetwork;
26import org.onosproject.vtnrsc.SegmentationId;
27import org.onosproject.vtnrsc.TenantId;
28import org.onosproject.vtnrsc.TenantNetwork;
29import org.onosproject.vtnrsc.TenantNetworkId;
30import org.onosproject.vtnrsc.tenantnetwork.TenantNetworkService;
31
32import com.google.common.collect.Sets;
33
34/**
35 * Supports for updating a TenantNetwork.
36 */
37@Command(scope = "onos", name = "tenantnetwork-update",
38 description = "Supports for updating a TenantNetwork")
39public class TenantNetworkUpdateCommand extends AbstractShellCommand {
40
41 @Argument(index = 0, name = "id", description = "TenantNetwork network id", required = true,
42 multiValued = false)
43 String id = null;
44
45 @Argument(index = 1, name = "tenantID", description = "The tenant id of TenantNetwork",
46 required = true, multiValued = false)
47 String tenantID = null;
48
49 @Argument(index = 2, name = "type", description = "The type of TenantNetwork", required = true,
50 multiValued = false)
51 String type = null;
52
53 @Argument(index = 3, name = "segmentationID", description = "The segmentation id of TenantNetwork",
54 required = true, multiValued = false)
55 String segmentationID = "";
56
57 @Option(name = "-n", aliases = "--name", description = "TenantNetwork name", required = false,
58 multiValued = false)
59 String name = null;
60
61 @Option(name = "-a", aliases = "--adminStateUp", description = "TenantNetwork adminStateUp is true or false",
62 required = false, multiValued = false)
63 boolean adminStateUp = false;
64
65 @Option(name = "-s", aliases = "--state", description = "The state of TenantNetwork",
66 required = false, multiValued = false)
67 String state = null;
68
69 @Option(name = "-d", aliases = "--shared", description = "TenantNetwork is shared or not",
70 required = false, multiValued = false)
71 boolean shared = false;
72
73 @Option(name = "-r", aliases = "--routerExternal",
74 description = "TenantNetwork is routerExternal or not", required = false,
75 multiValued = false)
76 boolean routerExternal = false;
77
78 @Option(name = "-p", aliases = "--physicalNetwork", description = "The physical network of Tenant",
79 required = false, multiValued = false)
80 String physicalNetwork = "";
81
82 @Override
83 protected void execute() {
84 TenantNetworkService service = get(TenantNetworkService.class);
85 TenantNetwork network = new DefaultTenantNetwork(TenantNetworkId.networkId(id), name,
86 adminStateUp,
87 TenantNetwork.State.valueOf(state),
88 shared, TenantId.tenantId(tenantID),
89 routerExternal,
90 TenantNetwork.Type.valueOf(type),
91 PhysicalNetwork.physicalNetwork(physicalNetwork),
92 SegmentationId.segmentationId(segmentationID));
93
94 Set<TenantNetwork> networksSet = Sets.newHashSet();
95 networksSet.add(network);
96 service.updateNetworks(networksSet);
97 }
98
99}