Skip to content

Commit fe76522

Browse files
committed
Script to create (empty) mm lists, initially
1 parent b373797 commit fe76522

File tree

3 files changed

+143
-25
lines changed

3 files changed

+143
-25
lines changed

scripts/config-getter.py

Lines changed: 37 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,48 @@
77
from mailman.testing.documentation import dump_json
88
import os
99

10-
hostname="lists.boost.org"
11-
port_number="8001"
12-
rest_user="restadmin"
13-
rest_password=os.environ['REST_PASSWORD']
10+
hostname = "lists.boost.org"
11+
port_number = "8001"
12+
rest_user = "restadmin"
13+
rest_password = os.environ["REST_PASSWORD"]
1414

1515
if not rest_password:
1616
print("please set rest_password. Exiting.")
1717
exit(1)
1818

19-
urls={}
20-
urls["boost"]=f"http://{hostname}:{port_number}/3.1/lists/boost@{hostname}/config"
21-
urls["Boost-announce"]=f"http://{hostname}:{port_number}/3.1/lists/boost-announce@{hostname}/config"
22-
urls["Boost-users"]=f"http://{hostname}:{port_number}/3.1/lists/boost-users@{hostname}/config"
23-
settings={}
24-
settings["boost"]=dict(default_nonmember_action='reject', convert_html_to_plaintext='True', filter_content='True', dmarc_mitigate_action='munge_from', reply_goes_to_list='point_to_list', subject_prefix='[boost] ')
25-
settings["Boost-announce"]=dict(default_nonmember_action='reject', convert_html_to_plaintext='True', filter_content='True', dmarc_mitigate_action='munge_from', reply_goes_to_list='point_to_list', subject_prefix='[Boost-announce] ')
26-
settings["Boost-users"]=dict(default_nonmember_action='reject', convert_html_to_plaintext='True', filter_content='True', dmarc_mitigate_action='munge_from', reply_goes_to_list='point_to_list', subject_prefix='[Boost-users] ')
19+
urls = {}
20+
urls["boost"] = f"http://{hostname}:{port_number}/3.1/lists/boost@{hostname}/config"
21+
urls["Boost-announce"] = (
22+
f"http://{hostname}:{port_number}/3.1/lists/boost-announce@{hostname}/config"
23+
)
24+
urls["Boost-users"] = (
25+
f"http://{hostname}:{port_number}/3.1/lists/boost-users@{hostname}/config"
26+
)
27+
settings = {}
28+
settings["boost"] = dict(
29+
default_nonmember_action="reject",
30+
convert_html_to_plaintext="True",
31+
filter_content="True",
32+
dmarc_mitigate_action="munge_from",
33+
reply_goes_to_list="point_to_list",
34+
subject_prefix="[boost] ",
35+
)
36+
settings["Boost-announce"] = dict(
37+
default_nonmember_action="reject",
38+
convert_html_to_plaintext="True",
39+
filter_content="True",
40+
dmarc_mitigate_action="munge_from",
41+
reply_goes_to_list="point_to_list",
42+
subject_prefix="[Boost-announce] ",
43+
)
44+
settings["Boost-users"] = dict(
45+
default_nonmember_action="reject",
46+
convert_html_to_plaintext="True",
47+
filter_content="True",
48+
dmarc_mitigate_action="munge_from",
49+
reply_goes_to_list="point_to_list",
50+
subject_prefix="[Boost-users] ",
51+
)
2752

2853
for listname, request_url in urls.items():
2954
print(f"listname is {listname} and request_url is {request_url}")

scripts/config-setter.py

Lines changed: 44 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,56 @@
77
from mailman.testing.documentation import dump_json
88
import os
99

10-
hostname="lists.boost.org"
11-
port_number="8001"
12-
rest_user="restadmin"
13-
rest_password=os.environ['REST_PASSWORD']
10+
hostname = "lists.boost.org"
11+
port_number = "8001"
12+
rest_user = "restadmin"
13+
rest_password = os.environ["REST_PASSWORD"]
1414

1515
if not rest_password:
1616
print("please set rest_password. Exiting.")
1717
exit(1)
1818

19-
urls={}
20-
urls["boost"]=f"http://{hostname}:{port_number}/3.1/lists/boost@{hostname}/config"
21-
urls["Boost-announce"]=f"http://{hostname}:{port_number}/3.1/lists/boost-announce@{hostname}/config"
22-
urls["Boost-users"]=f"http://{hostname}:{port_number}/3.1/lists/boost-users@{hostname}/config"
23-
settings={}
24-
settings["boost"]=dict(default_nonmember_action='reject', convert_html_to_plaintext='True', filter_content='True', dmarc_mitigate_action='munge_from', reply_goes_to_list='point_to_list', subject_prefix='[boost] ')
25-
settings["Boost-announce"]=dict(default_nonmember_action='reject', convert_html_to_plaintext='True', filter_content='True', dmarc_mitigate_action='munge_from', reply_goes_to_list='point_to_list', subject_prefix='[Boost-announce] ')
26-
settings["Boost-users"]=dict(default_nonmember_action='reject', convert_html_to_plaintext='True', filter_content='True', dmarc_mitigate_action='munge_from', reply_goes_to_list='point_to_list', subject_prefix='[Boost-users] ')
19+
urls = {}
20+
urls["boost"] = f"http://{hostname}:{port_number}/3.1/lists/boost@{hostname}/config"
21+
urls["Boost-announce"] = (
22+
f"http://{hostname}:{port_number}/3.1/lists/boost-announce@{hostname}/config"
23+
)
24+
urls["Boost-users"] = (
25+
f"http://{hostname}:{port_number}/3.1/lists/boost-users@{hostname}/config"
26+
)
27+
settings = {}
28+
settings["boost"] = dict(
29+
default_nonmember_action="reject",
30+
convert_html_to_plaintext="True",
31+
filter_content="True",
32+
dmarc_mitigate_action="munge_from",
33+
reply_goes_to_list="point_to_list",
34+
subject_prefix="[boost] ",
35+
)
36+
settings["Boost-announce"] = dict(
37+
default_nonmember_action="reject",
38+
convert_html_to_plaintext="True",
39+
filter_content="True",
40+
dmarc_mitigate_action="munge_from",
41+
reply_goes_to_list="point_to_list",
42+
subject_prefix="[Boost-announce] ",
43+
)
44+
settings["Boost-users"] = dict(
45+
default_nonmember_action="reject",
46+
convert_html_to_plaintext="True",
47+
filter_content="True",
48+
dmarc_mitigate_action="munge_from",
49+
reply_goes_to_list="point_to_list",
50+
subject_prefix="[Boost-users] ",
51+
)
2752

2853
for listname, request_url in urls.items():
2954
print(f"listname is {listname} and request_url is {request_url}")
3055
print("running dump_json")
31-
dump_json(request_url, settings[listname], 'PATCH', username=rest_user, password=rest_password)
56+
dump_json(
57+
request_url,
58+
settings[listname],
59+
"PATCH",
60+
username=rest_user,
61+
password=rest_password,
62+
)

scripts/create-lists.py

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#!/usr/bin/env python
2+
3+
# activate the venv first
4+
# . /opt/mailman3/bin/activate
5+
6+
import requests
7+
from mailman.testing.documentation import dump_json
8+
import os
9+
10+
hostname = "lists.boost.org"
11+
port_number = "8001"
12+
rest_user = "restadmin"
13+
rest_password = os.environ["REST_PASSWORD"]
14+
15+
if not rest_password:
16+
print("please set rest_password. Exiting.")
17+
exit(1)
18+
19+
# DOMAINS
20+
21+
domain = "lists.boost.org"
22+
url = f"http://{hostname}:{port_number}/3.1/domains"
23+
dump_json(
24+
url,
25+
{
26+
"mail_host": domain,
27+
},
28+
username=rest_user,
29+
password=rest_password,
30+
)
31+
32+
print("Next, view the result")
33+
34+
url = f"http://{hostname}:{port_number}/3.1/domains/{domain}"
35+
dump_json(url, username=rest_user, password=rest_password)
36+
37+
# LISTS
38+
39+
print("Now for lists\n")
40+
41+
lists = [
42+
43+
44+
45+
]
46+
url = f"http://{hostname}:{port_number}/3.1/lists"
47+
48+
for list in lists:
49+
dump_json(
50+
url,
51+
{
52+
"fqdn_listname": list,
53+
},
54+
username=rest_user,
55+
password=rest_password,
56+
)
57+
58+
print("Next, view the results")
59+
60+
for list in lists:
61+
url = f"http://{hostname}:{port_number}/3.1/lists/{list}"
62+
dump_json(url, username=rest_user, password=rest_password)

0 commit comments

Comments
 (0)