blob: 31dd9759388443f31af22f0047b88d8a6751d00c [file] [log] [blame]
Daniele Moro10c45cc2021-06-24 18:17:30 +02001/*
2 * Copyright 2021-present Open Networking Foundation
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.pipelines.fabric.impl.behaviour.cli;
18
19import org.apache.karaf.shell.api.action.Command;
20import org.apache.karaf.shell.api.action.Option;
21import org.apache.karaf.shell.api.action.lifecycle.Service;
22import org.onosproject.cli.AbstractShellCommand;
23import org.onosproject.pipelines.fabric.impl.behaviour.upf.FabricUpfStore;
24import org.onosproject.pipelines.fabric.impl.behaviour.upf.UpfRuleIdentifier;
25
26import java.util.Map;
27
28/**
29 * Read internal UPF store of fabric.
30 */
31@Service
32@Command(scope = "fabric", name = "upf-read-internal-store",
33 description = "Print internal UPF stores")
34public class ReadInternalUpfStoreCommand extends AbstractShellCommand {
35 @Option(name = "-v", aliases = "--verbose",
36 description = "Print more detail of each entry",
37 required = false, multiValued = false)
38 private boolean verbose = false;
39
40 @Override
41 protected void doExecute() {
42 FabricUpfStore upfStore = get(FabricUpfStore.class);
43
44 if (upfStore == null) {
45 print("Error: FabricUpfStore is null");
46 return;
47 }
48
pierventre1eb98712021-07-13 18:03:22 +020049 Map<Integer, UpfRuleIdentifier> reverseFarIdMap = upfStore.getReverseFarIdMap();
50 print("reverseFarIdMap size: " + reverseFarIdMap.size());
Daniele Moro10c45cc2021-06-24 18:17:30 +020051 if (verbose) {
pierventre1eb98712021-07-13 18:03:22 +020052 reverseFarIdMap.entrySet().forEach(entry -> print(entry.toString()));
Daniele Moro10c45cc2021-06-24 18:17:30 +020053 }
54 }
55}