custom date output and response update
Change-Id: I47b685bfd1aeedc4db5672656e13304ff4369185
This commit is contained in:
parent
622331a450
commit
2d5e949be6
@ -145,8 +145,10 @@ class LoadBalancersController(RestController):
|
||||
load_balancers['nodes'].append(node)
|
||||
|
||||
if load_balancers is None:
|
||||
response.status = 400
|
||||
return Responses.not_found
|
||||
else:
|
||||
response.status = 200
|
||||
return load_balancers
|
||||
|
||||
@expose('json')
|
||||
|
@ -12,11 +12,11 @@
|
||||
# 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 Table, Column, Integer, ForeignKey, create_engine
|
||||
from sqlalchemy import INTEGER, VARCHAR, TIMESTAMP, BIGINT
|
||||
from sqlalchemy import INTEGER, VARCHAR, BIGINT
|
||||
from sqlalchemy.ext.declarative import declarative_base
|
||||
from sqlalchemy.orm import relationship, backref, sessionmaker
|
||||
import sqlalchemy.types as types
|
||||
from pecan import conf
|
||||
|
||||
# TODO replace this with something better
|
||||
@ -40,12 +40,22 @@ loadbalancers_devices = Table(
|
||||
)
|
||||
|
||||
|
||||
class FormatedDateTime(types.TypeDecorator):
|
||||
'''formats date to match iso 8601 standards
|
||||
'''
|
||||
|
||||
impl = types.DateTime
|
||||
|
||||
def process_result_value(self, value, dialect):
|
||||
return value.strftime('%Y-%m-%dT%H:%M:%S')
|
||||
|
||||
|
||||
class Device(DeclarativeBase):
|
||||
"""device model"""
|
||||
__tablename__ = 'devices'
|
||||
#column definitions
|
||||
az = Column(u'az', INTEGER(), nullable=False)
|
||||
created = Column(u'created', TIMESTAMP(), nullable=False)
|
||||
created = Column(u'created', FormatedDateTime(), nullable=False)
|
||||
floatingIpAddr = Column(
|
||||
u'floatingIpAddr', VARCHAR(length=128), nullable=False
|
||||
)
|
||||
@ -54,7 +64,7 @@ class Device(DeclarativeBase):
|
||||
publicIpAddr = Column(u'publicIpAddr', VARCHAR(length=128), nullable=False)
|
||||
status = Column(u'status', VARCHAR(length=128), nullable=False)
|
||||
type = Column(u'type', VARCHAR(length=128), nullable=False)
|
||||
updated = Column(u'updated', TIMESTAMP(), nullable=False)
|
||||
updated = Column(u'updated', FormatedDateTime(), nullable=False)
|
||||
|
||||
def find_free_device(self):
|
||||
"""queries for free and clear device
|
||||
@ -73,7 +83,6 @@ class LoadBalancer(DeclarativeBase):
|
||||
__tablename__ = 'loadbalancers'
|
||||
#column definitions
|
||||
algorithm = Column(u'algorithm', VARCHAR(length=80), nullable=False)
|
||||
created = Column(u'created', TIMESTAMP(), nullable=False)
|
||||
errmsg = Column(u'errmsg', VARCHAR(length=128))
|
||||
id = Column(u'id', BIGINT(), primary_key=True, nullable=False)
|
||||
name = Column(u'name', VARCHAR(length=128), nullable=False)
|
||||
@ -81,7 +90,8 @@ class LoadBalancer(DeclarativeBase):
|
||||
protocol = Column(u'protocol', VARCHAR(length=128), nullable=False)
|
||||
status = Column(u'status', VARCHAR(length=50), nullable=False)
|
||||
tenantid = Column(u'tenantid', VARCHAR(length=128), nullable=False)
|
||||
updated = Column(u'updated', TIMESTAMP(), nullable=False)
|
||||
updated = Column(u'updated', FormatedDateTime(), nullable=False)
|
||||
created = Column(u'created', FormatedDateTime(), nullable=False)
|
||||
nodes = relationship(
|
||||
'Node', backref=backref('loadbalancers', order_by='Node.id')
|
||||
)
|
||||
@ -105,5 +115,6 @@ class Node(DeclarativeBase):
|
||||
status = Column(u'status', VARCHAR(length=128), nullable=False)
|
||||
weight = Column(u'weight', INTEGER(), nullable=False)
|
||||
|
||||
|
||||
"""session"""
|
||||
session = sessionmaker(bind=engine)()
|
||||
|
@ -7,5 +7,5 @@ python_swiftclient>=1.3.0
|
||||
requests>=1.0.0
|
||||
dogapi
|
||||
pecan
|
||||
sqlalchemy
|
||||
sqlalchemy>=0.8.0
|
||||
MySQL-python
|
||||
|
Loading…
x
Reference in New Issue
Block a user