Hyunsun Moon | de37257 | 2016-01-14 03:42:47 -0800 | [diff] [blame] | 1 | /* |
Brian O'Connor | 8e57fd5 | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Laboratory |
Hyunsun Moon | de37257 | 2016-01-14 03:42:47 -0800 | [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 | |
| 17 | package org.onosproject.cordvtn.cli; |
| 18 | |
| 19 | import org.apache.karaf.shell.commands.Argument; |
| 20 | import org.apache.karaf.shell.commands.Command; |
| 21 | import org.onosproject.cli.AbstractShellCommand; |
Hyunsun Moon | f948020 | 2016-04-14 16:13:42 -0700 | [diff] [blame^] | 22 | import org.onosproject.cordvtn.api.CordVtnNode; |
| 23 | import org.onosproject.cordvtn.impl.CordVtnNodeManager; |
Hyunsun Moon | de37257 | 2016-01-14 03:42:47 -0800 | [diff] [blame] | 24 | |
| 25 | /** |
| 26 | * Checks detailed node init state. |
| 27 | */ |
| 28 | @Command(scope = "onos", name = "cordvtn-node-check", |
| 29 | description = "Shows detailed node init state") |
| 30 | public class CordVtnNodeCheckCommand extends AbstractShellCommand { |
| 31 | |
| 32 | @Argument(index = 0, name = "hostname", description = "Hostname", |
| 33 | required = true, multiValued = false) |
| 34 | private String hostname = null; |
| 35 | |
| 36 | @Override |
| 37 | protected void execute() { |
Hyunsun Moon | cb79944 | 2016-01-15 20:03:18 -0800 | [diff] [blame] | 38 | CordVtnNodeManager nodeManager = AbstractShellCommand.get(CordVtnNodeManager.class); |
| 39 | CordVtnNode node = nodeManager.getNodes() |
Hyunsun Moon | de37257 | 2016-01-14 03:42:47 -0800 | [diff] [blame] | 40 | .stream() |
| 41 | .filter(n -> n.hostname().equals(hostname)) |
| 42 | .findFirst() |
| 43 | .orElse(null); |
| 44 | |
| 45 | if (node == null) { |
| 46 | print("Cannot find %s from registered nodes", hostname); |
| 47 | return; |
| 48 | } |
| 49 | |
Hyunsun Moon | cb79944 | 2016-01-15 20:03:18 -0800 | [diff] [blame] | 50 | print(nodeManager.checkNodeInitState(node)); |
Hyunsun Moon | de37257 | 2016-01-14 03:42:47 -0800 | [diff] [blame] | 51 | } |
| 52 | } |