root / snf-cyclades-app / synnefo / api / management / commands / port-inspect.py @ 9835a70d
History | View | Annotate | Download (2.7 kB)
1 | d5a4a8d1 | Christos Stavrakakis | # Copyright 2013 GRNET S.A. All rights reserved.
|
---|---|---|---|
2 | 5fa91dc4 | Marios Kogias | #
|
3 | 5fa91dc4 | Marios Kogias | # Redistribution and use in source and binary forms, with or
|
4 | 5fa91dc4 | Marios Kogias | # without modification, are permitted provided that the following
|
5 | 5fa91dc4 | Marios Kogias | # conditions are met:
|
6 | 5fa91dc4 | Marios Kogias | #
|
7 | 5fa91dc4 | Marios Kogias | # 1. Redistributions of source code must retain the above
|
8 | 5fa91dc4 | Marios Kogias | # copyright notice, this list of conditions and the following
|
9 | 5fa91dc4 | Marios Kogias | # disclaimer.
|
10 | 5fa91dc4 | Marios Kogias | #
|
11 | 5fa91dc4 | Marios Kogias | # 2. Redistributions in binary form must reproduce the above
|
12 | 5fa91dc4 | Marios Kogias | # copyright notice, this list of conditions and the following
|
13 | 5fa91dc4 | Marios Kogias | # disclaimer in the documentation and/or other materials
|
14 | 5fa91dc4 | Marios Kogias | # provided with the distribution.
|
15 | 5fa91dc4 | Marios Kogias | #
|
16 | 5fa91dc4 | Marios Kogias | # THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
|
17 | 5fa91dc4 | Marios Kogias | # OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
18 | 5fa91dc4 | Marios Kogias | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
19 | 5fa91dc4 | Marios Kogias | # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
|
20 | 5fa91dc4 | Marios Kogias | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
21 | 5fa91dc4 | Marios Kogias | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
22 | 5fa91dc4 | Marios Kogias | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
23 | 5fa91dc4 | Marios Kogias | # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
24 | 5fa91dc4 | Marios Kogias | # AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
25 | 5fa91dc4 | Marios Kogias | # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
26 | 5fa91dc4 | Marios Kogias | # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
27 | 5fa91dc4 | Marios Kogias | # POSSIBILITY OF SUCH DAMAGE.
|
28 | 5fa91dc4 | Marios Kogias | #
|
29 | 5fa91dc4 | Marios Kogias | # The views and conclusions contained in the software and
|
30 | 5fa91dc4 | Marios Kogias | # documentation are those of the authors and should not be
|
31 | 5fa91dc4 | Marios Kogias | # interpreted as representing official policies, either expressed
|
32 | 5fa91dc4 | Marios Kogias | # or implied, of GRNET S.A.
|
33 | 5fa91dc4 | Marios Kogias | |
34 | 5fa91dc4 | Marios Kogias | from optparse import make_option |
35 | 5fa91dc4 | Marios Kogias | from django.core.management.base import BaseCommand, CommandError |
36 | 5fa91dc4 | Marios Kogias | |
37 | 86961519 | Christos Stavrakakis | from synnefo.management.common import convert_api_faults |
38 | 09b76b7e | Christos Stavrakakis | from synnefo.management import pprint, common |
39 | 86961519 | Christos Stavrakakis | |
40 | 86961519 | Christos Stavrakakis | |
41 | 5fa91dc4 | Marios Kogias | class Command(BaseCommand): |
42 | 5fa91dc4 | Marios Kogias | help = "Inspect a port on DB and Ganeti"
|
43 | 5fa91dc4 | Marios Kogias | args = "<port ID>"
|
44 | 5fa91dc4 | Marios Kogias | |
45 | 5fa91dc4 | Marios Kogias | option_list = BaseCommand.option_list + ( |
46 | 5fa91dc4 | Marios Kogias | make_option( |
47 | 5fa91dc4 | Marios Kogias | '--jobs',
|
48 | 5fa91dc4 | Marios Kogias | action='store_true',
|
49 | 5fa91dc4 | Marios Kogias | dest='jobs',
|
50 | 5fa91dc4 | Marios Kogias | default=False,
|
51 | 5fa91dc4 | Marios Kogias | help="Show non-archived jobs concerning port."),
|
52 | 5fa91dc4 | Marios Kogias | make_option( |
53 | 5fa91dc4 | Marios Kogias | '--displayname',
|
54 | 5fa91dc4 | Marios Kogias | action='store_true',
|
55 | 5fa91dc4 | Marios Kogias | dest='displayname',
|
56 | 5fa91dc4 | Marios Kogias | default=False,
|
57 | 5fa91dc4 | Marios Kogias | help="Display both uuid and display name"),
|
58 | 5fa91dc4 | Marios Kogias | ) |
59 | 5fa91dc4 | Marios Kogias | |
60 | 5fa91dc4 | Marios Kogias | @convert_api_faults
|
61 | 5fa91dc4 | Marios Kogias | def handle(self, *args, **options): |
62 | 5fa91dc4 | Marios Kogias | if len(args) != 1: |
63 | 5fa91dc4 | Marios Kogias | raise CommandError("Please provide a port ID") |
64 | 5fa91dc4 | Marios Kogias | |
65 | 09b76b7e | Christos Stavrakakis | port = common.get_port(args[0])
|
66 | 5fa91dc4 | Marios Kogias | |
67 | d5a4a8d1 | Christos Stavrakakis | pprint.pprint_port(port, stdout=self.stdout)
|
68 | 86961519 | Christos Stavrakakis | self.stdout.write('\n\n') |
69 | 9c15e488 | Christos Stavrakakis | |
70 | d5a4a8d1 | Christos Stavrakakis | pprint.pprint_port_ips(port, stdout=self.stdout)
|
71 | 86961519 | Christos Stavrakakis | self.stdout.write('\n\n') |
72 | 86961519 | Christos Stavrakakis | |
73 | d5a4a8d1 | Christos Stavrakakis | pprint.pprint_port_in_ganeti(port, stdout=self.stdout) |