Revision 2333a2c4 snf-cyclades-app/synnefo/logic/management/commands/backend-add.py
b/snf-cyclades-app/synnefo/logic/management/commands/backend-add.py | ||
---|---|---|
37 | 37 |
update_resources, |
38 | 38 |
create_network_synced, |
39 | 39 |
connect_network_synced) |
40 |
from synnefo.logic.rapi import GanetiApiError, GanetiRapiClient
|
|
40 |
from synnefo.management.common import check_backend_credentials
|
|
41 | 41 |
|
42 | 42 |
|
43 | 43 |
class Command(BaseCommand): |
... | ... | |
74 | 74 |
|
75 | 75 |
# Ensure correctness of credentials |
76 | 76 |
if options['check']: |
77 |
self.stdout.write('Checking connectivity and credentials.\n') |
|
78 |
try: |
|
79 |
client = GanetiRapiClient(clustername, port, username, password) |
|
80 |
# This command will raise an exception if there is no |
|
81 |
# write-access |
|
82 |
client.ModifyCluster() |
|
83 |
except GanetiApiError as e: |
|
84 |
self.stdout.write('Check failed:\n%s\n' % e) |
|
85 |
return |
|
86 |
else: |
|
87 |
self.stdout.write('Check passed.\n') |
|
88 |
|
|
89 |
info = client.GetInfo() |
|
90 |
info_name = info['name'] |
|
91 |
if info_name != clustername: |
|
92 |
raise CommandError("Invalid clustername value. Please use the" |
|
93 |
" Ganeti Cluster name: %s" % info_name) |
|
77 |
check_backend_credentials(clustername, port, username, password) |
|
94 | 78 |
|
95 | 79 |
# Create the new backend in database |
96 | 80 |
try: |
Also available in: Unified diff