-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_env_files.py
59 lines (49 loc) · 1.54 KB
/
build_env_files.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import json
fablo_dict = json.load(open('./fablo-config.json', 'r'))
json_config_file = {
"port": 3000,
"orgs": {},
"channels": {},
"chaincodes": fablo_dict['chaincodes']
}
# Add orgs
for i in fablo_dict['orgs']:
org_name = i['organization']['name']
domain = i['organization']['domain']
connectionProfile = json.load(
open(
f'./fablo-target/fabric-config/connection-profiles/connection-profile-{org_name.lower()}.json',
'r'
)
)
certificate = open(
f'./fablo-target/fabric-config/crypto-config/peerOrganizations/{domain}/users/User1@{domain}/msp/signcerts/User1@{domain}-cert.pem',
'r'
)
privateKey = open(
f'./fablo-target/fabric-config/crypto-config/peerOrganizations/{domain}/users/User1@{domain}/msp/keystore/priv-key.pem',
'r'
)
json_config_file['orgs'][org_name] = {
"msp": i['organization']['name'] + "MSP",
"connectionProfile": json.dumps(connectionProfile),
"certificate": str(certificate.read()),
"privateKey": str(privateKey.read())
}
# Add channels
for i in fablo_dict['channels']:
json_config_file['channels'][i['name']] = {
"acceptOrgs": [
j['name']
for j in i['orgs']
]
}
LOCALS_TO_SAVE = [
"./zeus-middleware-api/env.json",
"./mechanic-cli/env.json",
"./scripts/env.json",
]
# Saving file
for local_to_save in LOCALS_TO_SAVE:
with open(local_to_save, "w") as outfile:
outfile.write(json.dumps(json_config_file, indent=4))