Revision 3524241a snf-cyclades-app/synnefo/logic/management/commands/network-inspect.py
b/snf-cyclades-app/synnefo/logic/management/commands/network-inspect.py | ||
---|---|---|
35 | 35 |
|
36 | 36 |
from django.core.management.base import BaseCommand, CommandError |
37 | 37 |
|
38 |
from synnefo.db.models import Backend, Network, BackendNetwork |
|
39 |
from synnefo.util.rapi import GanetiApiError |
|
38 |
from synnefo.db.models import (Backend, Network, BackendNetwork, |
|
39 |
pooled_rapi_client) |
|
40 |
from synnefo.logic.rapi import GanetiApiError |
|
40 | 41 |
from util import pool_map_chunks |
41 | 42 |
|
43 |
|
|
42 | 44 |
class Command(BaseCommand): |
43 | 45 |
help = "Inspect a network on DB and Ganeti." |
44 | 46 |
|
... | ... | |
88 | 90 |
self.stdout.write(sep) |
89 | 91 |
|
90 | 92 |
for backend in Backend.objects.exclude(offline=True): |
91 |
client = backend.client
|
|
92 |
try: |
|
93 |
g_net = client.GetNetwork(net.backend_id) |
|
94 |
self.stdout.write("Backend: %s\n" % backend.clustername) |
|
95 |
print json.dumps(g_net, indent=2) |
|
96 |
self.stdout.write(sep) |
|
97 |
except GanetiApiError as e: |
|
98 |
if e.code == 404: |
|
99 |
self.stdout.write('Network does not exist in backend %s\n' % |
|
100 |
backend.clustername) |
|
101 |
else: |
|
102 |
raise e |
|
93 |
with pooled_rapi_client(backend) as client:
|
|
94 |
try:
|
|
95 |
g_net = client.GetNetwork(net.backend_id)
|
|
96 |
self.stdout.write("Backend: %s\n" % backend.clustername)
|
|
97 |
print json.dumps(g_net, indent=2)
|
|
98 |
self.stdout.write(sep)
|
|
99 |
except GanetiApiError as e:
|
|
100 |
if e.code == 404:
|
|
101 |
self.stdout.write('Network does not exist in backend %s\n' %
|
|
102 |
backend.clustername)
|
|
103 |
else:
|
|
104 |
raise e
|
|
103 | 105 |
|
104 | 106 |
|
105 | 107 |
def splitPoolMap(s, count): |
Also available in: Unified diff