make pep8 happy
Change-Id: I4ef5583432cc4f9c1aeb095bcd37bc31cc82aa75
This commit is contained in:
@@ -74,8 +74,7 @@ class DevicesController(RestController):
|
|||||||
lbids = session.query(
|
lbids = session.query(
|
||||||
loadbalancers_devices.c.loadbalancer).\
|
loadbalancers_devices.c.loadbalancer).\
|
||||||
filter(
|
filter(
|
||||||
loadbalancers_devices.c.device == dev['id']
|
loadbalancers_devices.c.device == dev['id']).\
|
||||||
).\
|
|
||||||
all()
|
all()
|
||||||
|
|
||||||
lblist = [i[0] for i in lbids]
|
lblist = [i[0] for i in lbids]
|
||||||
@@ -118,8 +117,7 @@ class DevicesController(RestController):
|
|||||||
lbids = session.query(
|
lbids = session.query(
|
||||||
loadbalancers_devices.c.loadbalancer).\
|
loadbalancers_devices.c.loadbalancer).\
|
||||||
filter(
|
filter(
|
||||||
loadbalancers_devices.c.device == device['id']
|
loadbalancers_devices.c.device == device['id']).\
|
||||||
).\
|
|
||||||
all()
|
all()
|
||||||
|
|
||||||
lblist = [i[0] for i in lbids]
|
lblist = [i[0] for i in lbids]
|
||||||
@@ -182,7 +180,7 @@ class DevicesController(RestController):
|
|||||||
session.add(device)
|
session.add(device)
|
||||||
session.flush()
|
session.flush()
|
||||||
|
|
||||||
#refresh the device record so we get the id back
|
# refresh the device record so we get the id back
|
||||||
session.refresh(device)
|
session.refresh(device)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@@ -138,8 +138,7 @@ class DevicesController(RestController):
|
|||||||
lbids = session.query(
|
lbids = session.query(
|
||||||
loadbalancers_devices.c.loadbalancer).\
|
loadbalancers_devices.c.loadbalancer).\
|
||||||
filter(
|
filter(
|
||||||
loadbalancers_devices.c.device == device['id']
|
loadbalancers_devices.c.device == device['id']).\
|
||||||
).\
|
|
||||||
all()
|
all()
|
||||||
|
|
||||||
lblist = [i[0] for i in lbids]
|
lblist = [i[0] for i in lbids]
|
||||||
|
@@ -25,7 +25,7 @@ from libra.common.api.lbaas import Counters
|
|||||||
from libra.common.json_gearman import JSONGearmanClient
|
from libra.common.json_gearman import JSONGearmanClient
|
||||||
from libra.openstack.common import log
|
from libra.openstack.common import log
|
||||||
|
|
||||||
#TODO: Lots of duplication of code here, need to cleanup
|
# TODO: Lots of duplication of code here, need to cleanup
|
||||||
|
|
||||||
LOG = log.getLogger(__name__)
|
LOG = log.getLogger(__name__)
|
||||||
|
|
||||||
|
@@ -107,7 +107,7 @@ class BillingStats(object):
|
|||||||
session.rollback()
|
session.rollback()
|
||||||
return
|
return
|
||||||
|
|
||||||
#Update the exists timestamp now
|
# Update the exists timestamp now
|
||||||
session.query(Billing).\
|
session.query(Billing).\
|
||||||
filter(Billing.name == "exists").\
|
filter(Billing.name == "exists").\
|
||||||
update({"last_update": func.now()},
|
update({"last_update": func.now()},
|
||||||
|
@@ -193,8 +193,7 @@ class PingStats(object):
|
|||||||
format(
|
format(
|
||||||
node_data.lbid,
|
node_data.lbid,
|
||||||
data.floatingIpAddr,
|
data.floatingIpAddr,
|
||||||
data.tenantid
|
data.tenantid)
|
||||||
)
|
|
||||||
|
|
||||||
# Change the node status in the node table
|
# Change the node status in the node table
|
||||||
session.query(Node).\
|
session.query(Node).\
|
||||||
|
@@ -188,7 +188,7 @@ class GearJobs(object):
|
|||||||
# Error returned by Gearman
|
# Error returned by Gearman
|
||||||
failed_list.append(stats.job.task)
|
failed_list.append(stats.job.task)
|
||||||
else:
|
else:
|
||||||
#Success
|
# Success
|
||||||
results[stats.job.task] = stats.result
|
results[stats.job.task] = stats.result
|
||||||
|
|
||||||
list_of_jobs = []
|
list_of_jobs = []
|
||||||
@@ -218,7 +218,7 @@ class GearJobs(object):
|
|||||||
# Error returned by Gearman
|
# Error returned by Gearman
|
||||||
failed_list.append(stats.job.task)
|
failed_list.append(stats.job.task)
|
||||||
else:
|
else:
|
||||||
#Success
|
# Success
|
||||||
results[stats.job.task] = stats.result
|
results[stats.job.task] = stats.result
|
||||||
|
|
||||||
return failed_list, results
|
return failed_list, results
|
||||||
|
@@ -82,7 +82,7 @@ class UsageStats(object):
|
|||||||
session.rollback()
|
session.rollback()
|
||||||
return 0, 0
|
return 0, 0
|
||||||
|
|
||||||
#Update the stats timestamp
|
# Update the stats timestamp
|
||||||
session.query(Billing).\
|
session.query(Billing).\
|
||||||
filter(Billing.name == "stats").\
|
filter(Billing.name == "stats").\
|
||||||
update({"last_update": func.now()},
|
update({"last_update": func.now()},
|
||||||
|
@@ -523,7 +523,7 @@ class LoadBalancersController(RestController):
|
|||||||
# write to database
|
# write to database
|
||||||
session.add(lb)
|
session.add(lb)
|
||||||
session.flush()
|
session.flush()
|
||||||
#refresh the lb record so we get the id back
|
# refresh the lb record so we get the id back
|
||||||
session.refresh(lb)
|
session.refresh(lb)
|
||||||
for node in body.nodes:
|
for node in body.nodes:
|
||||||
if node.condition == 'DISABLED':
|
if node.condition == 'DISABLED':
|
||||||
|
@@ -18,7 +18,7 @@ from pecan.rest import RestController
|
|||||||
import wsmeext.pecan as wsme_pecan
|
import wsmeext.pecan as wsme_pecan
|
||||||
from wsme.exc import ClientSideError
|
from wsme.exc import ClientSideError
|
||||||
from wsme import Unset
|
from wsme import Unset
|
||||||
#default response objects
|
# default response objects
|
||||||
from libra.common.api.lbaas import LoadBalancer, Node, db_session, Limits
|
from libra.common.api.lbaas import LoadBalancer, Node, db_session, Limits
|
||||||
from libra.common.api.lbaas import Device, Counters
|
from libra.common.api.lbaas import Device, Counters
|
||||||
from libra.api.acl import get_limited_to_project
|
from libra.api.acl import get_limited_to_project
|
||||||
|
@@ -40,7 +40,7 @@ class V1Controller(object):
|
|||||||
response.status = 200
|
response.status = 200
|
||||||
return Responses.algorithms
|
return Responses.algorithms
|
||||||
|
|
||||||
#pecan uses this controller class for urls that start with /loadbalancers
|
# pecan uses this controller class for urls that start with /loadbalancers
|
||||||
loadbalancers = LoadBalancersController()
|
loadbalancers = LoadBalancersController()
|
||||||
limits = LimitsController()
|
limits = LimitsController()
|
||||||
protocols = ProtocolsController()
|
protocols = ProtocolsController()
|
||||||
|
@@ -322,7 +322,7 @@ class GearmanClientThread(object):
|
|||||||
counter.value += 1
|
counter.value += 1
|
||||||
session.commit()
|
session.commit()
|
||||||
|
|
||||||
#Notify billing of the LB deletion
|
# Notify billing of the LB deletion
|
||||||
update_mnb('lbaas.instance.delete', self.lbid, tenant_id)
|
update_mnb('lbaas.instance.delete', self.lbid, tenant_id)
|
||||||
|
|
||||||
def _set_error(self, device_id, errmsg, session):
|
def _set_error(self, device_id, errmsg, session):
|
||||||
|
@@ -88,7 +88,7 @@ class Vip(DeclarativeBase):
|
|||||||
class Device(DeclarativeBase):
|
class Device(DeclarativeBase):
|
||||||
"""device model"""
|
"""device model"""
|
||||||
__tablename__ = 'devices'
|
__tablename__ = 'devices'
|
||||||
#column definitions
|
# column definitions
|
||||||
az = Column(u'az', INTEGER(), nullable=False)
|
az = Column(u'az', INTEGER(), nullable=False)
|
||||||
created = Column(u'created', FormatedDateTime(), nullable=False)
|
created = Column(u'created', FormatedDateTime(), nullable=False)
|
||||||
floatingIpAddr = Column(
|
floatingIpAddr = Column(
|
||||||
@@ -107,7 +107,7 @@ class Device(DeclarativeBase):
|
|||||||
class LoadBalancer(DeclarativeBase):
|
class LoadBalancer(DeclarativeBase):
|
||||||
"""load balancer model"""
|
"""load balancer model"""
|
||||||
__tablename__ = 'loadbalancers'
|
__tablename__ = 'loadbalancers'
|
||||||
#column definitions
|
# column definitions
|
||||||
algorithm = Column(u'algorithm', VARCHAR(length=80), nullable=False)
|
algorithm = Column(u'algorithm', VARCHAR(length=80), nullable=False)
|
||||||
errmsg = Column(u'errmsg', VARCHAR(length=128), nullable=True)
|
errmsg = Column(u'errmsg', VARCHAR(length=128), nullable=True)
|
||||||
id = Column(u'id', BIGINT(), primary_key=True, nullable=False)
|
id = Column(u'id', BIGINT(), primary_key=True, nullable=False)
|
||||||
@@ -137,7 +137,7 @@ class LoadBalancer(DeclarativeBase):
|
|||||||
class Node(DeclarativeBase):
|
class Node(DeclarativeBase):
|
||||||
"""node model"""
|
"""node model"""
|
||||||
__tablename__ = 'nodes'
|
__tablename__ = 'nodes'
|
||||||
#column definitions
|
# column definitions
|
||||||
address = Column(u'address', VARCHAR(length=128), nullable=False)
|
address = Column(u'address', VARCHAR(length=128), nullable=False)
|
||||||
enabled = Column(u'enabled', INTEGER(), nullable=False)
|
enabled = Column(u'enabled', INTEGER(), nullable=False)
|
||||||
id = Column(u'id', BIGINT(), primary_key=True, nullable=False)
|
id = Column(u'id', BIGINT(), primary_key=True, nullable=False)
|
||||||
@@ -153,7 +153,7 @@ class Node(DeclarativeBase):
|
|||||||
class HealthMonitor(DeclarativeBase):
|
class HealthMonitor(DeclarativeBase):
|
||||||
"""monitors model"""
|
"""monitors model"""
|
||||||
__tablename__ = 'monitors'
|
__tablename__ = 'monitors'
|
||||||
#column definitions
|
# column definitions
|
||||||
lbid = Column(
|
lbid = Column(
|
||||||
u'lbid', BIGINT(), ForeignKey('loadbalancers.id'), primary_key=True,
|
u'lbid', BIGINT(), ForeignKey('loadbalancers.id'), primary_key=True,
|
||||||
nullable=False
|
nullable=False
|
||||||
@@ -177,7 +177,7 @@ class Billing(DeclarativeBase):
|
|||||||
class Stats(DeclarativeBase):
|
class Stats(DeclarativeBase):
|
||||||
"""stats model"""
|
"""stats model"""
|
||||||
__tablename__ = 'stats'
|
__tablename__ = 'stats'
|
||||||
#column definitions
|
# column definitions
|
||||||
id = Column(u'id', BIGINT(), primary_key=True, nullable=False)
|
id = Column(u'id', BIGINT(), primary_key=True, nullable=False)
|
||||||
lbid = Column(
|
lbid = Column(
|
||||||
u'lbid', BIGINT(), ForeignKey('loadbalancers.id'), primary_key=True,
|
u'lbid', BIGINT(), ForeignKey('loadbalancers.id'), primary_key=True,
|
||||||
@@ -192,7 +192,7 @@ class Stats(DeclarativeBase):
|
|||||||
class Ports(DeclarativeBase):
|
class Ports(DeclarativeBase):
|
||||||
"""ports model"""
|
"""ports model"""
|
||||||
__tablename__ = 'ports'
|
__tablename__ = 'ports'
|
||||||
#column definitions
|
# column definitions
|
||||||
id = Column(u'id', BIGINT(), primary_key=True, nullable=False)
|
id = Column(u'id', BIGINT(), primary_key=True, nullable=False)
|
||||||
protocol = Column(u'protocol', VARCHAR(length=50), nullable=False)
|
protocol = Column(u'protocol', VARCHAR(length=50), nullable=False)
|
||||||
portnum = Column(u'portnum', BIGINT(), nullable=False)
|
portnum = Column(u'portnum', BIGINT(), nullable=False)
|
||||||
|
@@ -310,7 +310,7 @@ def _send_test(event_type, lbid, tenant_id):
|
|||||||
LOG.info("Aborting test Notifications. Could not connect")
|
LOG.info("Aborting test Notifications. Could not connect")
|
||||||
return
|
return
|
||||||
|
|
||||||
#Note lbid is the number of notifications to send
|
# Note lbid is the number of notifications to send
|
||||||
lbid += 1
|
lbid += 1
|
||||||
for x in xrange(1, lbid):
|
for x in xrange(1, lbid):
|
||||||
payload = _build_payload(now, now, "Test LB", str(x),
|
payload = _build_payload(now, now, "Test LB", str(x),
|
||||||
|
@@ -31,7 +31,7 @@ def get_descriptors():
|
|||||||
descriptors = []
|
descriptors = []
|
||||||
|
|
||||||
def _add(fh):
|
def _add(fh):
|
||||||
if not fh in descriptors:
|
if fh not in descriptors:
|
||||||
descriptors.append(fh)
|
descriptors.append(fh)
|
||||||
|
|
||||||
for logger in log._loggers.values():
|
for logger in log._loggers.values():
|
||||||
|
@@ -82,9 +82,9 @@ class HAProxyDriver(LoadBalancerDriver):
|
|||||||
if proto == 'galera':
|
if proto == 'galera':
|
||||||
real_proto = 'tcp'
|
real_proto = 'tcp'
|
||||||
|
|
||||||
#------------------------
|
# ------------------------
|
||||||
# Frontend configuration
|
# Frontend configuration
|
||||||
#------------------------
|
# ------------------------
|
||||||
output.append('frontend %s-in' % real_proto)
|
output.append('frontend %s-in' % real_proto)
|
||||||
output.append(' mode %s' % real_proto)
|
output.append(' mode %s' % real_proto)
|
||||||
output.append(' bind %s:%s' % (protocfg['bind_address'],
|
output.append(' bind %s:%s' % (protocfg['bind_address'],
|
||||||
@@ -100,9 +100,9 @@ class HAProxyDriver(LoadBalancerDriver):
|
|||||||
elif real_proto == 'tcp':
|
elif real_proto == 'tcp':
|
||||||
output.append(' option tcplog')
|
output.append(' option tcplog')
|
||||||
|
|
||||||
#------------------------
|
# ------------------------
|
||||||
# Backend configuration
|
# Backend configuration
|
||||||
#------------------------
|
# ------------------------
|
||||||
|
|
||||||
output.append('backend %s-servers' % real_proto)
|
output.append('backend %s-servers' % real_proto)
|
||||||
output.append(' mode %s' % real_proto)
|
output.append(' mode %s' % real_proto)
|
||||||
|
Reference in New Issue
Block a user