Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcus Vinicius G. Cesario committed May 9, 2016
2 parents 2ec746d + 57c30ad commit dc6105b
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 26 deletions.
25 changes: 16 additions & 9 deletions networkapi/plugins/F5/Generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ def create_pool(self, pools):
self.__create_pool(pools)

def __create_pool(self, pools):
log.info('__create_pool')

monitor_associations = []
pls = util.trata_param_pool(pools)
Expand Down Expand Up @@ -169,9 +170,6 @@ def __create_pool(self, pools):
monitor_state=pls['pools_members']['monitor'],
session_state=pls['pools_members']['session'])

nd = node.Node(self._lb)
nd.set_monitor_rule(monitor_associations=monitor_associations_nodes)

except Exception, e:
self._lb._channel.System.Session.rollback_transaction()
if monitor_associations != []:
Expand All @@ -183,12 +181,19 @@ def __create_pool(self, pools):
else:
self._lb._channel.System.Session.submit_transaction()

try:
if monitor_associations_nodes.get('nodes'):
nd = node.Node(self._lb)
nd.set_monitor_rule(monitor_associations=monitor_associations_nodes)
except bigsuds.OperationFailed:
pass

@util.connection
def update_pool(self, pools):
self.__update_pool(pools)

def __update_pool(self, pools):
log.info('update_pool')
log.info('__update_pool')
monitor_associations = []
pls = util.trata_param_pool(pools)

Expand Down Expand Up @@ -315,9 +320,6 @@ def __update_pool(self, pools):
monitor_state=pls['pools_members']['monitor'],
session_state=pls['pools_members']['session'])

nd = node.Node(self._lb)
nd.set_monitor_rule(monitor_associations=monitor_associations_nodes)

except Exception, e:
self._lb._channel.System.Session.rollback_transaction()

Expand All @@ -332,6 +334,11 @@ def __update_pool(self, pools):
self._lb._channel.System.Session.submit_transaction()

try:

if monitor_associations_nodes.get('nodes'):
nd = node.Node(self._lb)
nd.set_monitor_rule(monitor_associations=monitor_associations_nodes)

if pls['pools_confirm']['pools_names']:
plm.set_member_monitor_state(
names=pls['pools_confirm']['pools_names'],
Expand All @@ -350,10 +357,10 @@ def __update_pool(self, pools):

@util.connection
def delete_pool(self, pools):
self.delete_pool(pools)
self.__delete_pool(pools)

def __delete_pool(self, pools):
log.info('delete_pool')
log.info('__delete_pool')

pls = util.trata_param_pool(pools)

Expand Down
17 changes: 11 additions & 6 deletions networkapi/plugins/F5/lb.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,14 @@ def __init__(self, hostname, username, password):
logging.critical("Unable to connect to BIG-IP. Details: %s" % (e))
raise base_exceptions.CommandErrorException(e)
else:
self._version = self._channel.System.SystemInfo.get_version()
if self._version[8:len(self._version)].split('.')[0] <= 10:
raise base_exceptions.UnsupportedVersion(
'This plugin only supports BIG-IP v11 or above')
else:
self._channel = self._channel.with_session_id()
log.info('connected in hostname:%s' % hostname)
try:
self._version = self._channel.System.SystemInfo.get_version()
log.info('self._version %s' % self._version)
if self._version[8:len(self._version)].split('.')[0] <= 10:
raise base_exceptions.UnsupportedVersion(
'This plugin only supports BIG-IP v11 or above')
else:
self._channel = self._channel.with_session_id()
except:
raise base_exceptions.CommandErrorException('There are too many existing user sessions. Please try later')
23 changes: 12 additions & 11 deletions networkapi/plugins/F5/monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,17 +86,18 @@ def prepare_template(self, **kwargs):
monitor_association['monitor_rule']['quorum'] = 0
monitor_associations.append(monitor_association)

for node in kwargs['members'][i]:
monitor_association_node = {
'monitor_templates': [],
'type': None,
'quorum': None
}
monitor_association_node['monitor_templates'].append('icmp')
monitor_association_node['type'] = 'MONITOR_RULE_TYPE_SINGLE'
monitor_association_node['quorum'] = 0
monitor_associations_nodes['monitor_rules'].append(monitor_association_node)
monitor_associations_nodes['nodes'].append(node['address'])
if name == 'udp':
for node in kwargs['members'][i]:
monitor_association_node = {
'monitor_templates': [],
'type': None,
'quorum': None
}
monitor_association_node['monitor_templates'].append('icmp')
monitor_association_node['type'] = 'MONITOR_RULE_TYPE_SINGLE'
monitor_association_node['quorum'] = 0
monitor_associations_nodes['monitor_rules'].append(monitor_association_node)
monitor_associations_nodes['nodes'].append(node['address'])

except Exception, e:
log.error(e)
Expand Down

0 comments on commit dc6105b

Please sign in to comment.