Make VNFD/VNF/VIM Name Mandatory in Tacker API's

Change-Id: I389d62e40d473c5149a18601f898e47b981b4b1d
Partial-Bug: #1474966
This commit is contained in:
Manikantha Srinivas Tadi 2016-05-19 09:04:34 -04:00
parent 4c74e89790
commit a8395daace
15 changed files with 72 additions and 15 deletions

View File

@ -0,0 +1,4 @@
---
features:
- Made VNFD/VNF/VIM names mandatory in tacker.

View File

@ -0,0 +1,41 @@
# Copyright 2016 OpenStack Foundation
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
"""make VNFD/VNF/VIM name mandatory
Revision ID: 5f88e86b35c7
Revises: 354de64ba129
Create Date: 2016-06-14 11:16:16.303343
"""
# revision identifiers, used by Alembic.
revision = '5f88e86b35c7'
down_revision = '354de64ba129'
from alembic import op
from sqlalchemy.dialects import mysql
def upgrade(active_plugins=None, options=None):
op.alter_column('devices', 'name',
existing_type=mysql.VARCHAR(length=255),
nullable=False)
op.alter_column('devicetemplates', 'name',
existing_type=mysql.VARCHAR(length=255),
nullable=False)
op.alter_column('vims', 'name',
existing_type=mysql.VARCHAR(length=255),
nullable=False)

View File

@ -1 +1 @@
354de64ba129
5f88e86b35c7

View File

@ -38,7 +38,7 @@ VIM_AUTH_ATTRIBUTES = ('auth_url', 'vim_project', 'password', 'auth_cred')
class Vim(model_base.BASE, models_v1.HasId, models_v1.HasTenant):
type = sa.Column(sa.String(64), nullable=False)
name = sa.Column(sa.String(255), nullable=True)
name = sa.Column(sa.String(255), nullable=False)
description = sa.Column(sa.Text, nullable=True)
placement_attr = sa.Column(types.Json, nullable=True)
shared = sa.Column(sa.Boolean, default=True, server_default=sql.true(

View File

@ -46,7 +46,7 @@ class DeviceTemplate(model_base.BASE, models_v1.HasId, models_v1.HasTenant):
"""Represents template to create hosting device."""
# Descriptive name
name = sa.Column(sa.String(255))
name = sa.Column(sa.String(255), nullable=False)
description = sa.Column(sa.Text)
# service type that this service vm provides.
@ -98,7 +98,7 @@ class Device(model_base.BASE, models_v1.HasId, models_v1.HasTenant):
template_id = sa.Column(types.Uuid, sa.ForeignKey('devicetemplates.id'))
template = orm.relationship('DeviceTemplate')
name = sa.Column(sa.String(255), nullable=True)
name = sa.Column(sa.String(255), nullable=False)
description = sa.Column(sa.Text, nullable=True)
# sufficient information to uniquely identify hosting device.

View File

@ -112,7 +112,6 @@ RESOURCE_ATTRIBUTE_MAP = {
'allow_put': True,
'validate': {'type:string': None},
'is_visible': True,
'default': '',
},
'description': {
'allow_post': True,

View File

@ -184,7 +184,6 @@ RESOURCE_ATTRIBUTE_MAP = {
'allow_put': True,
'validate': {'type:string': None},
'is_visible': True,
'default': '',
},
'description': {
'allow_post': True,
@ -258,7 +257,6 @@ RESOURCE_ATTRIBUTE_MAP = {
'allow_put': True,
'validate': {'type:string': None},
'is_visible': True,
'default': '',
},
'description': {
'allow_post': True,

View File

@ -27,8 +27,10 @@ class VnfTestToscaCreate(base.BaseTackerTest):
def test_create_delete_vnf_tosca_no_monitoring(self):
data = dict()
data['tosca'] = read_file('sample-tosca-vnfd.yaml')
vnfd_name = 'test_tosca_vnf_with_cirros_no_monitoring'
toscal = data['tosca']
tosca_arg = {'vnfd': {'attributes': {'vnfd': toscal}}}
tosca_arg = {'vnfd': {'name': vnfd_name,
'attributes': {'vnfd': toscal}}}
# Create vnfd with tosca template
vnfd_instance = self.client.create_vnfd(body=tosca_arg)

View File

@ -31,7 +31,9 @@ class VnfTestToscaMultipleVDU(base.BaseTackerTest):
input_yaml = read_file('sample-tosca-vnfd-multi-vdu.yaml')
data['tosca'] = input_yaml
toscal = data['tosca']
tosca_arg = {'vnfd': {'attributes': {'vnfd': toscal}}}
vnfd_name = 'sample-tosca-vnfd-multi-vdu'
tosca_arg = {'vnfd': {'name': vnfd_name,
'attributes': {'vnfd': toscal}}}
# Create vnfd with tosca template
vnfd_instance = self.client.create_vnfd(body=tosca_arg)

View File

@ -25,7 +25,9 @@ class VnfdTestCreate(base.BaseTackerTest):
data = dict()
data['tosca'] = read_file(tosca_vnfd_file)
toscal = data['tosca']
tosca_arg = {'vnfd': {'attributes': {'vnfd': toscal}}}
vnfd_name = 'sample-tosca-vnfd'
tosca_arg = {'vnfd': {'name': vnfd_name,
'attributes': {'vnfd': toscal}}}
vnfd_instance = self.client.create_vnfd(body=tosca_arg)
self.assertIsNotNone(vnfd_instance)

View File

@ -26,8 +26,10 @@ class VnfTestCreate(base.BaseTackerTest):
def _test_create_delete_vnf(self, vnf_name, vim_id=None):
data = dict()
data['tosca'] = read_file('sample_cirros_vnf_no_monitoring.yaml')
vnfd_name = 'sample_cirros_vnf_no_monitoring'
toscal = data['tosca']
tosca_arg = {'vnfd': {'attributes': {'vnfd': toscal}}}
tosca_arg = {'vnfd': {'name': vnfd_name,
'attributes': {'vnfd': toscal}}}
# Create vnfd with tosca template
vnfd_instance = self.client.create_vnfd(body=tosca_arg)

View File

@ -23,7 +23,8 @@ class VnfTestPingMonitor(base.BaseTackerTest):
data = dict()
data['tosca'] = read_file(vnfd_file)
toscal = data['tosca']
tosca_arg = {'vnfd': {'attributes': {'vnfd': toscal}}}
tosca_arg = {'vnfd': {'name': vnf_name,
'attributes': {'vnfd': toscal}}}
# Create vnfd with tosca template
vnfd_instance = self.client.create_vnfd(body=tosca_arg)

View File

@ -29,7 +29,9 @@ class VnfTestMultipleVDU(base.BaseTackerTest):
input_yaml = read_file('sample-vnfd-multi-vdu.yaml')
data['tosca'] = input_yaml
toscal = data['tosca']
tosca_arg = {'vnfd': {'attributes': {'vnfd': toscal}}}
vnfd_name = 'sample-vnfd-multi-vdu'
tosca_arg = {'vnfd': {'name': vnfd_name,
'attributes': {'vnfd': toscal}}}
# Create vnfd with tosca template
vnfd_instance = self.client.create_vnfd(body=tosca_arg)

View File

@ -25,7 +25,9 @@ class VnfdTestCreate(base.BaseTackerTest):
data = dict()
data['tosca'] = read_file(vnfd_file)
toscal = data['tosca']
tosca_arg = {'vnfd': {'attributes': {'vnfd': toscal}}}
vnfd_name = 'sample_cirros_vnf'
tosca_arg = {'vnfd': {'name': vnfd_name,
'attributes': {'vnfd': toscal}}}
vnfd_instance = self.client.create_vnfd(body=tosca_arg)
self.assertIsNotNone(vnfd_instance)

View File

@ -23,8 +23,10 @@ class VnfmTestParam(base.BaseTackerTest):
def _test_vnfd_create(self, vnfd_file):
yaml_input = dict()
yaml_input['tosca'] = read_file(vnfd_file)
vnfd_name = 'sample_cirros_vnf'
toscal = yaml_input['tosca']
req_dict = {'vnfd': {'attributes': {'vnfd': toscal}}}
req_dict = {'vnfd': {'name': vnfd_name,
'attributes': {'vnfd': toscal}}}
# Create vnfd
vnfd_instance = self.client.create_vnfd(body=req_dict)