from .iscsi_client import IscsiClient
from .iscsi_config import IscsiGatewaysConfig, IscsiGatewayAlreadyExists, InvalidServiceUrl, \
- ManagedByOrchestratorException, IscsiGatewayDoesNotExist, IscsiGatewayInUse
+ ManagedByOrchestratorException, IscsiGatewayDoesNotExist
from ..rest_client import RequestException
@CLIWriteCommand('dashboard iscsi-gateway-add',
- 'name=service_url,type=CephString',
+ 'name=service_url,type=CephString '
+ 'name=name,type=CephString,req=false',
'Add iSCSI gateway configuration')
-def add_iscsi_gateway(_, service_url):
+def add_iscsi_gateway(_, service_url, name=None):
try:
IscsiGatewaysConfig.validate_service_url(service_url)
- name = IscsiClient.instance(service_url=service_url).get_hostname()['data']
+ if name is None:
+ name = IscsiClient.instance(service_url=service_url).get_hostname()['data']
IscsiGatewaysConfig.add_gateway(name, service_url)
return 0, 'Success', ''
except IscsiGatewayAlreadyExists as ex:
'Remove iSCSI gateway configuration')
def remove_iscsi_gateway(_, name):
try:
- try:
- iscsi_config = IscsiClient.instance(gateway_name=name).get_config()
- if name in iscsi_config['gateways']:
- raise IscsiGatewayInUse(name)
- except RequestException:
- pass
IscsiGatewaysConfig.remove_gateway(name)
return 0, 'Success', ''
- except IscsiGatewayInUse as ex:
- return -errno.EBUSY, '', str(ex)
except IscsiGatewayDoesNotExist as ex:
return -errno.ENOENT, '', str(ex)
except ManagedByOrchestratorException as ex: