← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1404073] Re: type should be required for v2.0 service create

 

** Changed in: python-keystoneclient
    Milestone: None => 1.1.0

** Changed in: python-keystoneclient
   Importance: Undecided => Low

** Changed in: python-keystoneclient
       Status: Fix Committed => Fix Released

-- 
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to Keystone.
https://bugs.launchpad.net/bugs/1404073

Title:
  type should be required for v2.0 service create

Status in OpenStack Identity (Keystone):
  Won't Fix
Status in Python client library for Keystone:
  Fix Released
Status in OpenStack Command Line Client:
  Fix Released

Bug description:
  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.

To manage notifications about this bug go to:
https://bugs.launchpad.net/keystone/+bug/1404073/+subscriptions