2014-12-19 19:50:58 |
Steve Martinelli |
description |
According to the api http://specs.openstack.org/openstack/keystone-specs/api/v3/identity-api-v3.html only the service type is mandatory.
name, description and enabled field are optional.
openstack-client should not require the name as it is optional in the service, this is to make the validation consistent.
$ openstack service create --type service_type_1
usage: openstack service create [-h] [-f {html,json,shell,table,value,yaml}]
[-c COLUMN] [--max-width <integer>]
[--prefix PREFIX] --type <service-type>
[--description <service-description>]
<service-name>
openstack service create: error: too few arguments
Type should be the only field required and name should be optional.
This is for keystone v3. |
For v2.0, the API says the following, but is unclear about what is required vs. optional
http://developer.openstack.org/api-ref-identity-v2.html
{
"OS-KSADM:service": {
"id": "123",
"name": "nova",
"type": "compute",
"description": "OpenStack Compute Service"
}
}
Based on the v3 API, type should be the only argument that is required.
However, looking at what is implemented, there is very little validation going on. 'id' is assigned set at the controller level:
https://github.com/openstack/keystone/blob/master/keystone/catalog/controllers.py#L53-L60
And 'enabled' which is missing from the API is set at the manager level:
https://github.com/openstack/keystone/blob/master/keystone/catalog/core.py#L145-L147
There is no validation performed at any level, leaving it up to the backends, for the SQL backend for instance, only 'enabled' is required:
https://github.com/openstack/keystone/blob/master/keystone/catalog/backends/sql.py#L57-L65
class Service(sql.ModelBase, sql.DictBase):
__tablename__ = 'service'
attributes = ['id', 'type', 'enabled']
id = sql.Column(sql.String(64), primary_key=True)
type = sql.Column(sql.String(255))
enabled = sql.Column(sql.Boolean, nullable=False, default=True,
server_default=sqlalchemy.sql.expression.true())
extra = sql.Column(sql.JsonBlob())
endpoints = sqlalchemy.orm.relationship("Endpoint", backref="service")
Which means the following call works, and is very useless:
$ http post http://localhost:35357/v2.0/OS-KSADM/services '{"OS-KSADM:service": {}}' --x-auth-token=ADMIN
{
"OS-KSADM:service": {
"type": null,
"enabled": true,
"id": "fe937fd1152f494d88edd89e3adbfe1f"
}
}
Keystoneclient requires name, type and description.
https://github.com/openstack/python-keystoneclient/blob/master/keystoneclient/v2_0/services.py#L38-L43
It should probably at least default some of those to None.
Lastly OpenstackClient has only 'name' as a required argument.
$ openstack service create --type service_type_1
usage: openstack service create [-h] [-f {html,json,shell,table,value,yaml}]
[-c COLUMN] [--max-width <integer>]
[--prefix PREFIX] --type <service-type>
[--description <service-description>]
<service-name>
openstack service create: error: too few arguments
We should probably make this similar to v3, where the only required argument is 'type', and name/description are optional. |
|