Merge "Add a description field for resource plan"

This commit is contained in:
Jenkins 2016-10-10 01:43:33 +00:00 committed by Gerrit Code Review
commit 1a8adb3014
6 changed files with 14 additions and 0 deletions

View File

@ -77,6 +77,7 @@ class PlanViewBuilder(common.ViewBuilder):
'plan': { 'plan': {
'id': plan.get('id'), 'id': plan.get('id'),
'name': plan.get('name'), 'name': plan.get('name'),
'description': plan.get('description'),
'resources': plan.get('resources'), 'resources': plan.get('resources'),
'provider_id': plan.get('provider_id'), 'provider_id': plan.get('provider_id'),
'status': plan.get('status'), 'status': plan.get('status'),
@ -263,6 +264,7 @@ class PlansController(wsgi.Controller):
plan_properties = { plan_properties = {
'name': plan.get('name', None), 'name': plan.get('name', None),
'description': plan.get('description', None),
'provider_id': plan.get('provider_id', None), 'provider_id': plan.get('provider_id', None),
'project_id': context.project_id, 'project_id': context.project_id,
'status': constants.PLAN_STATUS_SUSPENDED, 'status': constants.PLAN_STATUS_SUSPENDED,

View File

@ -43,6 +43,7 @@ def define_tables(meta):
Column('deleted', Boolean), Column('deleted', Boolean),
Column('id', String(36), primary_key=True, nullable=False), Column('id', String(36), primary_key=True, nullable=False),
Column('name', String(length=255)), Column('name', String(length=255)),
Column('description', String(length=255)),
Column('provider_id', String(length=36)), Column('provider_id', String(length=36)),
Column('project_id', String(length=255)), Column('project_id', String(length=255)),
Column('status', String(length=64)), Column('status', String(length=64)),

View File

@ -149,6 +149,7 @@ class Plan(BASE, KarborBase):
__tablename__ = 'plans' __tablename__ = 'plans'
id = Column(String(36), primary_key=True) id = Column(String(36), primary_key=True)
name = Column(String(255)) name = Column(String(255))
description = Column(String(255))
provider_id = Column(String(36)) provider_id = Column(String(36))
project_id = Column(String(255)) project_id = Column(String(255))
status = Column(String(64)) status = Column(String(64))

View File

@ -37,6 +37,7 @@ class Plan(base.KarborPersistentObject, base.KarborObject,
fields = { fields = {
'id': fields.UUIDField(), 'id': fields.UUIDField(),
'name': fields.StringField(), 'name': fields.StringField(),
'description': fields.StringField(nullable=True),
'provider_id': fields.UUIDField(), 'provider_id': fields.UUIDField(),
'project_id': fields.UUIDField(), 'project_id': fields.UUIDField(),
'status': fields.StringField(nullable=True), 'status': fields.StringField(nullable=True),

View File

@ -25,6 +25,7 @@ from karbor.tests.unit.api import fakes
CONF = cfg.CONF CONF = cfg.CONF
DEFAULT_NAME = 'My 3 tier application' DEFAULT_NAME = 'My 3 tier application'
DEFAULT_DESCRIPTION = 'My 3 tier application protection plan'
DEFAULT_PROVIDER_ID = 'efc6a88b-9096-4bb6-8634-cda182a6e12a' DEFAULT_PROVIDER_ID = 'efc6a88b-9096-4bb6-8634-cda182a6e12a'
DEFAULT_PROJECT_ID = '39bb894794b741e982bd26144d2949f6' DEFAULT_PROJECT_ID = '39bb894794b741e982bd26144d2949f6'
DEFAULT_RESOURCES = [{'id': 'key1', DEFAULT_RESOURCES = [{'id': 'key1',
@ -57,6 +58,7 @@ class PlanApiTest(base.TestCase):
def test_plan_create_InvalidProviderId(self): def test_plan_create_InvalidProviderId(self):
plan = self._plan_in_request_body( plan = self._plan_in_request_body(
name=DEFAULT_NAME, name=DEFAULT_NAME,
description=DEFAULT_DESCRIPTION,
provider_id="", provider_id="",
status=constants.PLAN_STATUS_SUSPENDED, status=constants.PLAN_STATUS_SUSPENDED,
project_id=DEFAULT_PROJECT_ID, project_id=DEFAULT_PROJECT_ID,
@ -69,6 +71,7 @@ class PlanApiTest(base.TestCase):
def test_plan_create_InvalidResources(self): def test_plan_create_InvalidResources(self):
plan = self._plan_in_request_body( plan = self._plan_in_request_body(
name=DEFAULT_NAME, name=DEFAULT_NAME,
description=DEFAULT_DESCRIPTION,
provider_id=DEFAULT_PROVIDER_ID, provider_id=DEFAULT_PROVIDER_ID,
status=constants.PLAN_STATUS_SUSPENDED, status=constants.PLAN_STATUS_SUSPENDED,
project_id=DEFAULT_PROJECT_ID, project_id=DEFAULT_PROJECT_ID,
@ -110,6 +113,7 @@ class PlanApiTest(base.TestCase):
def test_plan_update_InvalidResources(self): def test_plan_update_InvalidResources(self):
plan = self._plan_in_request_body( plan = self._plan_in_request_body(
name=DEFAULT_NAME, name=DEFAULT_NAME,
description=DEFAULT_DESCRIPTION,
provider_id=DEFAULT_PROVIDER_ID, provider_id=DEFAULT_PROVIDER_ID,
status=constants.PLAN_STATUS_SUSPENDED, status=constants.PLAN_STATUS_SUSPENDED,
project_id=DEFAULT_PROJECT_ID, project_id=DEFAULT_PROJECT_ID,
@ -169,6 +173,7 @@ class PlanApiTest(base.TestCase):
self, mock_plan_get, mock_check_policy): self, mock_plan_get, mock_check_policy):
plan = self._plan_in_request_body( plan = self._plan_in_request_body(
name=DEFAULT_NAME, name=DEFAULT_NAME,
description=DEFAULT_DESCRIPTION,
provider_id=DEFAULT_PROVIDER_ID, provider_id=DEFAULT_PROVIDER_ID,
status=constants.PLAN_STATUS_STARTED, status=constants.PLAN_STATUS_STARTED,
project_id=DEFAULT_PROJECT_ID, project_id=DEFAULT_PROJECT_ID,
@ -182,6 +187,7 @@ class PlanApiTest(base.TestCase):
body) body)
def _plan_in_request_body(self, name=DEFAULT_NAME, def _plan_in_request_body(self, name=DEFAULT_NAME,
description=DEFAULT_DESCRIPTION,
provider_id=DEFAULT_PROVIDER_ID, provider_id=DEFAULT_PROVIDER_ID,
status=constants.PLAN_STATUS_SUSPENDED, status=constants.PLAN_STATUS_SUSPENDED,
project_id=DEFAULT_PROJECT_ID, project_id=DEFAULT_PROJECT_ID,
@ -189,6 +195,7 @@ class PlanApiTest(base.TestCase):
parameters=DEFAULT_PARAMETERS): parameters=DEFAULT_PARAMETERS):
plan_req = { plan_req = {
'name': name, 'name': name,
'description': description,
'provider_id': provider_id, 'provider_id': provider_id,
'status': status, 'status': status,
'project_id': project_id, 'project_id': project_id,

View File

@ -401,6 +401,7 @@ class PlanDbTestCase(base.TestCase):
fake_plan = { fake_plan = {
'name': 'My 3 tier application', 'name': 'My 3 tier application',
'description': 'My 3 tier application protection plan',
'provider_id': 'efc6a88b-9096-4bb6-8634-cda182a6e12a', 'provider_id': 'efc6a88b-9096-4bb6-8634-cda182a6e12a',
'status': 'suspended', 'status': 'suspended',
'project_id': '39bb894794b741e982bd26144d2949f6', 'project_id': '39bb894794b741e982bd26144d2949f6',
@ -410,6 +411,7 @@ class PlanDbTestCase(base.TestCase):
fake_plan_with_resources = { fake_plan_with_resources = {
'name': 'My 3 tier application', 'name': 'My 3 tier application',
'description': 'My 3 tier application protection plan',
'provider_id': 'efc6a88b-9096-4bb6-8634-cda182a6e12a', 'provider_id': 'efc6a88b-9096-4bb6-8634-cda182a6e12a',
'status': 'suspended', 'status': 'suspended',
'project_id': '39bb894794b741e982bd26144d2949f6', 'project_id': '39bb894794b741e982bd26144d2949f6',