<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def register_service(email, password, organisation_id, name=None, service_type=None, accounts_url=None, location=None, config=None):
 """Register a service with the accounts service \b EMAIL: a user's email PASSWORD: a user's password ORGANISATION_ID: ID of the service's parent organisation """

    accounts_url = accounts_url or getattr(options, 'url_accounts', None)
    name = name or getattr(options, 'name', None)
    service_type = service_type or getattr(options, 'service_type', None)
    location = location or ('https://localhost:' + str(getattr(options, 'port')))
    config = config or 'config'

    if not accounts_url:
        raise click.ClickException(click.style('accounts_url not defined',
                                               fg='red'))

    if not name:
        raise click.ClickException(click.style('service name not defined',
                                               fg='red'))

    if not service_type:
        raise click.ClickException(click.style('service type not defined',
                                               fg='red'))

    try:
        client = _get_accounts_client(accounts_url, email, password)
        service_id = _create_service(client, organisation_id, name, location, service_type)
        client_secret = _get_client_secret(client, service_id)
        _update_local_conf(config, service_id, client_secret)
    except httpclient.HTTPError as exc:
        try:
            msg = exc.response.body
        except AttributeError:
            msg = exc.message
        raise click.ClickException(click.style(msg, fg='red'))
    except socket.error as exc:
        raise click.ClickException(click.style(exc.strerror, fg='red'))

    click.echo(click.style('\n{} service registered\n'.format(name),
                           fg='green'))