Hyunsun Moon | 187bf53 | 2017-01-19 10:57:40 +0900 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2017-present Open Networking Laboratory |
| 3 | * |
| 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 | */ |
| 16 | package org.opencord.cordvtn.cli; |
| 17 | |
| 18 | import org.apache.karaf.shell.commands.Argument; |
| 19 | import org.apache.karaf.shell.commands.Command; |
| 20 | import org.onosproject.cli.AbstractShellCommand; |
Hyunsun Moon | 187bf53 | 2017-01-19 10:57:40 +0900 | [diff] [blame] | 21 | import org.opencord.cordvtn.rest.XosVtnNetworkingClient; |
| 22 | |
Hyunsun Moon | 187bf53 | 2017-01-19 10:57:40 +0900 | [diff] [blame] | 23 | /** |
| 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 Hart | 19dcbae | 2017-07-12 09:52:59 -0700 | [diff] [blame^] | 29 | description = "Synchronizes network states with XOS") |
Hyunsun Moon | 187bf53 | 2017-01-19 10:57:40 +0900 | [diff] [blame] | 30 | public 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 Moon | 187bf53 | 2017-01-19 10:57:40 +0900 | [diff] [blame] | 44 | @Override |
| 45 | protected void execute() { |
Hyunsun Moon | 187bf53 | 2017-01-19 10:57:40 +0900 | [diff] [blame] | 46 | XosVtnNetworkingClient client = XosVtnNetworkingClient.builder() |
| 47 | .endpoint(endpoint) |
| 48 | .user(user) |
| 49 | .password(password) |
| 50 | .build(); |
| 51 | |
Jonathan Hart | 19dcbae | 2017-07-12 09:52:59 -0700 | [diff] [blame^] | 52 | print("Requesting state synchronization"); |
| 53 | client.requestSync(); |
Hyunsun Moon | 187bf53 | 2017-01-19 10:57:40 +0900 | [diff] [blame] | 54 | } |
| 55 | } |