Add timestamps to amphora table

Change-Id: I3df39278eee2d2c6c31f93c8b651e6f74690a1b1
This commit is contained in:
Adam Harwell 2018-02-26 10:19:05 +00:00
parent 5e6f652b3f
commit 2e7d9c6cd1
8 changed files with 66 additions and 6 deletions

View File

@ -67,6 +67,8 @@ Response Parameters
- vrrp_id: vrrp-id
- vrrp_priority: vrrp-priority
- cached_zone: cached-zone
- created_at: created_at
- updated_at: updated_at
Response Example
----------------
@ -138,6 +140,8 @@ Response Parameters
- vrrp_id: vrrp-id
- vrrp_priority: vrrp-priority
- cached_zone: cached-zone
- created_at: created_at
- updated_at: updated_at
Response Example
----------------

View File

@ -16,7 +16,9 @@
"vrrp_interface": "eth1",
"vrrp_id": 1,
"vrrp_priority": 100,
"cached_zone": "zone1"
"cached_zone": "zone1",
"created_at": "2017-05-10T18:14:44",
"updated_at": "2017-05-10T23:08:12"
},
{
"id": "89c186a3-cb16-497b-b099-c4bd40316642",
@ -34,7 +36,9 @@
"vrrp_interface": "eth1",
"vrrp_id": 1,
"vrrp_priority": 200,
"cached_zone": "zone2"
"cached_zone": "zone2",
"created_at": "2017-06-11T19:15:45",
"updated_at": "2017-06-11T24:09:13"
}
]
}

View File

@ -15,6 +15,8 @@
"vrrp_interface": "eth1",
"vrrp_id": 1,
"vrrp_priority": 100,
"cached_zone": "zone1"
"cached_zone": "zone1",
"created_at": "2017-05-10T18:14:44",
"updated_at": "2017-05-10T23:08:12"
}
}

View File

@ -40,6 +40,8 @@ class AmphoraResponse(BaseAmphoraType):
vrrp_id = wtypes.wsattr(wtypes.IntegerType())
vrrp_priority = wtypes.wsattr(wtypes.IntegerType())
cached_zone = wtypes.wsattr(wtypes.StringType())
created_at = wtypes.wsattr(wtypes.datetime.datetime)
updated_at = wtypes.wsattr(wtypes.datetime.datetime)
@classmethod
def from_data_model(cls, data_model, children=False):

View File

@ -500,7 +500,8 @@ class Amphora(BaseDataModel):
ha_ip=None, vrrp_port_id=None, ha_port_id=None,
load_balancer=None, role=None, cert_expiration=None,
cert_busy=False, vrrp_interface=None, vrrp_id=None,
vrrp_priority=None, cached_zone=None):
vrrp_priority=None, cached_zone=None, created_at=None,
updated_at=None):
self.id = id
self.load_balancer_id = load_balancer_id
self.compute_id = compute_id
@ -518,6 +519,8 @@ class Amphora(BaseDataModel):
self.cert_expiration = cert_expiration
self.cert_busy = cert_busy
self.cached_zone = cached_zone
self.created_at = created_at
self.updated_at = updated_at
def delete(self):
for amphora in self.load_balancer.amphorae:

View File

@ -0,0 +1,39 @@
# Copyright 2018 GoDaddy
#
# 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.
"""add timestamps to amphora
Revision ID: 10d38216ad34
Revises: 0aee2b450512
Create Date: 2018-02-26 10:04:59.133772
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '10d38216ad34'
down_revision = '0aee2b450512'
def upgrade():
op.add_column(
u'amphora',
sa.Column(u'created_at', sa.DateTime(), nullable=True)
)
op.add_column(
u'amphora',
sa.Column(u'updated_at', sa.DateTime(), nullable=True)
)

View File

@ -484,7 +484,7 @@ class SNI(base_models.BASE):
cascade="delete"))
class Amphora(base_models.BASE, base_models.IdMixin):
class Amphora(base_models.BASE, base_models.IdMixin, models.TimestampMixin):
__data_model__ = data_models.Amphora

View File

@ -52,7 +52,9 @@ class TestAmphora(base.BaseAPITest):
'vrrp_interface': 'eth1',
'vrrp_id': 1,
'vrrp_priority': 100,
'cached_zone': None
'cached_zone': None,
'created_at': datetime.datetime.now(),
'updated_at': datetime.datetime.now(),
}
self.amp = self.amphora_repo.create(self.session, **self.amp_args)
self.amp_id = self.amp.id
@ -82,6 +84,10 @@ class TestAmphora(base.BaseAPITest):
response.pop('loadbalancer_id'))
self.assertEqual(source.pop('cert_expiration').isoformat(),
response.pop('cert_expiration'))
self.assertEqual(source.pop('created_at').isoformat(),
response.pop('created_at'))
self.assertEqual(source.pop('updated_at').isoformat(),
response.pop('updated_at'))
self.assertEqual(source, response)
def test_get(self):