Last active
August 29, 2015 14:00
-
-
Save mahmoudimus/11159920 to your computer and use it in GitHub Desktop.
vizor-work
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from cement.core import foundation, controller, handler | |
class VizorBaseController(controller.CementBaseController): | |
class Meta: | |
label = 'base' | |
description = 'Vizor is a cloud visualizer' | |
class VizorScanController(controller.CementBaseController): | |
class Meta: | |
label = 'scanner' | |
stacked_on = 'base' | |
stacked_type = 'nested' | |
description = ( | |
'The scanner sub-command is used to scan either a ' | |
'static source (e.g. a file generated by a cli from the provider) ' | |
'or a dynamic source.') | |
arguments = [ | |
(['--unknown'], dict( | |
action='store_true', help='Include unknown nodes')), | |
(['--out'], dict( | |
default='output.dot', help='Dot output filename')), | |
] | |
@controller.expose(hide=True) | |
def default(self): | |
# visible commmands is the sub commands | |
self.app.args.print_help() | |
# vizor scan aws --output=|--only= | |
class VizorAWSScanController(VizorScanController): | |
class Meta: | |
label = 'aws' | |
stacked_on = 'scanner' | |
stacked_type = 'nested' | |
description = 'Scans AWS' | |
arguments = VizorScanController.Meta.arguments + [ | |
(['--ec2-credentials'], dict(help='Uec2 credentials location')) | |
] | |
@controller.expose(help='connects to the cloud provider to scan') | |
def default(self): | |
print self.app.pargs | |
print 'scanning dynamically' | |
# vizor scan file | |
class VizorFileScanController(VizorScanController): | |
class Meta: | |
label = 'file' | |
stacked_on = 'scanner' | |
stacked_type = 'nested' | |
description = 'Scans a file' | |
@controller.expose(help='statically scans a file output') | |
def default(self): | |
print 'static scanning' | |
class VizorRenderController(controller.CementBaseController): | |
class Meta: | |
label = 'render' | |
stacked_on = 'base' | |
stacked_type = 'nested' | |
@controller.expose(help='render', hide=True) | |
def default(self): | |
print 'inside rendering' | |
class VizorApp(foundation.CementApp): | |
class Meta: | |
label = 'vizor' | |
def __enter__(self): | |
return self | |
def __exit__(self, exc_type, exc_val, exc_tb): | |
self.close() | |
def main(): | |
with VizorApp(base_controller=VizorBaseController) as app: | |
handler.register(VizorScanController) | |
handler.register(VizorAWSScanController) | |
handler.register(VizorFileScanController) | |
handler.register(VizorRenderController) | |
app.setup() | |
app.run() | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment