'Create an iSCSI initiator.'

def create_initiator(self, initiator, alias, chapuser=None, chapsecret=None):

    svc = ('/api/san/v1/iscsi/initiators/alias=' + alias)
    ret = self.rclient.get(svc)
    if (ret.status != restclient.Status.OK):
        svc = '/api/san/v1/iscsi/initiators'
        arg = {'initiator': initiator, 'alias': alias}
        if (chapuser and (chapuser != '') and chapsecret and (chapsecret != '')):
            arg.update({'chapuser': chapuser, 'chapsecret': chapsecret})
        ret = self.rclient.post(svc, arg)
        if (ret.status != restclient.Status.CREATED):
            exception_msg = (_('Error    Creating    Initiator:    %(initiator)s    on    Alias:    %(alias)s    Return    code:    %(ret.status)d    Message:    %(ret.data)s    .') % {'initiator': initiator, 'alias': alias, 'ret.status': ret.status, 'ret.data': ret.data})
            LOG.error(exception_msg)
            raise exception.VolumeBackendAPIException(data=exception_msg)
