blob: 4b747b80c2f0a02d5e435b0db2027a8c1301b2c3 [file] [log] [blame]
Hyunsun Moon187bf532017-01-19 10:57:40 +09001/*
Brian O'Connor80dff972017-08-03 22:46:30 -07002 * Copyright 2017-present Open Networking Foundation
Hyunsun Moon187bf532017-01-19 10:57:40 +09003 *
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.opencord.cordvtn.cli;
17
18import org.apache.karaf.shell.commands.Argument;
19import org.apache.karaf.shell.commands.Command;
Jonathan Hart86051062018-01-26 14:56:30 -080020import org.apache.karaf.shell.commands.Option;
Hyunsun Moon187bf532017-01-19 10:57:40 +090021import org.onosproject.cli.AbstractShellCommand;
Jonathan Hart86051062018-01-26 14:56:30 -080022import org.opencord.cordvtn.api.core.ServiceNetworkAdminService;
Hyunsun Moon187bf532017-01-19 10:57:40 +090023
Hyunsun Moon187bf532017-01-19 10:57:40 +090024/**
25 * Synchronizes network states with XOS VTN service.
26 * This command can be used to actively synchronize XOS network with VTN
27 * service network.
28 */
29@Command(scope = "onos", name = "cordvtn-sync-xos-states",
Jonathan Hart19dcbae2017-07-12 09:52:59 -070030 description = "Synchronizes network states with XOS")
Hyunsun Moon187bf532017-01-19 10:57:40 +090031public class CordVtnSyncXosStatesCommand extends AbstractShellCommand {
32
Jonathan Hart86051062018-01-26 14:56:30 -080033 @Option(name = "-c", aliases = "--config", description = "Use connection values from config",
34 required = false, multiValued = false)
35 private boolean config = false;
36
Hyunsun Moon187bf532017-01-19 10:57:40 +090037 @Argument(index = 0, name = "endpoint", description = "XOS VTN service endpoint",
38 required = true, multiValued = false)
39 private String endpoint = null;
40
41 @Argument(index = 1, name = "user", description = "XOS admin user name",
42 required = true, multiValued = false)
43 private String user = null;
44
45 @Argument(index = 2, name = "password", description = "XOS admin user password",
46 required = true, multiValued = false)
47 private String password = null;
48
Hyunsun Moon187bf532017-01-19 10:57:40 +090049 @Override
50 protected void execute() {
Jonathan Hart19dcbae2017-07-12 09:52:59 -070051 print("Requesting state synchronization");
Jonathan Hart86051062018-01-26 14:56:30 -080052 ServiceNetworkAdminService snService = get(ServiceNetworkAdminService.class);
53 if (config) {
54 snService.syncXosState();
55 } else {
56 snService.syncXosState(endpoint, user, password);
57 }
Hyunsun Moon187bf532017-01-19 10:57:40 +090058 }
59}