blob: d6224fba2256c3920fdc5075a1f73cb3fdc6df37 [file] [log] [blame]
Hyunsun Moonb219fc42016-01-14 03:42:47 -08001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2016-present Open Networking Laboratory
Hyunsun Moonb219fc42016-01-14 03:42:47 -08003 *
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
17package org.onosproject.cordvtn.cli;
18
19import org.apache.karaf.shell.commands.Argument;
20import org.apache.karaf.shell.commands.Command;
21import org.onosproject.cli.AbstractShellCommand;
Hyunsun Moon7f4ed9d2016-04-14 16:13:42 -070022import org.onosproject.cordvtn.api.CordVtnNode;
23import org.onosproject.cordvtn.impl.CordVtnNodeManager;
Hyunsun Moonb219fc42016-01-14 03:42:47 -080024
25/**
26 * Checks detailed node init state.
27 */
28@Command(scope = "onos", name = "cordvtn-node-check",
29 description = "Shows detailed node init state")
30public 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 Moonb77b60f2016-01-15 20:03:18 -080038 CordVtnNodeManager nodeManager = AbstractShellCommand.get(CordVtnNodeManager.class);
39 CordVtnNode node = nodeManager.getNodes()
Hyunsun Moonb219fc42016-01-14 03:42:47 -080040 .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 Moonb77b60f2016-01-15 20:03:18 -080050 print(nodeManager.checkNodeInitState(node));
Hyunsun Moonb219fc42016-01-14 03:42:47 -080051 }
52}