def get_configured_monitor_bindings():
     log('Entering get_configured_monitor_bindings')
     bindings = {}
     if 'monitorbindings' in module.params and module.params['monitorbindings'] is not None:
         for binding in module.params['monitorbindings']:
             readwrite_attrs = [
                 'monitorname',
                 'servicename',
             ]
             readonly_attrs = []
             if isinstance(binding, dict):
                 attribute_values_dict = copy.deepcopy(binding)
             else:
                 attribute_values_dict = {
                     'monitorname': binding
                 }
             attribute_values_dict['servicename'] = module.params['name']
             binding_proxy = ConfigProxy(
                 actual=lbmonitor_service_binding(),
                 client=client,
                 attribute_values_dict=attribute_values_dict,
                 readwrite_attrs=readwrite_attrs,
                 readonly_attrs=readonly_attrs,
             )
             key = attribute_values_dict['monitorname']
             bindings[key] = binding_proxy
     return bindings
Esempio n. 2
0
def BindMonitorServiceList(sess, serviceList, monitorname):
    l = []

    for svc in serviceList:
        binding = LBMONSVCBINDING.lbmonitor_service_binding()
        binding.servicename = svc.name
        binding.monitorname = monitorname
        l.append(binding)

    LBMONSVCBINDING.lbmonitor_service_binding.add(sess, l)
    return l
Esempio n. 3
0
def get_configured_monitor_bindings(client, module, monitor_bindings_rw_attrs):
    bindings = {}
    if module.params['monitor_bindings'] is not None:
        for binding in module.params['monitor_bindings']:
            attribute_values_dict = copy.deepcopy(binding)
            # attribute_values_dict['servicename'] = module.params['name']
            attribute_values_dict['servicegroupname'] = module.params['name']
            binding_proxy = ConfigProxy(
                actual=lbmonitor_service_binding(),
                client=client,
                attribute_values_dict=attribute_values_dict,
                readwrite_attrs=monitor_bindings_rw_attrs,
            )
            key = binding_proxy.monitorname
            bindings[key] = binding_proxy
    return bindings
Esempio n. 4
0
def get_configured_monitor_bindings(client, module, monitor_bindings_rw_attrs):
    bindings = {}
    if module.params['monitor_bindings'] is not None:
        for binding in module.params['monitor_bindings']:
            attribute_values_dict = copy.deepcopy(binding)
            # attribute_values_dict['servicename'] = module.params['name']
            attribute_values_dict['servicegroupname'] = module.params['name']
            binding_proxy = ConfigProxy(
                actual=lbmonitor_service_binding(),
                client=client,
                attribute_values_dict=attribute_values_dict,
                readwrite_attrs=monitor_bindings_rw_attrs,
            )
            key = binding_proxy.monitorname
            bindings[key] = binding_proxy
    return bindings
Esempio n. 5
0
def get_actual_monitor_bindings(client, module):
    bindings = {}
    if service_lbmonitor_binding.count(client, module.params['name']) == 0:
        return bindings

    # Fallthrough to rest of execution
    for binding in service_lbmonitor_binding.get(client, module.params['name']):
        # Excluding default monitors since we cannot operate on them
        if binding.monitor_name in ('tcp-default', 'ping-default'):
            continue
        key = binding.monitor_name
        actual = lbmonitor_service_binding()
        actual.weight = binding.weight
        actual.monitorname = binding.monitor_name
        actual.dup_weight = binding.dup_weight
        actual.servicename = module.params['name']
        bindings[key] = actual

    return bindings
Esempio n. 6
0
def get_actual_monitor_bindings(client, module):
    bindings = {}
    if service_lbmonitor_binding.count(client, module.params['name']) == 0:
        return bindings

    # Fallthrough to rest of execution
    for binding in service_lbmonitor_binding.get(client, module.params['name']):
        # Excluding default monitors since we cannot operate on them
        if binding.monitor_name in ('tcp-default', 'ping-default'):
            continue
        key = binding.monitor_name
        actual = lbmonitor_service_binding()
        actual.weight = binding.weight
        actual.monitorname = binding.monitor_name
        actual.dup_weight = binding.dup_weight
        actual.servicename = module.params['name']
        bindings[key] = actual

    return bindings
Esempio n. 7
0
 def sync_bindings():
     delete_all_bindings()
     if 'servicebindings' in module.params and module.params['servicebindings'] is not None:
         for servicebinding in module.params['servicebindings']:
             attribute_values_dict  = copy.deepcopy(servicebinding)
             readwrite_attrs = [
                 'servicename',
                 'servicegroupname',
                 'weight',
                 'monitorname',
             ]
             attribute_values_dict['monitorname'] = module.params['monitorname']
             readonly_attrs = []
             binding_proxy = ConfigProxy(
                 actual=lbmonitor_service_binding(),
                 client=client,
                 attribute_values_dict=attribute_values_dict,
                 readwrite_attrs=readwrite_attrs,
                 readonly_attrs=readonly_attrs,
             )
             binding_proxy.add()
    def sync_monitor_bindings():
        log('Entering sync_monitor_bindings')
        # Delete existing bindings
        for binding in get_actual_monitor_bindings().values():
            b = lbmonitor_service_binding()
            b.monitorname = binding.monitor_name
            b.servicename = module.params['name']
            # Cannot remove default monitor bindings
            if b.monitorname in ('tcp-default', 'ping-default'):
                continue
            lbmonitor_service_binding.delete(client, b)
            continue

            binding.monitorname = binding.monitor_name
            log('Will delete %s' % dir(binding))
            log('Name %s' % binding.name)
            log('monitor Name %s' % binding.monitor_name)
            binding.delete(client, binding)
            #service_lbmonitor_binding.delete(client, binding)

        # Apply configured bindings

        for binding in get_configured_monitor_bindings().values():
            binding.add()
Esempio n. 9
0
def     BindMonitor(sess,svcname,monitorname) :
        binding = LBMONSVCBINDING.lbmonitor_service_binding()
        binding.servicename = svcname
        binding.monitorname = monitorname
        LBMONSVCBINDING.lbmonitor_service_binding.add(sess,binding)