Adds `resources` field for flavors.
The `resources` field is intended to be used to reference baremetal node resource classes and also other generic resources in the cloud tracked by placement. Partially Implements: bp new-flavor Change-Id: I4e8fe15aed612e62cec96d1acad236cd0924d597
This commit is contained in:
parent
260361c5f4
commit
fc005946a3
|
@ -34,6 +34,7 @@ Response
|
|||
- name: flavor_name
|
||||
- links: links
|
||||
- description: flavor_description
|
||||
- resources: flavor_resources
|
||||
- uuid: flavor_uuid
|
||||
- created_at: created_at
|
||||
- updated_at: updated_at
|
||||
|
@ -68,6 +69,7 @@ Request
|
|||
|
||||
- name: flavor_name
|
||||
- description: flavor_description
|
||||
- resources: flavor_resources
|
||||
- extra_specs: flavor_extra_specs
|
||||
- is_public: flavor_is_public_not_required
|
||||
- disabled: flavor_disabled
|
||||
|
@ -85,6 +87,7 @@ Response
|
|||
- name: flavor_name
|
||||
- links: links
|
||||
- description: flavor_description
|
||||
- resources: flavor_resources
|
||||
- uuid: flavor_uuid
|
||||
- created_at: created_at
|
||||
- updated_at: updated_at
|
||||
|
@ -135,6 +138,7 @@ Response
|
|||
- name: flavor_name
|
||||
- links: links
|
||||
- description: flavor_description
|
||||
- resources: flavor_resources
|
||||
- uuid: flavor_uuid
|
||||
- created_at: created_at
|
||||
- updated_at: updated_at
|
||||
|
@ -173,6 +177,7 @@ Response
|
|||
- name: flavor_name
|
||||
- links: links
|
||||
- description: flavor_description
|
||||
- resources: flavor_resources
|
||||
- uuid: flavor_uuid
|
||||
- created_at: created_at
|
||||
- updated_at: updated_at
|
||||
|
|
|
@ -180,6 +180,13 @@ flavor_name:
|
|||
in: body
|
||||
required: true
|
||||
type: string
|
||||
flavor_resources:
|
||||
description: |
|
||||
A dict of key and value pairs associate with the flavor including the resource
|
||||
name and the quantity.
|
||||
in: body
|
||||
required: true
|
||||
type: string
|
||||
flavor_uuid:
|
||||
description: |
|
||||
The UUID of the flavor.
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
{
|
||||
"name": "test_flavor",
|
||||
"description": "this is a test flavor",
|
||||
"resources": {
|
||||
"CUSTOM_BAREMETAL_GOLD": 1
|
||||
},
|
||||
"extra_specs": {
|
||||
"capabilities": "boot_mode:bios"
|
||||
},
|
||||
|
|
|
@ -1,20 +1,23 @@
|
|||
{
|
||||
"description": "this is a test flavor",
|
||||
"links": [
|
||||
{
|
||||
"href": "http://10.3.150.17:6688/v1/flavors/7de2859d-ec6d-42c7-bb86-9d630ba5ac94",
|
||||
"rel": "self"
|
||||
"description": "this is a test flavor",
|
||||
"links": [
|
||||
{
|
||||
"href": "http://10.3.150.17:6688/v1/flavors/7de2859d-ec6d-42c7-bb86-9d630ba5ac94",
|
||||
"rel": "self"
|
||||
},
|
||||
{
|
||||
"href": "http://10.3.150.17:6688/flavors/7de2859d-ec6d-42c7-bb86-9d630ba5ac94",
|
||||
"rel": "bookmark"
|
||||
}
|
||||
],
|
||||
"resources": {
|
||||
"CUSTOM_BAREMETAL_GOLD": 1
|
||||
},
|
||||
{
|
||||
"href": "http://10.3.150.17:6688/flavors/7de2859d-ec6d-42c7-bb86-9d630ba5ac94",
|
||||
"rel": "bookmark"
|
||||
}
|
||||
],
|
||||
"created_at": "2016-09-27T02:37:21.966342+00:00",
|
||||
"uuid": "7de2859d-ec6d-42c7-bb86-9d630ba5ac94",
|
||||
"updated_at": null,
|
||||
"extra_specs": {},
|
||||
"is_public": true,
|
||||
"disabled": true,
|
||||
"name": "test_flavor"
|
||||
"created_at": "2016-09-27T02:37:21.966342+00:00",
|
||||
"uuid": "7de2859d-ec6d-42c7-bb86-9d630ba5ac94",
|
||||
"updated_at": null,
|
||||
"extra_specs": {},
|
||||
"is_public": true,
|
||||
"disabled": true,
|
||||
"name": "test_flavor"
|
||||
}
|
||||
|
|
|
@ -1,20 +1,23 @@
|
|||
{
|
||||
"description": "this is a test flavor",
|
||||
"links": [
|
||||
{
|
||||
"href": "http://10.3.150.17:6688/v1/flavors/7de2859d-ec6d-42c7-bb86-9d630ba5ac94",
|
||||
"rel": "self"
|
||||
"description": "this is a test flavor",
|
||||
"links": [
|
||||
{
|
||||
"href": "http://10.3.150.17:6688/v1/flavors/7de2859d-ec6d-42c7-bb86-9d630ba5ac94",
|
||||
"rel": "self"
|
||||
},
|
||||
{
|
||||
"href": "http://10.3.150.17:6688/flavors/7de2859d-ec6d-42c7-bb86-9d630ba5ac94",
|
||||
"rel": "bookmark"
|
||||
}
|
||||
],
|
||||
"resources": {
|
||||
"CUSTOM_BAREMETAL_GOLD": 1
|
||||
},
|
||||
{
|
||||
"href": "http://10.3.150.17:6688/flavors/7de2859d-ec6d-42c7-bb86-9d630ba5ac94",
|
||||
"rel": "bookmark"
|
||||
}
|
||||
],
|
||||
"created_at": "2016-09-27T02:37:21.966342+00:00",
|
||||
"uuid": "7de2859d-ec6d-42c7-bb86-9d630ba5ac94",
|
||||
"updated_at": null,
|
||||
"extra_specs": {},
|
||||
"is_public": true,
|
||||
"disabled": false,
|
||||
"name": "test_flavor"
|
||||
"created_at": "2016-09-27T02:37:21.966342+00:00",
|
||||
"uuid": "7de2859d-ec6d-42c7-bb86-9d630ba5ac94",
|
||||
"updated_at": null,
|
||||
"extra_specs": {},
|
||||
"is_public": true,
|
||||
"disabled": false,
|
||||
"name": "test_flavor"
|
||||
}
|
||||
|
|
|
@ -1,20 +1,23 @@
|
|||
{
|
||||
"description": "this is a flavor to be updated",
|
||||
"links": [
|
||||
{
|
||||
"href": "http://10.3.150.17:6688/v1/flavors/7de2859d-ec6d-42c7-bb86-9d630ba5ac94",
|
||||
"rel": "self"
|
||||
"description": "this is a flavor to be updated",
|
||||
"links": [
|
||||
{
|
||||
"href": "http://10.3.150.17:6688/v1/flavors/7de2859d-ec6d-42c7-bb86-9d630ba5ac94",
|
||||
"rel": "self"
|
||||
},
|
||||
{
|
||||
"href": "http://10.3.150.17:6688/flavors/7de2859d-ec6d-42c7-bb86-9d630ba5ac94",
|
||||
"rel": "bookmark"
|
||||
}
|
||||
],
|
||||
"resources": {
|
||||
"CUSTOM_BAREMETAL_GOLD": 1
|
||||
},
|
||||
{
|
||||
"href": "http://10.3.150.17:6688/flavors/7de2859d-ec6d-42c7-bb86-9d630ba5ac94",
|
||||
"rel": "bookmark"
|
||||
}
|
||||
],
|
||||
"created_at": "2016-09-27T02:37:21.966342+00:00",
|
||||
"uuid": "7de2859d-ec6d-42c7-bb86-9d630ba5ac94",
|
||||
"updated_at": null,
|
||||
"extra_specs": {},
|
||||
"is_public": false,
|
||||
"disabled": false,
|
||||
"name": "updated_flavor"
|
||||
"created_at": "2016-09-27T02:37:21.966342+00:00",
|
||||
"uuid": "7de2859d-ec6d-42c7-bb86-9d630ba5ac94",
|
||||
"updated_at": null,
|
||||
"extra_specs": {},
|
||||
"is_public": false,
|
||||
"disabled": false,
|
||||
"name": "updated_flavor"
|
||||
}
|
||||
|
|
|
@ -12,6 +12,9 @@
|
|||
"rel": "bookmark"
|
||||
}
|
||||
],
|
||||
"resources": {
|
||||
"CUSTOM_BAREMETAL_GOLD": 1
|
||||
},
|
||||
"created_at": "2016-09-22T03:21:57+00:00",
|
||||
"uuid": "2ce3df6b-f571-42e8-b6a8-8f7fa1c019ce",
|
||||
"updated_at": null,
|
||||
|
@ -34,6 +37,9 @@
|
|||
"rel": "bookmark"
|
||||
}
|
||||
],
|
||||
"resources": {
|
||||
"CUSTOM_BAREMETAL_GOLD": 1
|
||||
},
|
||||
"created_at": "2016-09-27T02:37:21+00:00",
|
||||
"uuid": "7de2859d-ec6d-42c7-bb86-9d630ba5ac94",
|
||||
"updated_at": null,
|
||||
|
|
|
@ -63,6 +63,9 @@ class Flavor(base.APIBase):
|
|||
disabled = types.boolean
|
||||
"""Indicates whether the flavor is disabled."""
|
||||
|
||||
resources = {wtypes.text: types.jsontype}
|
||||
"""The resources of the flavor"""
|
||||
|
||||
extra_specs = {wtypes.text: types.jsontype}
|
||||
"""The extra specs of the flavor"""
|
||||
|
||||
|
|
|
@ -21,7 +21,8 @@ create_flavor = {
|
|||
"type": "object",
|
||||
"properties": {
|
||||
'name': parameter_types.name,
|
||||
'description': parameter_types.description,
|
||||
'description': {'type': 'string', 'minLength': 1},
|
||||
'resources': parameter_types.resources,
|
||||
'extra_specs': parameter_types.metadata,
|
||||
'is_public': parameter_types.boolean,
|
||||
'disabled': parameter_types.boolean,
|
||||
|
|
|
@ -18,6 +18,12 @@ Common parameter types for validating request Body.
|
|||
"""
|
||||
|
||||
|
||||
positive_integer = {
|
||||
'type': ['integer', 'string'],
|
||||
'pattern': '^[0-9]*$', 'minimum': 1
|
||||
}
|
||||
|
||||
|
||||
name = {
|
||||
'type': 'string', 'minLength': 1, 'maxLength': 255,
|
||||
}
|
||||
|
@ -69,6 +75,15 @@ metadata = {
|
|||
}
|
||||
|
||||
|
||||
resources = {
|
||||
'type': 'object',
|
||||
'patternProperties': {
|
||||
'^[a-zA-Z0-9-_:.]{1,255}$': positive_integer
|
||||
},
|
||||
'additionalProperties': False
|
||||
}
|
||||
|
||||
|
||||
mac_address = {
|
||||
'type': 'string',
|
||||
'pattern': '^([0-9a-fA-F]{2})(:[0-9a-fA-F]{2}){5}$'
|
||||
|
|
|
@ -34,7 +34,8 @@ def upgrade():
|
|||
sa.Column('updated_at', sa.DateTime(), nullable=True),
|
||||
sa.Column('uuid', sa.String(length=36), nullable=False),
|
||||
sa.Column('name', sa.String(length=255), nullable=False),
|
||||
sa.Column('description', sa.String(length=255), nullable=True),
|
||||
sa.Column('description', sa.Text(), nullable=True),
|
||||
sa.Column('resources', sa.Text(), nullable=True),
|
||||
sa.Column('extra_specs', sa.Text(), nullable=True),
|
||||
sa.Column('is_public', sa.Boolean(), nullable=False),
|
||||
sa.Column('disabled', sa.Boolean(), nullable=False),
|
||||
|
|
|
@ -155,7 +155,8 @@ class Flavors(Base):
|
|||
__tablename__ = 'flavors'
|
||||
uuid = Column(String(36), primary_key=True)
|
||||
name = Column(String(255), nullable=False)
|
||||
description = Column(String(255), nullable=True)
|
||||
description = Column(MediumText())
|
||||
resources = Column(db_types.JsonEncodedDict)
|
||||
extra_specs = Column(db_types.JsonEncodedDict)
|
||||
is_public = Column(Boolean, default=True)
|
||||
disabled = Column(Boolean, default=False)
|
||||
|
|
|
@ -37,6 +37,7 @@ class Flavor(base.MoganObject, object_base.VersionedObjectDictCompat):
|
|||
'description': object_fields.StringField(nullable=True),
|
||||
'is_public': object_fields.BooleanField(),
|
||||
'disabled': object_fields.BooleanField(),
|
||||
'resources': object_fields.FlexibleDictField(nullable=True),
|
||||
'extra_specs': object_fields.FlexibleDictField(nullable=True),
|
||||
'projects': object_fields.ListOfStringsField(),
|
||||
}
|
||||
|
|
|
@ -50,15 +50,16 @@ class BaremetalComputeAPITest(base.BaseBaremetalComputeTest):
|
|||
# Create a flavor
|
||||
body = {"name": 'mogan_flavor_create',
|
||||
"description": "mogan flavor description",
|
||||
'is_public': True}
|
||||
'is_public': True, 'resources': {'gold': 1}}
|
||||
resp = self.baremetal_compute_client.create_flavor(**body)
|
||||
self.assertEqual('mogan_flavor_create', resp['name'])
|
||||
self.assertEqual('mogan flavor description',
|
||||
resp['description'])
|
||||
self.assertEqual(True, resp['is_public'])
|
||||
self.assertEqual(False, resp['disabled'])
|
||||
self.assertEqual({'gold': 1}, resp['resources'])
|
||||
self.assertEqual({}, resp['extra_specs'])
|
||||
self.assertIn('uuid', resp)
|
||||
self.assertIn('extra_specs', resp)
|
||||
self.assertIn('links', resp)
|
||||
self.flavor_ids.append(resp['uuid'])
|
||||
|
||||
|
@ -70,8 +71,9 @@ class BaremetalComputeAPITest(base.BaseBaremetalComputeTest):
|
|||
resp['description'])
|
||||
self.assertEqual(True, resp['is_public'])
|
||||
self.assertEqual(False, resp['disabled'])
|
||||
self.assertEqual({}, resp['resources'])
|
||||
self.assertEqual({}, resp['extra_specs'])
|
||||
self.assertIn('uuid', resp)
|
||||
self.assertIn('extra_specs', resp)
|
||||
self.assertIn('links', resp)
|
||||
|
||||
@decorators.idempotent_id('f787f8e4-aa20-4c19-a9ec-44bff85d8634')
|
||||
|
|
|
@ -165,6 +165,7 @@ def get_test_flavor(**kw):
|
|||
'uuid': kw.get('uuid', uuidutils.generate_uuid()),
|
||||
'name': kw.get('name', 'test'),
|
||||
'description': kw.get('description', 'test'),
|
||||
'resources': kw.get('resources', {}),
|
||||
'extra_specs': kw.get('extra_specs', {}),
|
||||
'is_public': kw.get('is_public', 1),
|
||||
'disabled': kw.get('disabled', 0),
|
||||
|
|
|
@ -389,7 +389,7 @@ expected_object_fingerprints = {
|
|||
'ComputePortList': '1.0-33a2e1bb91ad4082f9f63429b77c1244',
|
||||
'ServerFault': '1.0-74349ff701259e4834b4e9dc2dac1b12',
|
||||
'ServerFaultList': '1.0-43e8aad0258652921f929934e9e048fd',
|
||||
'Flavor': '1.0-1ffc02ecf4565f4b5e88b8369cb70553',
|
||||
'Flavor': '1.0-ed05427767e256d81161ab212bf5e808',
|
||||
'MyObj': '1.1-aad62eedc5a5cc8bcaf2982c285e753f',
|
||||
'ServerNic': '1.0-ebbd767c2f6a7f14bd524c6067f2b382',
|
||||
'ServerNics': '1.0-33a2e1bb91ad4082f9f63429b77c1244',
|
||||
|
|
Loading…
Reference in New Issue