Drop the ipv4 and ipv6 columns from servers. It's never been used and makes little sense.
Change-Id: I9f22a77d5adcf0fb18a081aa1a73253925ed150d
This commit is contained in:
parent
e0c227ec3f
commit
c085766c2e
@ -211,16 +211,12 @@ Get Servers Hosting a Domain
|
||||
{
|
||||
"id": "384a9b20-239c-11e2-81c1-0800200c9a66",
|
||||
"name": "ns1.provider.com.",
|
||||
"ipv4": "192.0.2.1",
|
||||
"ipv6": "2001:db8::1",
|
||||
"created_at": "2011-01-21T11:33:21Z",
|
||||
"updated_at": null
|
||||
},
|
||||
{
|
||||
"id": "cf661142-e577-40b5-b3eb-75795cdc0cd7",
|
||||
"name": "ns2.provider.com.",
|
||||
"ipv4": "192.0.2.2",
|
||||
"ipv6": "2001:db8::2",
|
||||
"created_at": "2011-01-21T11:33:21Z",
|
||||
"updated_at": "2011-01-21T11:33:21Z"
|
||||
}
|
||||
@ -228,8 +224,6 @@ Get Servers Hosting a Domain
|
||||
|
||||
:form id: UUID server_id
|
||||
:form name: Server hostname
|
||||
:form ipv4: Server IPv4 address
|
||||
:form ipv6: Server IPv6 address
|
||||
:form created_at: timestamp
|
||||
:form updated_at: timestamp
|
||||
:statuscode 200: Success
|
||||
|
@ -25,9 +25,7 @@ Create Server
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"name": "ns1.example.org.",
|
||||
"ipv4": "192.0.2.1",
|
||||
"ipv6": "2001:db8::1"
|
||||
"name": "ns1.example.org."
|
||||
}
|
||||
|
||||
**Example response**:
|
||||
@ -40,16 +38,12 @@ Create Server
|
||||
|
||||
{
|
||||
"id": "384a9b20-239c-11e2-81c1-0800200c9a66",
|
||||
"name": "ns1.example.org.",
|
||||
"ipv4": "192.0.2.1",
|
||||
"ipv6": "2001:db8::1",
|
||||
"name": "ns1.example.org."
|
||||
"created_at": "2011-01-21T11:33:21Z",
|
||||
"updated_at": null
|
||||
}
|
||||
|
||||
:form name: Server hostname
|
||||
:form ipv4: Server IPv4 address
|
||||
:form ipv6: Server IPv6 address
|
||||
:statuscode 200: Success
|
||||
:statuscode 401: Access Denied
|
||||
:statuscode 409: Conflict
|
||||
@ -80,8 +74,6 @@ Get Server
|
||||
{
|
||||
"id": "384a9b20-239c-11e2-81c1-0800200c9a66",
|
||||
"name": "ns1.example.org.",
|
||||
"ipv4": "192.0.2.1",
|
||||
"ipv6": "2001:db8::1",
|
||||
"created_at": "2011-01-21T11:33:21Z",
|
||||
"updated_at": null
|
||||
}
|
||||
@ -89,8 +81,6 @@ Get Server
|
||||
:param server_id: The server's unique id
|
||||
:type server_id: uuid
|
||||
:form name: Server hostname
|
||||
:form ipv4: Server IPv4 address
|
||||
:form ipv6: Server IPv6 address
|
||||
:form created_at: timestamp
|
||||
:form updated_at: timestamp
|
||||
:statuscode 200: Success
|
||||
@ -114,8 +104,7 @@ Update Server
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"name": "ns1.example.org.",
|
||||
"ipv4": "1.2.3.5"
|
||||
"name": "ns1.example.org."
|
||||
}
|
||||
|
||||
**Example response**:
|
||||
@ -128,15 +117,13 @@ Update Server
|
||||
|
||||
{
|
||||
"id": "879c1100-9c92-4244-bc83-9535ee6534d0"t
|
||||
"name": "ns1.example.org.",
|
||||
"ipv4": "1.2.3.5",
|
||||
"name": "ns1.example.org."
|
||||
"created_at": "2012-11-02T02:55:44.000000",
|
||||
"updated_at": "2012-11-02T02:58:41.993556"
|
||||
}
|
||||
|
||||
:form id: UUID server_id
|
||||
:form name: Server hostname
|
||||
:form ipv4: Server IPv4 address
|
||||
:form created_at: timestamp
|
||||
:form updated_at: timestamp
|
||||
:statuscode 200: Success
|
||||
@ -170,17 +157,13 @@ List Servers
|
||||
[
|
||||
{
|
||||
"id": "384a9b20-239c-11e2-81c1-0800200c9a66",
|
||||
"name": "ns1.example.org.",
|
||||
"ipv4": "192.0.2.1",
|
||||
"ipv6": "2001:db8::1",
|
||||
"name": "ns1.example.org."
|
||||
"created_at": "2011-01-21T11:33:21Z",
|
||||
"updated_at": null
|
||||
},
|
||||
{
|
||||
"id": "cf661142-e577-40b5-b3eb-75795cdc0cd7",
|
||||
"name": "ns2.example.org.",
|
||||
"ipv4": "192.0.2.2",
|
||||
"ipv6": "2001:db8::2",
|
||||
"name": "ns2.example.org."
|
||||
"created_at": "2011-01-21T11:33:21Z",
|
||||
"updated_at": "2011-01-21T11:33:21Z"
|
||||
}
|
||||
@ -188,8 +171,6 @@ List Servers
|
||||
|
||||
:form id: UUID server_id
|
||||
:form name: Server hostname
|
||||
:form ipv4: Server IPv4 address
|
||||
:form ipv6: Server IPv6 address
|
||||
:form created_at: timestamp
|
||||
:form updated_at: timestamp
|
||||
:statuscode 200: Success
|
||||
|
@ -48,16 +48,12 @@ class CreateServerCommand(base.CreateCommand):
|
||||
parser = super(CreateServerCommand, self).get_parser(prog_name)
|
||||
|
||||
parser.add_argument('--name', help="Server Name", required=True)
|
||||
parser.add_argument('--ipv4', help="Server IPv4 Address")
|
||||
parser.add_argument('--ipv6', help="Server IPv6 Address")
|
||||
|
||||
return parser
|
||||
|
||||
def execute(self, parsed_args):
|
||||
server = dict(
|
||||
name=parsed_args.name,
|
||||
ipv4=parsed_args.ipv4,
|
||||
ipv6=parsed_args.ipv6,
|
||||
)
|
||||
|
||||
return central_api.create_server(self.context, server)
|
||||
@ -72,14 +68,6 @@ class UpdateServerCommand(base.UpdateCommand):
|
||||
parser.add_argument('id', help="Server ID")
|
||||
parser.add_argument('--name', help="Server Name")
|
||||
|
||||
ipv4_group = parser.add_mutually_exclusive_group()
|
||||
ipv4_group.add_argument('--ipv4', help="Server IPv4 Address")
|
||||
ipv4_group.add_argument('--no-ipv4', action='store_true')
|
||||
|
||||
ipv6_group = parser.add_mutually_exclusive_group()
|
||||
ipv6_group.add_argument('--ipv6', help="Server IPv6 Address")
|
||||
ipv6_group.add_argument('--no-ipv6', action='store_true')
|
||||
|
||||
return parser
|
||||
|
||||
def execute(self, parsed_args):
|
||||
@ -88,16 +76,6 @@ class UpdateServerCommand(base.UpdateCommand):
|
||||
if parsed_args.name:
|
||||
server['name'] = parsed_args.name
|
||||
|
||||
if parsed_args.no_ipv4:
|
||||
server['ipv4'] = None
|
||||
elif parsed_args.ipv4:
|
||||
server['ipv4'] = parsed_args.ipv4
|
||||
|
||||
if parsed_args.no_ipv6:
|
||||
server['ipv6'] = None
|
||||
elif parsed_args.ipv6:
|
||||
server['ipv6'] = parsed_args.ipv6
|
||||
|
||||
return central_api.update_server(self.context, parsed_args.id, server)
|
||||
|
||||
|
||||
|
@ -20,16 +20,6 @@
|
||||
"maxLength": 255,
|
||||
"required": true
|
||||
},
|
||||
"ipv4": {
|
||||
"type": ["string", "null"],
|
||||
"description": "IPv4 address of server",
|
||||
"format": "ip-address"
|
||||
},
|
||||
"ipv6": {
|
||||
"type": ["string", "null"],
|
||||
"description": "IPv6 address of server",
|
||||
"format": "ipv6"
|
||||
},
|
||||
"created_at": {
|
||||
"type": "string",
|
||||
"description": "Date and time of server creation",
|
||||
@ -43,23 +33,6 @@
|
||||
"readonly": true
|
||||
}
|
||||
},
|
||||
"anyOf": [{
|
||||
"description": "IPv4",
|
||||
"properties": {
|
||||
"ipv4": {
|
||||
"type": "string",
|
||||
"required": true
|
||||
}
|
||||
}
|
||||
}, {
|
||||
"description": "IPv6",
|
||||
"properties": {
|
||||
"ipv6": {
|
||||
"type": "string",
|
||||
"required": true
|
||||
}
|
||||
}
|
||||
}],
|
||||
"links": [{
|
||||
"rel": "self",
|
||||
"href": "/servers/{id}"
|
||||
|
@ -0,0 +1,43 @@
|
||||
# Copyright 2012 Managed I.T.
|
||||
#
|
||||
# Author: Kiall Mac Innes <kiall@managedit.ie>
|
||||
#
|
||||
# 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.
|
||||
from sqlalchemy import MetaData, Table, Column
|
||||
from moniker.sqlalchemy.types import Inet
|
||||
|
||||
meta = MetaData()
|
||||
|
||||
|
||||
def upgrade(migrate_engine):
|
||||
meta.bind = migrate_engine
|
||||
|
||||
servers_table = Table('servers', meta, autoload=True)
|
||||
|
||||
ipv4 = Column('ipv4', Inet(), nullable=False, unique=True)
|
||||
ipv6 = Column('ipv6', Inet(), default=None, unique=True)
|
||||
|
||||
ipv4.create(servers_table, populate_default=True)
|
||||
ipv6.create(servers_table, populate_default=True)
|
||||
|
||||
|
||||
def downgrade(migrate_engine):
|
||||
meta.bind = migrate_engine
|
||||
|
||||
servers_table = Table('servers', meta, autoload=True)
|
||||
|
||||
ipv4 = Column('ipv4', Inet(), nullable=False, unique=True)
|
||||
ipv6 = Column('ipv6', Inet(), default=None, unique=True)
|
||||
|
||||
ipv4.drop(servers_table)
|
||||
ipv6.drop(servers_table)
|
@ -22,7 +22,7 @@ from sqlalchemy.ext.hybrid import hybrid_property
|
||||
from moniker.openstack.common import log as logging
|
||||
from moniker.openstack.common import timeutils
|
||||
from moniker.openstack.common.uuidutils import generate_uuid
|
||||
from moniker.sqlalchemy.types import UUID, Inet
|
||||
from moniker.sqlalchemy.types import UUID
|
||||
from moniker.sqlalchemy.models import Base as CommonBase
|
||||
from sqlalchemy.ext.declarative import declarative_base
|
||||
|
||||
@ -51,8 +51,6 @@ class Server(Base):
|
||||
__tablename__ = 'servers'
|
||||
|
||||
name = Column(String(255), nullable=False, unique=True)
|
||||
ipv4 = Column(Inet, nullable=False, unique=True)
|
||||
ipv6 = Column(Inet, default=None, nullable=True, unique=True)
|
||||
|
||||
|
||||
class Domain(Base):
|
||||
|
@ -78,16 +78,10 @@ class AssertMixin(object):
|
||||
class TestCase(unittest2.TestCase, AssertMixin):
|
||||
server_fixtures = [{
|
||||
'name': 'ns1.example.org.',
|
||||
'ipv4': '192.0.2.1',
|
||||
'ipv6': '2001:db8::1',
|
||||
}, {
|
||||
'name': 'ns2.example.org.',
|
||||
'ipv4': '192.0.2.2',
|
||||
'ipv6': '2001:db8::2',
|
||||
}, {
|
||||
'name': 'ns2.example.org.',
|
||||
'ipv4': '192.0.2.2',
|
||||
'ipv6': '2001:db8::2',
|
||||
}]
|
||||
|
||||
tsigkey_fixtures = [{
|
||||
|
@ -84,9 +84,7 @@ class CentralServiceTest(CentralTestCase):
|
||||
context = self.get_admin_context()
|
||||
|
||||
values = dict(
|
||||
name='ns1.example.org.',
|
||||
ipv4='192.0.2.1',
|
||||
ipv6='2001:db8::1',
|
||||
name='ns1.example.org.'
|
||||
)
|
||||
|
||||
# Create a server
|
||||
@ -95,8 +93,6 @@ class CentralServiceTest(CentralTestCase):
|
||||
# Ensure all values have been set correctly
|
||||
self.assertIsNotNone(server['id'])
|
||||
self.assertEqual(server['name'], values['name'])
|
||||
self.assertEqual(server['ipv4'], values['ipv4'])
|
||||
self.assertEqual(server['ipv6'], values['ipv6'])
|
||||
|
||||
def test_get_servers(self):
|
||||
context = self.get_admin_context()
|
||||
@ -114,8 +110,7 @@ class CentralServiceTest(CentralTestCase):
|
||||
self.assertEqual(servers[0]['name'], 'ns1.example.org.')
|
||||
|
||||
# Create a second server
|
||||
self.create_server(name='ns2.example.org.', ipv4='192.0.2.2',
|
||||
ipv6='2001:db8::2')
|
||||
self.create_server(name='ns2.example.org.')
|
||||
|
||||
# Ensure we can retrieve both servers
|
||||
servers = self.central_service.get_servers(context)
|
||||
@ -135,8 +130,6 @@ class CentralServiceTest(CentralTestCase):
|
||||
expected_server['id'])
|
||||
self.assertEqual(server['id'], expected_server['id'])
|
||||
self.assertEqual(server['name'], expected_server['name'])
|
||||
self.assertEqual(server['ipv4'], expected_server['ipv4'])
|
||||
self.assertEqual(server['ipv6'], expected_server['ipv6'])
|
||||
|
||||
def test_update_server(self):
|
||||
context = self.get_admin_context()
|
||||
@ -145,7 +138,7 @@ class CentralServiceTest(CentralTestCase):
|
||||
expected_server = self.create_server()
|
||||
|
||||
# Update the server
|
||||
values = dict(ipv4='127.0.0.1')
|
||||
values = dict(name='prefix.%s' % expected_server['name'])
|
||||
self.central_service.update_server(context, expected_server['id'],
|
||||
values=values)
|
||||
|
||||
@ -154,7 +147,7 @@ class CentralServiceTest(CentralTestCase):
|
||||
expected_server['id'])
|
||||
|
||||
# Ensure the server was updated correctly
|
||||
self.assertEqual(server['ipv4'], '127.0.0.1')
|
||||
self.assertEqual(server['name'], 'prefix.%s' % expected_server['name'])
|
||||
|
||||
def test_delete_server(self):
|
||||
context = self.get_admin_context()
|
||||
|
@ -67,9 +67,7 @@ class StorageDriverTestCase(StorageTestCase):
|
||||
# Server Tests
|
||||
def test_create_server(self):
|
||||
values = {
|
||||
'name': 'ns1.example.org.',
|
||||
'ipv4': '192.0.2.1',
|
||||
'ipv6': '2001:db8::1',
|
||||
'name': 'ns1.example.org.'
|
||||
}
|
||||
|
||||
result = self.storage_conn.create_server(
|
||||
@ -80,57 +78,13 @@ class StorageDriverTestCase(StorageTestCase):
|
||||
self.assertIsNone(result['updated_at'])
|
||||
|
||||
self.assertEqual(result['name'], values['name'])
|
||||
self.assertEqual(result['ipv4'], values['ipv4'])
|
||||
self.assertEqual(result['ipv6'], values['ipv6'])
|
||||
|
||||
def test_create_server_ipv4_only(self):
|
||||
values = [{
|
||||
'name': 'ns1.example.org.',
|
||||
'ipv4': '192.0.2.1',
|
||||
'ipv6': None,
|
||||
}, {
|
||||
'name': 'ns2.example.org.',
|
||||
'ipv4': '192.0.2.2'
|
||||
}]
|
||||
|
||||
for value in values:
|
||||
result = self.storage_conn.create_server(
|
||||
self.admin_context, values=value)
|
||||
|
||||
self.assertIsNotNone(result['id'])
|
||||
self.assertIsNotNone(result['created_at'])
|
||||
self.assertIsNone(result['updated_at'])
|
||||
|
||||
self.assertEqual(result['name'], value['name'])
|
||||
self.assertEqual(result['ipv4'], value['ipv4'])
|
||||
self.assertIsNone(result['ipv6'])
|
||||
|
||||
def test_create_server_duplicate(self):
|
||||
# Create the Initial Server
|
||||
self.create_server()
|
||||
|
||||
values = [{
|
||||
# No Changes/Identical
|
||||
}, {
|
||||
'ipv4': '127.0.0.1',
|
||||
}, {
|
||||
'ipv4': '127.0.0.1',
|
||||
'ipv6': '::1',
|
||||
}, {
|
||||
'ipv6': '::1',
|
||||
}, {
|
||||
'name': 'localhost.',
|
||||
}, {
|
||||
'name': 'localhost.',
|
||||
'ipv4': '127.0.0.1',
|
||||
}, {
|
||||
'name': 'localhost.',
|
||||
'ipv6': '::1',
|
||||
}]
|
||||
|
||||
for value in values:
|
||||
with self.assertRaises(exceptions.DuplicateServer):
|
||||
self.create_server(values=value)
|
||||
self.create_server()
|
||||
|
||||
def test_get_servers(self):
|
||||
actual = self.storage_conn.get_servers(self.admin_context)
|
||||
@ -143,8 +97,6 @@ class StorageDriverTestCase(StorageTestCase):
|
||||
self.assertEqual(len(actual), 1)
|
||||
|
||||
self.assertEqual(str(actual[0]['name']), str(server_one['name']))
|
||||
self.assertEqual(str(actual[0]['ipv4']), str(server_one['ipv4']))
|
||||
self.assertEqual(str(actual[0]['ipv6']), str(server_one['ipv6']))
|
||||
|
||||
# Create a second server
|
||||
_, server_two = self.create_server(fixture=1)
|
||||
@ -153,8 +105,6 @@ class StorageDriverTestCase(StorageTestCase):
|
||||
self.assertEqual(len(actual), 2)
|
||||
|
||||
self.assertEqual(str(actual[1]['name']), str(server_two['name']))
|
||||
self.assertEqual(str(actual[1]['ipv4']), str(server_two['ipv4']))
|
||||
self.assertEqual(str(actual[1]['ipv6']), str(server_two['ipv6']))
|
||||
|
||||
def test_get_servers_criterion(self):
|
||||
_, server_one = self.create_server(0)
|
||||
@ -189,8 +139,6 @@ class StorageDriverTestCase(StorageTestCase):
|
||||
expected['id'])
|
||||
|
||||
self.assertEqual(str(actual['name']), str(expected['name']))
|
||||
self.assertEqual(str(actual['ipv4']), str(expected['ipv4']))
|
||||
self.assertEqual(str(actual['ipv6']), str(expected['ipv6']))
|
||||
|
||||
def test_get_server_missing(self):
|
||||
with self.assertRaises(exceptions.ServerNotFound):
|
||||
@ -205,8 +153,6 @@ class StorageDriverTestCase(StorageTestCase):
|
||||
self.admin_context, server['id'], fixture)
|
||||
|
||||
self.assertEqual(str(updated['name']), str(fixture['name']))
|
||||
self.assertEqual(str(updated['ipv4']), str(fixture['ipv4']))
|
||||
self.assertEqual(str(updated['ipv6']), str(fixture['ipv6']))
|
||||
|
||||
def test_update_server_duplicate(self):
|
||||
# Create two servers
|
||||
|
Loading…
Reference in New Issue
Block a user