blob: 02ecab376f849a543e3f9cd7e142b62cabacb03b [file] [log] [blame]
Jordan Haltermanf17d1732019-09-30 01:36:19 -07001/*
2 * Copyright 2015-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 */
16package org.onosproject.cli.net;
17
18import org.apache.karaf.shell.api.action.Command;
19import org.apache.karaf.shell.api.action.Option;
20import org.apache.karaf.shell.api.action.lifecycle.Service;
21import org.onosproject.cli.AbstractShellCommand;
22import org.onosproject.cluster.PartitionId;
23import org.onosproject.store.primitives.PartitionAdminService;
24
25/**
26 * Command to force a snapshot of the partitions.
27 */
28@Service
29@Command(scope = "onos", name = "snapshot-partitions",
30 description = "Force snapshot partitions")
31public class PartitionsSnapshotCommand extends AbstractShellCommand {
32
33 @Option(name = "-p", aliases = "--partition",
34 description = "The partition to snapshot",
35 required = false, multiValued = false)
36 private Integer partitionId;
37
38 @Override
39 protected void doExecute() {
40 PartitionAdminService partitionAdminService = get(PartitionAdminService.class);
41 if (partitionId != null) {
42 partitionAdminService.snapshot(PartitionId.from(partitionId));
43 } else {
44 partitionAdminService.snapshot();
45 }
46 }
47}