def get_hashed_route_rules(route_rules): route_rules_reprs = [] supported_route_rule_attributes = ['cidr_block', 'destination', 'destination_type', 'network_entity_id'] for route_rule in route_rules: hashed_route_rule = oci_utils.get_hashed_object( RouteRule, route_rule, supported_attributes=supported_route_rule_attributes) route_rules_reprs.append(hashed_route_rule) return route_rules_reprs
def get_hashed_route_rules(route_rules): route_rules_reprs = [] supported_route_rule_attributes = ["cidr_block", "network_entity_id"] for route_rule in route_rules: hashed_route_rule = oci_utils.get_hashed_object( RouteRule, route_rule, supported_attributes=supported_route_rule_attributes) route_rules_reprs.append(hashed_route_rule) return route_rules_reprs
def update_listener(lb_client, module, listener, lb_id, name): result = dict(listener=to_dict(listener), changed=False) update_listener_details = UpdateListenerDetails() changed = False get_logger().info("Updating listener %s in load balancer %s", name, lb_id) for attribute in update_listener_details.attribute_map.keys(): if attribute not in [ "ssl_configuration", "connection_configuration", "hostname_names", ]: changed = oci_utils.check_and_update_attributes( update_listener_details, attribute, module.params.get(attribute, None), getattr(listener, attribute), changed, ) input_ssl_configuration = oci_lb_utils.create_ssl_configuration( module.params.get("ssl_configuration", None) ) existing_ssl_configuration = oci_utils.get_hashed_object( SSLConfigurationDetails, listener.ssl_configuration ) ssl_configuration_changed = oci_utils.check_and_update_attributes( update_listener_details, "ssl_configuration", input_ssl_configuration, existing_ssl_configuration, False, ) input_connection_configuration = oci_lb_utils.create_connection_configuration( module.params.get("connection_configuration", None) ) existing_connection_configuration = oci_utils.get_hashed_object( ConnectionConfiguration, listener.connection_configuration ) connection_configuration_changed = oci_utils.check_and_update_attributes( update_listener_details, "connection_configuration", input_connection_configuration, existing_connection_configuration, False, ) input_hostname_names = module.params.get("hostname_names", None) update_listener_details.hostname_names = listener.hostname_names hostname_names_changed = False if input_hostname_names is not None: ( changed_hostname_names, hostname_names_changed, ) = oci_utils.check_and_return_component_list_difference( input_hostname_names, listener.hostname_names, module.params.get("purge_hostname_names"), module.params.get("delete_hostname_names"), ) if hostname_names_changed: update_listener_details.hostname_names = changed_hostname_names changed = ( changed or ssl_configuration_changed or connection_configuration_changed or hostname_names_changed ) get_logger().debug( "Existing listener property values: %s, input property values: %s", listener, update_listener_details, ) if changed: result = oci_lb_utils.create_or_update_lb_resources_and_wait( resource_type="listener", function=lb_client.update_listener, kwargs_function={ "update_listener_details": update_listener_details, "load_balancer_id": lb_id, "listener_name": name, }, lb_client=lb_client, get_sub_resource_fn=oci_lb_utils.get_listener, kwargs_get={ "lb_client": lb_client, "module": module, "load_balancer_id": lb_id, "name": name, }, module=module, ) else: get_logger().info( "Successfully updated listener %s in load balancer %s", name, lb_id ) return result
def update_listener(lb_client, module, listener, lb_id, name): result = dict(listener=to_dict(listener), changed=False) update_listener_details = UpdateListenerDetails() changed = False get_logger().info("Updating listener %s in load balancer %s", name, lb_id) for attribute in update_listener_details.attribute_map.keys(): if attribute not in [ 'ssl_configuration', 'connection_configuration', 'hostname_names' ]: changed = oci_utils.check_and_update_attributes( update_listener_details, attribute, module.params.get(attribute, None), getattr(listener, attribute), changed) input_ssl_configuration = oci_lb_utils.create_ssl_configuration( module.params.get('ssl_configuration', None)) existing_ssl_configuration = oci_utils.get_hashed_object( SSLConfigurationDetails, listener.ssl_configuration) ssl_configuration_changed = oci_utils.check_and_update_attributes( update_listener_details, 'ssl_configuration', input_ssl_configuration, existing_ssl_configuration, False) input_connection_configuration = oci_lb_utils.create_connection_configuration( module.params.get('connection_configuration', None)) existing_connection_configuration = oci_utils.get_hashed_object( ConnectionConfiguration, listener.connection_configuration) connection_configuration_changed = oci_utils.check_and_update_attributes( update_listener_details, 'connection_configuration', input_connection_configuration, existing_connection_configuration, False) input_hostname_names = module.params.get('hostname_names', None) update_listener_details.hostname_names = listener.hostname_names hostname_names_changed = False if input_hostname_names is not None: changed_hostname_names, hostname_names_changed = oci_lb_utils.check_and_return_component_list_difference( input_hostname_names, listener.hostname_names, module.params.get('purge_hostname_names')) if hostname_names_changed: update_listener_details.hostname_names = changed_hostname_names changed = changed or ssl_configuration_changed or connection_configuration_changed or hostname_names_changed get_logger().debug( "Existing listener property values: %s, input property values: %s", listener, update_listener_details) if changed: result = oci_lb_utils.create_or_update_lb_resources_and_wait( resource_type='listener', function=lb_client.update_listener, kwargs_function={ 'update_listener_details': update_listener_details, 'load_balancer_id': lb_id, 'listener_name': name }, lb_client=lb_client, get_sub_resource_fn=oci_lb_utils.get_listener, kwargs_get={ 'lb_client': lb_client, 'module': module, 'load_balancer_id': lb_id, 'name': name }, module=module) return result