ceph / ceph-iscsi-config

NOTICE: moved to https://github.com/ceph/ceph-iscsi
GNU General Public License v3.0
22 stars 28 forks source link

AttributeError: 'GWClient' object has no attribute 'controls' #73

Closed Rjerk closed 6 years ago

Rjerk commented 6 years ago

add host to hostgroup

curl --insecure --user admin:admin -d action=add -d members=iqn.2018-08.com.umcloud.iscsi-gw:host1  -X PUT http://192.168.2.80:5000/api/hostgroup/test

got error: 'GWClient' object has no attribute 'controls'

Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/flask/app.py", line 1836, in __call__
    return self.wsgi_app(environ, start_response)
  File "/usr/lib/python2.7/site-packages/flask/app.py", line 1820, in wsgi_app
    response = self.make_response(self.handle_exception(e))
  File "/usr/lib/python2.7/site-packages/flask/app.py", line 1403, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/lib/python2.7/site-packages/flask/app.py", line 1817, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/lib/python2.7/site-packages/flask/app.py", line 1477, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/lib/python2.7/site-packages/flask/app.py", line 1381, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/lib/python2.7/site-packages/flask/app.py", line 1475, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/lib/python2.7/site-packages/flask/app.py", line 1461, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/usr/bin/rbd-target-api", line 97, in decorated
    return f(*args, **kwargs)
  File "/usr/bin/rbd-target-api", line 1656, in _hostgroup
    grp.apply()
  File "/usr/lib/python2.7/site-packages/ceph_iscsi_config/group.py", line 217, in apply
    self.enforce_policy()
  File "/usr/lib/python2.7/site-packages/ceph_iscsi_config/group.py", line 318, in enforce_policy
    self.update_client(client_iqn, image_list)
  File "/usr/lib/python2.7/site-packages/ceph_iscsi_config/group.py", line 345, in update_client
    client.define_client()                          # sets up tpg lun list
  File "/usr/lib/python2.7/site-packages/ceph_iscsi_config/client.py", line 175, in define_client
    try:
  File "/usr/lib/python2.7/site-packages/ceph_iscsi_config/client.py", line 150, in update_acl_controls
    self.acl.set_attribute('dataout_timeout', '{}'.format(
AttributeError: 'GWClient' object has no attribute 'controls'
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/flask/app.py", line 1836, in __call__
    return self.wsgi_app(environ, start_response)
  File "/usr/lib/python2.7/site-packages/flask/app.py", line 1820, in wsgi_app
    response = self.make_response(self.handle_exception(e))
  File "/usr/lib/python2.7/site-packages/flask/app.py", line 1403, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/lib/python2.7/site-packages/flask/app.py", line 1817, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/lib/python2.7/site-packages/flask/app.py", line 1477, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/lib/python2.7/site-packages/flask/app.py", line 1381, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/lib/python2.7/site-packages/flask/app.py", line 1475, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/lib/python2.7/site-packages/flask/app.py", line 1461, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/usr/bin/rbd-target-api", line 97, in decorated
    return f(*args, **kwargs)
  File "/usr/bin/rbd-target-api", line 1588, in hostgroup
    http_method='put', api_vars=api_vars)
  File "/usr/bin/rbd-target-api", line 1809, in call_api
    fail_msg += api.response.json()['message']
  File "/usr/lib/python2.7/site-packages/requests/models.py", line 802, in json
    return json.loads(self.text, **kwargs)
  File "/usr/lib64/python2.7/json/__init__.py", line 338, in loads
    return _default_decoder.decode(s)
  File "/usr/lib64/python2.7/json/decoder.py", line 366, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib64/python2.7/json/decoder.py", line 384, in raw_decode
    raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded

after add self.controls = {} to GWClient, still got an error:

File "/usr/lib/python2.7/site-packages/ceph_iscsi_config/client.py", line 151, in update_acl_controls
    self.controls['dataout_timeout']))
KeyError: 'dataout_timeout'
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/flask/app.py", line 1836, in __call__
    return self.wsgi_app(environ, start_response)
  File "/usr/lib/python2.7/site-packages/flask/app.py", line 1820, in wsgi_app
    response = self.make_response(self.handle_exception(e))
  File "/usr/lib/python2.7/site-packages/flask/app.py", line 1403, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/lib/python2.7/site-packages/flask/app.py", line 1817, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/lib/python2.7/site-packages/flask/app.py", line 1477, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/lib/python2.7/site-packages/flask/app.py", line 1381, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/lib/python2.7/site-packages/flask/app.py", line 1475, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/lib/python2.7/site-packages/flask/app.py", line 1461, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/usr/bin/rbd-target-api", line 97, in decorated
    return f(*args, **kwargs)
  File "/usr/bin/rbd-target-api", line 1656, in _hostgroup
    grp.apply()
  File "/usr/lib/python2.7/site-packages/ceph_iscsi_config/group.py", line 217, in apply
    self.enforce_policy()
  File "/usr/lib/python2.7/site-packages/ceph_iscsi_config/group.py", line 318, in enforce_policy
    self.update_client(client_iqn, image_list)
  File "/usr/lib/python2.7/site-packages/ceph_iscsi_config/group.py", line 345, in update_client
    client.define_client()                          # sets up tpg lun list
  File "/usr/lib/python2.7/site-packages/ceph_iscsi_config/client.py", line 176, in define_client
    self.update_acl_controls()
  File "/usr/lib/python2.7/site-packages/ceph_iscsi_config/client.py", line 151, in update_acl_controls
    self.controls['dataout_timeout']))
KeyError: 'dataout_timeout'
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/flask/app.py", line 1836, in __call__
    return self.wsgi_app(environ, start_response)
  File "/usr/lib/python2.7/site-packages/flask/app.py", line 1820, in wsgi_app
    response = self.make_response(self.handle_exception(e))
  File "/usr/lib/python2.7/site-packages/flask/app.py", line 1403, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/lib/python2.7/site-packages/flask/app.py", line 1817, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/lib/python2.7/site-packages/flask/app.py", line 1477, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/lib/python2.7/site-packages/flask/app.py", line 1381, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/lib/python2.7/site-packages/flask/app.py", line 1475, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/lib/python2.7/site-packages/flask/app.py", line 1461, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/usr/bin/rbd-target-api", line 97, in decorated
    return f(*args, **kwargs)
  File "/usr/bin/rbd-target-api", line 1588, in hostgroup
    http_method='put', api_vars=api_vars)
  File "/usr/bin/rbd-target-api", line 1809, in call_api
    fail_msg += api.response.json()['message']
  File "/usr/lib/python2.7/site-packages/requests/models.py", line 802, in json
    return json.loads(self.text, **kwargs)
  File "/usr/lib64/python2.7/json/__init__.py", line 338, in loads
    return _default_decoder.decode(s)
  File "/usr/lib64/python2.7/json/decoder.py", line 366, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib64/python2.7/json/decoder.py", line 384, in raw_decode
    raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded
dillaman commented 6 years ago

Looks like that client.define_client() call should be client.manage('reconfigure')

Rjerk commented 6 years ago

yes it works, thx~

I pull a request here to fix it: #74