blob: 687c1a4d73546e89e8e2abce36a351b68ca55f63 [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;
20import org.onosproject.cli.AbstractShellCommand;
Hyunsun Moon187bf532017-01-19 10:57:40 +090021import org.opencord.cordvtn.rest.XosVtnNetworkingClient;
22
Hyunsun Moon187bf532017-01-19 10:57:40 +090023/**
24 * Synchronizes network states with XOS VTN service.
25 * This command can be used to actively synchronize XOS network with VTN
26 * service network.
27 */
28@Command(scope = "onos", name = "cordvtn-sync-xos-states",
Jonathan Hart19dcbae2017-07-12 09:52:59 -070029 description = "Synchronizes network states with XOS")
Hyunsun Moon187bf532017-01-19 10:57:40 +090030public class CordVtnSyncXosStatesCommand extends AbstractShellCommand {
31
32 @Argument(index = 0, name = "endpoint", description = "XOS VTN service endpoint",
33 required = true, multiValued = false)
34 private String endpoint = null;
35
36 @Argument(index = 1, name = "user", description = "XOS admin user name",
37 required = true, multiValued = false)
38 private String user = null;
39
40 @Argument(index = 2, name = "password", description = "XOS admin user password",
41 required = true, multiValued = false)
42 private String password = null;
43
Hyunsun Moon187bf532017-01-19 10:57:40 +090044 @Override
45 protected void execute() {
Hyunsun Moon187bf532017-01-19 10:57:40 +090046 XosVtnNetworkingClient client = XosVtnNetworkingClient.builder()
47 .endpoint(endpoint)
48 .user(user)
49 .password(password)
50 .build();
51
Jonathan Hart19dcbae2017-07-12 09:52:59 -070052 print("Requesting state synchronization");
53 client.requestSync();
Hyunsun Moon187bf532017-01-19 10:57:40 +090054 }
55}