blob: 185acd7f6fd6f103e067567be62827abee9a6a16 [file] [log] [blame]
Hyunsun Moonde372572016-01-14 03:42:47 -08001/*
2 * Copyright 2015 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
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;
22import org.onosproject.cordvtn.CordVtnNode;
23import org.onosproject.cordvtn.CordVtnService;
24
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() {
38 CordVtnService service = AbstractShellCommand.get(CordVtnService.class);
39 CordVtnNode node = service.getNodes()
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
50 print(service.checkNodeInitState(node));
51 }
52}