~mpontillo/maas/beaconing--replies-from-maas--wip

« back to all changes in this revision

Viewing changes to src/maasserver/triggers/system.py

  • Committer: Mike Pontillo
  • Date: 2017-06-19 22:29:18 UTC
  • mfrom: (6085.2.8 maas)
  • Revision ID: mike.pontillo@canonical.com-20170619222918-4pzgkvgr9b7cbob2
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1050
1050
    """)
1051
1051
 
1052
1052
 
 
1053
# Triggered when the proxy settings are updated.
 
1054
PEER_PROXY_CONFIG_INSERT = dedent("""\
 
1055
    CREATE OR REPLACE FUNCTION sys_proxy_config_use_peer_proxy_insert()
 
1056
    RETURNS trigger as $$
 
1057
    BEGIN
 
1058
      IF (NEW.name = 'enable_proxy' OR
 
1059
          NEW.name = 'use_peer_proxy' OR
 
1060
          NEW.name = 'http_proxy') THEN
 
1061
        PERFORM pg_notify('sys_proxy', '');
 
1062
      END IF;
 
1063
      RETURN NEW;
 
1064
    END;
 
1065
    $$ LANGUAGE plpgsql;
 
1066
    """)
 
1067
 
 
1068
 
 
1069
# Triggered when the proxy settings are updated.
 
1070
PEER_PROXY_CONFIG_UPDATE = dedent("""\
 
1071
    CREATE OR REPLACE FUNCTION sys_proxy_config_use_peer_proxy_update()
 
1072
    RETURNS trigger as $$
 
1073
    BEGIN
 
1074
      IF (NEW.name = 'enable_proxy' OR
 
1075
          NEW.name = 'use_peer_proxy' OR
 
1076
          NEW.name = 'http_proxy') THEN
 
1077
        PERFORM pg_notify('sys_proxy', '');
 
1078
      END IF;
 
1079
      RETURN NEW;
 
1080
    END;
 
1081
    $$ LANGUAGE plpgsql;
 
1082
    """)
 
1083
 
 
1084
 
1053
1085
def render_sys_dns_procedure(proc_name, on_delete=False):
1054
1086
    """Render a database procedure that creates a new DNS publication.
1055
1087
 
1338
1370
    register_trigger(
1339
1371
        "maasserver_subnet",
1340
1372
        "sys_proxy_subnet_delete", "delete")
 
1373
 
 
1374
    # - Config/http_proxy (when use_peer_proxy)
 
1375
    register_procedure(PEER_PROXY_CONFIG_INSERT)
 
1376
    register_trigger(
 
1377
        "maasserver_config", "sys_proxy_config_use_peer_proxy_insert",
 
1378
        "insert")
 
1379
    register_procedure(PEER_PROXY_CONFIG_UPDATE)
 
1380
    register_trigger(
 
1381
        "maasserver_config", "sys_proxy_config_use_peer_proxy_update",
 
1382
        "update")