Hyunsun Moon | 187bf53 | 2017-01-19 10:57:40 +0900 | [diff] [blame] | 1 | /* |
Brian O'Connor | 80dff97 | 2017-08-03 22:46:30 -0700 | [diff] [blame] | 2 | * Copyright 2017-present Open Networking Foundation |
Hyunsun Moon | 187bf53 | 2017-01-19 10:57:40 +0900 | [diff] [blame] | 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; |
Jonathan Hart | 8605106 | 2018-01-26 14:56:30 -0800 | [diff] [blame^] | 20 | import org.apache.karaf.shell.commands.Option; |
Hyunsun Moon | 187bf53 | 2017-01-19 10:57:40 +0900 | [diff] [blame] | 21 | import org.onosproject.cli.AbstractShellCommand; |
Jonathan Hart | 8605106 | 2018-01-26 14:56:30 -0800 | [diff] [blame^] | 22 | import org.opencord.cordvtn.api.core.ServiceNetworkAdminService; |
Hyunsun Moon | 187bf53 | 2017-01-19 10:57:40 +0900 | [diff] [blame] | 23 | |
Hyunsun Moon | 187bf53 | 2017-01-19 10:57:40 +0900 | [diff] [blame] | 24 | /** |
| 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 Hart | 19dcbae | 2017-07-12 09:52:59 -0700 | [diff] [blame] | 30 | description = "Synchronizes network states with XOS") |
Hyunsun Moon | 187bf53 | 2017-01-19 10:57:40 +0900 | [diff] [blame] | 31 | public class CordVtnSyncXosStatesCommand extends AbstractShellCommand { |
| 32 | |
Jonathan Hart | 8605106 | 2018-01-26 14:56:30 -0800 | [diff] [blame^] | 33 | @Option(name = "-c", aliases = "--config", description = "Use connection values from config", |
| 34 | required = false, multiValued = false) |
| 35 | private boolean config = false; |
| 36 | |
Hyunsun Moon | 187bf53 | 2017-01-19 10:57:40 +0900 | [diff] [blame] | 37 | @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 Moon | 187bf53 | 2017-01-19 10:57:40 +0900 | [diff] [blame] | 49 | @Override |
| 50 | protected void execute() { |
Jonathan Hart | 19dcbae | 2017-07-12 09:52:59 -0700 | [diff] [blame] | 51 | print("Requesting state synchronization"); |
Jonathan Hart | 8605106 | 2018-01-26 14:56:30 -0800 | [diff] [blame^] | 52 | ServiceNetworkAdminService snService = get(ServiceNetworkAdminService.class); |
| 53 | if (config) { |
| 54 | snService.syncXosState(); |
| 55 | } else { |
| 56 | snService.syncXosState(endpoint, user, password); |
| 57 | } |
Hyunsun Moon | 187bf53 | 2017-01-19 10:57:40 +0900 | [diff] [blame] | 58 | } |
| 59 | } |