|
7 | 7 | "OPSPlugin", ['name', 'location', 'func', 'section', 'plugin_type'] |
8 | 8 | ) |
9 | 9 |
|
| 10 | + |
| 11 | +class Plugin(object): |
| 12 | + """Generic OPS plugin object""" |
| 13 | + def __init__(self, requires_ops, requires_cli): |
| 14 | + self.requires_ops = requires_ops |
| 15 | + self.requires_cli = requires_cli |
| 16 | + |
| 17 | + |
| 18 | +class CommandPlugin(Plugin): |
| 19 | + """Plugin for subcommands to the OPS CLI""" |
| 20 | + def __init__(self, command, section, requires_ops=(1, 0), |
| 21 | + requires_cli=(0, 1)): |
| 22 | + self.command = command |
| 23 | + self.section = section |
| 24 | + super().__init__(requires_ops, requires_cli) |
| 25 | + |
| 26 | + @property |
| 27 | + def name(self): |
| 28 | + return self.command.name |
| 29 | + |
| 30 | + |
| 31 | +class ParserPlugin(Plugin): |
| 32 | + """Plugin to add a new Parser (top-level stage in YAML parsing""" |
| 33 | + def __init__(self, parser, requires_ops=(1,0), requires_cli=(0,3)): |
| 34 | + self.parser = parser |
| 35 | + super().__init__(requires_ops, requires_cli) |
| 36 | + |
| 37 | + |
| 38 | +class InstanceBuilderPlugin(Plugin): |
| 39 | + """ |
| 40 | + Plugin to add a new object type (InstanceBuilder) to YAML parsing. |
| 41 | + """ |
| 42 | + def __init__(self, yaml_name, instance_builder, requires_ops=(1,0), |
| 43 | + requires_cli=(0,3)): |
| 44 | + self.yaml_name = yaml_name |
| 45 | + self.instance_builder = instance_builder |
| 46 | + super().__init__(requires_ops, requires_cli) |
| 47 | + |
| 48 | + |
10 | 49 | class CLIPluginLoader(object): |
11 | 50 | """Abstract object for CLI plugins |
12 | 51 |
|
|
0 commit comments