root / snf-cyclades-app / synnefo / logic / management / commands / subnet-inspect.py @ a6e6fe48
History | View | Annotate | Download (2.1 kB)
1 | e4758367 | Dionysis Grigoropoulos | # Copyright 2013 GRNET S.A. All rights reserved.
|
---|---|---|---|
2 | e4758367 | Dionysis Grigoropoulos | #
|
3 | e4758367 | Dionysis Grigoropoulos | # Redistribution and use in source and binary forms, with or
|
4 | e4758367 | Dionysis Grigoropoulos | # without modification, are permitted provided that the following
|
5 | e4758367 | Dionysis Grigoropoulos | # conditions are met:
|
6 | e4758367 | Dionysis Grigoropoulos | #
|
7 | e4758367 | Dionysis Grigoropoulos | # 1. Redistributions of source code must retain the above
|
8 | e4758367 | Dionysis Grigoropoulos | # copyright notice, this list of conditions and the following
|
9 | e4758367 | Dionysis Grigoropoulos | # disclaimer.
|
10 | e4758367 | Dionysis Grigoropoulos | #
|
11 | e4758367 | Dionysis Grigoropoulos | # 2. Redistributions in binary form must reproduce the above
|
12 | e4758367 | Dionysis Grigoropoulos | # copyright notice, this list of conditions and the following
|
13 | e4758367 | Dionysis Grigoropoulos | # disclaimer in the documentation and/or other materials
|
14 | e4758367 | Dionysis Grigoropoulos | # provided with the distribution.
|
15 | e4758367 | Dionysis Grigoropoulos | #
|
16 | e4758367 | Dionysis Grigoropoulos | # THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
|
17 | e4758367 | Dionysis Grigoropoulos | # OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
18 | e4758367 | Dionysis Grigoropoulos | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
19 | e4758367 | Dionysis Grigoropoulos | # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
|
20 | e4758367 | Dionysis Grigoropoulos | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
21 | e4758367 | Dionysis Grigoropoulos | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
22 | e4758367 | Dionysis Grigoropoulos | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
23 | e4758367 | Dionysis Grigoropoulos | # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
24 | e4758367 | Dionysis Grigoropoulos | # AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
25 | e4758367 | Dionysis Grigoropoulos | # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
26 | e4758367 | Dionysis Grigoropoulos | # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
27 | e4758367 | Dionysis Grigoropoulos | # POSSIBILITY OF SUCH DAMAGE.
|
28 | e4758367 | Dionysis Grigoropoulos | #
|
29 | e4758367 | Dionysis Grigoropoulos | # The views and conclusions contained in the software and
|
30 | e4758367 | Dionysis Grigoropoulos | # documentation are those of the authors and should not be
|
31 | e4758367 | Dionysis Grigoropoulos | # interpreted as representing official policies, either expressed
|
32 | e4758367 | Dionysis Grigoropoulos | # or implied, of GRNET S.A.
|
33 | e4758367 | Dionysis Grigoropoulos | |
34 | a6e6fe48 | Christos Stavrakakis | #from optparse import make_option
|
35 | e4758367 | Dionysis Grigoropoulos | |
36 | e4758367 | Dionysis Grigoropoulos | from django.core.management.base import BaseCommand, CommandError |
37 | e4758367 | Dionysis Grigoropoulos | from synnefo.management import pprint, common |
38 | e4758367 | Dionysis Grigoropoulos | |
39 | e4758367 | Dionysis Grigoropoulos | |
40 | e4758367 | Dionysis Grigoropoulos | class Command(BaseCommand): |
41 | e4758367 | Dionysis Grigoropoulos | help = "Inspect a subnet on DB and Ganeti."
|
42 | 689d7a07 | Dionysis Grigoropoulos | args = "<Subnet ID>"
|
43 | e4758367 | Dionysis Grigoropoulos | option_list = BaseCommand.option_list |
44 | e4758367 | Dionysis Grigoropoulos | |
45 | e4758367 | Dionysis Grigoropoulos | def handle(self, *args, **options): |
46 | e4758367 | Dionysis Grigoropoulos | if len(args) != 1: |
47 | e4758367 | Dionysis Grigoropoulos | raise CommandError("Please provide a subnet ID.") |
48 | e4758367 | Dionysis Grigoropoulos | |
49 | a6e6fe48 | Christos Stavrakakis | subnet = common.get_resource("subnet", args[0]) |
50 | e4758367 | Dionysis Grigoropoulos | |
51 | e4758367 | Dionysis Grigoropoulos | pprint.pprint_subnet_in_db(subnet, stdout=self.stdout)
|
52 | e4758367 | Dionysis Grigoropoulos | self.stdout.write("\n\n") |
53 | e4758367 | Dionysis Grigoropoulos | pprint.pprint_ippool(subnet, stdout=self.stdout) |