Revision 2333a2c4 snf-cyclades-app/synnefo/management/common.py

b/snf-cyclades-app/synnefo/management/common.py
43 43
from synnefo.api.faults import ItemNotFound
44 44
from django.core.exceptions import FieldError
45 45

  
46

  
47 46
from synnefo.api.util import validate_network_size
48 47
from synnefo.settings import MAX_CIDR_BLOCK
48
from synnefo.logic.rapi import GanetiApiError, GanetiRapiClient
49 49

  
50 50

  
51 51
def format_bool(b):
......
201 201
        return objects.exclude(**exclude_dict)
202 202
    except FieldError as e:
203 203
        raise CommandError(e)
204

  
205

  
206
def check_backend_credentials(clustername, port, username, password):
207
    try:
208
        client = GanetiRapiClient(clustername, port, username, password)
209
        # This command will raise an exception if there is no
210
        # write-access
211
        client.ModifyCluster()
212
    except GanetiApiError as e:
213
        raise CommandError(e)
214

  
215
    info = client.GetInfo()
216
    info_name = info['name']
217
    if info_name != clustername:
218
        raise CommandError("Invalid clustername value. Please use the"
219
                           " Ganeti Cluster name: %s" % info_name)

Also available in: Unified diff