Revision a53b5141
b/snf-cyclades-app/synnefo/api/management/commands/port-list.py | ||
---|---|---|
31 | 31 |
# interpreted as representing official policies, either expressed |
32 | 32 |
# or implied, of GRNET S.A. |
33 | 33 |
|
34 |
#from optparse import make_option
|
|
34 |
from optparse import make_option |
|
35 | 35 |
|
36 | 36 |
from snf_django.management.commands import ListCommand |
37 | 37 |
from synnefo.db.models import NetworkInterface |
... | ... | |
45 | 45 |
class Command(ListCommand): |
46 | 46 |
help = "List ports" |
47 | 47 |
|
48 |
option_list = ListCommand.option_list + ( |
|
49 |
make_option( |
|
50 |
'--public', |
|
51 |
dest='public', |
|
52 |
action='store_true', |
|
53 |
default=False, |
|
54 |
help="List only ports connected to public networks"), |
|
55 |
make_option( |
|
56 |
'--server', |
|
57 |
dest='server_id', |
|
58 |
default=False, |
|
59 |
help="List ports connected to specific server"), |
|
60 |
) |
|
61 |
|
|
48 | 62 |
object_class = NetworkInterface |
49 | 63 |
user_uuid_field = "userid" |
50 | 64 |
astakos_url = ASTAKOS_BASE_URL |
... | ... | |
72 | 86 |
|
73 | 87 |
fields = ["id", "name", "user.uuid", "mac_address", "network", |
74 | 88 |
"device_id", "fixed_ips", "state"] |
89 |
|
|
90 |
def handle_args(self, *args, **options): |
|
91 |
if options["public"]: |
|
92 |
self.filters["network__public"] = True |
|
93 |
|
|
94 |
if options["server_id"]: |
|
95 |
self.filters["machine"] = options["server_id"] |
Also available in: Unified diff