/usr/lib/python2.7/dist-packages/gnocchiclient/v1/archive_policy_rule_cli.py is in python-gnocchiclient 7.0.1-0ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | #
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from cliff import command
from cliff import lister
from cliff import show
from gnocchiclient import utils
class CliArchivePolicyRuleList(lister.Lister):
"""List archive policy rules"""
COLS = ('name', 'archive_policy_name', 'metric_pattern')
def take_action(self, parsed_args):
ap_rules = utils.get_client(self).archive_policy_rule.list()
return utils.list2cols(self.COLS, ap_rules)
class CliArchivePolicyRuleShow(show.ShowOne):
"""Show an archive policy rule"""
def get_parser(self, prog_name):
parser = super(CliArchivePolicyRuleShow, self).get_parser(prog_name)
parser.add_argument("name",
help="Name of the archive policy rule")
return parser
def take_action(self, parsed_args):
ap_rule = utils.get_client(self).archive_policy_rule.get(
name=parsed_args.name)
return self.dict2columns(ap_rule)
class CliArchivePolicyRuleCreate(show.ShowOne):
"""Create an archive policy rule"""
def get_parser(self, prog_name):
parser = super(CliArchivePolicyRuleCreate, self).get_parser(prog_name)
parser.add_argument("name",
help="Rule name")
parser.add_argument("-a", "--archive-policy-name",
dest="archive_policy_name",
required=True,
help="Archive policy name")
parser.add_argument("-m", "--metric-pattern",
dest="metric_pattern", required=True,
help="Wildcard of metric name to match")
return parser
def take_action(self, parsed_args):
rule = utils.dict_from_parsed_args(
parsed_args, ["name", "metric_pattern", "archive_policy_name"])
policy = utils.get_client(self).archive_policy_rule.create(rule)
return self.dict2columns(policy)
class CliArchivePolicyRuleUpdate(show.ShowOne):
"""Update an archive policy rule"""
def get_parser(self, prog_name):
parser = super(CliArchivePolicyRuleUpdate, self).get_parser(prog_name)
parser.add_argument("name",
help="Rule name")
parser.add_argument("-n", "--name",
dest="new_name",
required=True,
help="New rule name")
return parser
def take_action(self, parsed_args):
policy = utils.get_client(self).archive_policy_rule.update(
parsed_args.name,
parsed_args.new_name)
return self.dict2columns(policy)
class CliArchivePolicyRuleDelete(command.Command):
"""Delete an archive policy rule"""
def get_parser(self, prog_name):
parser = super(CliArchivePolicyRuleDelete, self).get_parser(prog_name)
parser.add_argument("name",
help="Name of the archive policy rule")
return parser
def take_action(self, parsed_args):
utils.get_client(self).archive_policy_rule.delete(parsed_args.name)
|