Skip to content

Commit

Permalink
Merge pull request #179 from jlongstaf/feature.sdk-alias
Browse files Browse the repository at this point in the history
f5-sdk requires assigning return values for load() and create()
  • Loading branch information
zancas authored Jul 7, 2016
2 parents a849d71 + e7555fa commit aef2e63
Show file tree
Hide file tree
Showing 12 changed files with 98 additions and 158 deletions.
3 changes: 2 additions & 1 deletion f5_openstack_agent/lbaasv2/drivers/bigip/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ def main():
config.register_root_helper(cfg.CONF)

common_config.init(sys.argv[1:])
config.setup_logging() # alias for common_config.setup_logging()...
# alias for common_config.setup_logging()...
config.setup_logging()

mgr = manager.LbaasAgentManager(cfg.CONF)

Expand Down
6 changes: 3 additions & 3 deletions f5_openstack_agent/lbaasv2/drivers/bigip/agent_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
# XXX OPTS is used in (at least) agent.py Maybe move/rename to agent.py
OPTS = [
cfg.StrOpt( # XXX should we use this with internal classes?
'f5_bigip_lbaas_device_driver', # XXX maybe remove "device" and "f5"?
'f5_bigip_lbaas_device_driver', # XXX maybe remove "device" and "f5"?
default=('f5_openstack_agent.lbaasv2.drivers.bigip.icontrol_driver.'
'iControlDriver'),
help=('The driver used to provision BigIPs')
Expand Down Expand Up @@ -114,7 +114,7 @@
class LogicalServiceCache(object):
"""Manage a cache of known services."""

class Service(object): # XXX maybe promote/use this class elsewhere?
class Service(object): # XXX maybe promote/use this class elsewhere?
"""Inner classes used to hold values for weakref lookups."""

def __init__(self, port_id, loadbalancer_id, tenant_id, agent_host):
Expand Down Expand Up @@ -201,7 +201,7 @@ def get_agent_hosts(self):
return agent_hosts.keys()


class LbaasAgentManager(periodic_task.PeriodicTasks): # b --> B
class LbaasAgentManager(periodic_task.PeriodicTasks): # b --> B
"""Periodic task that is an endpoint for plugin to agent RPC."""

RPC_API_VERSION = '1.0'
Expand Down
22 changes: 10 additions & 12 deletions f5_openstack_agent/lbaasv2/drivers/bigip/icontrol_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
# limitations under the License.
#

from pprint import pprint as pp
import datetime
import hashlib
import logging as std_logging
Expand Down Expand Up @@ -278,7 +277,7 @@ def wrapper(*args, **kwargs):
return method(*args, **kwargs)
except IOError as ioe:
LOG.error('IO Error detected: %s' % method.__name__)
instance.connect_bigips() #what's this do?
instance.connect_bigips() # what's this do?
raise ioe
else:
LOG.error('Cannot execute %s. Not connected. Connecting.'
Expand All @@ -300,23 +299,23 @@ def __init__(self, conf, registerOpts=True):
self.conf.register_opts(OPTS)
self.hostnames = None
self.device_type = conf.f5_device_type
self.plugin_rpc = None # overrides base, same value
self.plugin_rpc = None # overrides base, same value
self.__last_connect_attempt = None
self.connected = False # overrides base, same value
self.connected = False # overrides base, same value
self.driver_name = 'f5-lbaasv2-icontrol'

# BIG-IP® containers
self.__bigips = {}
self.__traffic_groups = []
self.agent_configurations = {} # overrides base, same value
self.agent_configurations = {} # overrides base, same value
self.tenant_manager = None
self.cluster_manager = None
self.system_helper = None
self.lbaas_builder = None
self.service_adapter = None
self.vlan_binding = None
self.l3_binding = None
self.cert_manager = None # overrides register_OPTS
self.cert_manager = None # overrides register_OPTS

if self.conf.f5_global_routed_mode:
LOG.info('WARNING - f5_global_routed_mode enabled.'
Expand Down Expand Up @@ -507,12 +506,12 @@ def _init_bigips(self):
except NeutronException as exc:
LOG.error('Could not communicate with all ' +
'iControl devices: %s' % exc.msg)
greenthread.sleep(5) # this should probably go away
greenthread.sleep(5) # this should probably go away
raise
except Exception as exc:
LOG.error('Could not communicate with all ' +
'iControl devices: %s' % exc.message)
greenthread.sleep(5) # this should probably go away
greenthread.sleep(5) # this should probably go away
raise

def _open_bigip(self, hostname):
Expand Down Expand Up @@ -992,7 +991,7 @@ def _service_exists(self, service):
# folder=service['pool']['tenant_id'],
# config_mode=self.conf.icontrol_config_mode)
return True

def _common_service_handler(self, service, delete_partition=False):
# Assure that the service is configured on bigip(s)
start_time = time()
Expand All @@ -1001,7 +1000,6 @@ def _common_service_handler(self, service, delete_partition=False):
LOG.error("_common_service_handler: Service loadbalancer is None")
return

pp('about to attempt assure_tenant_created')
try:
self.tenant_manager.assure_tenant_created(service)
LOG.debug(" _assure_tenant_created took %.5f secs" %
Expand Down Expand Up @@ -1202,9 +1200,9 @@ def get_bigip(self):
# As implemented I think this always returns the "first" bigip
# without any HTTP traffic? CONFIRMED: __bigips are mgmt_rts
hostnames = sorted(self.__bigips)
for i in range(len(hostnames)): # C-style make Pythonic.
for i in range(len(hostnames)): # C-style make Pythonic.
try:
bigip = self.__bigips[hostnames[i]] # Calling devices?!
bigip = self.__bigips[hostnames[i]] # Calling devices?!
return bigip
except urllib2.URLError:
pass
Expand Down
8 changes: 4 additions & 4 deletions f5_openstack_agent/lbaasv2/drivers/bigip/lbaas_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ def __init__(self, conf): # XXX 'conf' appears to be unused
subclassing...
'''
self.agent_id = None
self.plugin_rpc = None # XXX This is overridden in the only known subclass
self.connected = False # XXX This is overridden in the only known subclass
self.plugin_rpc = None # XXX overridden in the only known subclass
self.connected = False # XXX overridden in the only known subclass
self.service_queue = []
self.agent_configurations = {} # XXX overridden in subclass
self.agent_configurations = {} # XXX overridden in subclass

def set_context(self, context):
"""Set the global context object for the lbaas driver """
Expand All @@ -36,7 +36,7 @@ def post_init(self):
"""Run after agent is fully connected """
raise NotImplementedError()

def set_tunnel_rpc(self, tunnel_rpc): # XXX into this class?
def set_tunnel_rpc(self, tunnel_rpc): # XXX into this class?
"""Provide FDB Connector RPC access """
raise NotImplementedError()

Expand Down
24 changes: 12 additions & 12 deletions f5_openstack_agent/lbaasv2/drivers/bigip/listener_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ def update_listener_pool(self, service, name, bigips):
for bigip in bigips:
v = bigip.tm.ltm.virtuals.virtual
if v.exists(name=vip["name"], partition=vip["partition"]):
v.load(name=vip["name"], partition=vip["partition"])
v.update(**vip)
obj = v.load(name=vip["name"], partition=vip["partition"])
obj.update(**vip)

def update_session_persistence(self, service, bigips):
"""Update session persistence for virtual server.
Expand Down Expand Up @@ -217,8 +217,8 @@ def _add_profile(self, vip, profile_name, bigip, context='all'):
:param bigip: Single BigIP instances to update.
"""
v = bigip.tm.ltm.virtuals.virtual
v.load(name=vip["name"], partition=vip["partition"])
p = v.profiles_s
obj = v.load(name=vip["name"], partition=vip["partition"])
p = obj.profiles_s
profiles = p.get_collection()

# see if profile exists
Expand Down Expand Up @@ -333,8 +333,8 @@ def _remove_ssl_profile(self, name, bigip):
try:
ssl_client_profile = bigip.tm.ltm.profile.client_ssls.client_ssl
if ssl_client_profile.exists(name=name, partition='Common'):
ssl_client_profile.load(name=name, partition='Common')
ssl_client_profile.delete()
obj = ssl_client_profile.load(name=name, partition='Common')
obj.delete()

except Exception as err:
# Not necessarily an error -- profile might be referenced
Expand All @@ -353,8 +353,8 @@ def _remove_profile(self, vip, profile_name, bigip):
"""
try:
v = bigip.tm.ltm.virtuals.virtual
v.load(name=vip["name"], partition=vip["partition"])
p = v.profiles_s
obj = v.load(name=vip["name"], partition=vip["partition"])
p = obj.profiles_s
profiles = p.get_collection()

# see if profile exists
Expand Down Expand Up @@ -382,12 +382,12 @@ def _remove_cookie_persist_rule(self, vip, bigip):

u = bigip.tm.ltm.persistences.universals.universal
if u.exists(name=rule_name, partition=vip["partition"]):
u.load(name=rule_name, partition=vip["partition"])
u.delete()
obj = u.load(name=rule_name, partition=vip["partition"])
obj.delete()
LOG.debug("Deleted persistence universal %s" % rule_name)

r = bigip.tm.ltm.rules.rule
if r.exists(name=rule_name, partition=vip["partition"]):
r.load(name=rule_name, partition=vip["partition"])
r.delete()
obj = r.load(name=rule_name, partition=vip["partition"])
obj.delete()
LOG.debug("Deleted rule %s" % rule_name)
Loading

0 comments on commit aef2e63

Please sign in to comment.