Skip to content

Commit

Permalink
add --webui.disabled and --webui.expose-ports options
Browse files Browse the repository at this point in the history
  • Loading branch information
reliveyy committed Jul 8, 2020
1 parent feec11e commit a147a4c
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 51 deletions.
90 changes: 42 additions & 48 deletions images/utils/launcher/config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,10 @@ def parse_command_line_arguments(self):

parser.add_argument("--boltz.disabled", nargs='?')

parser.add_argument("--use-local-images")
parser.add_argument("--webui.disabled", nargs='?')
parser.add_argument("--webui.expose-ports")

parser.add_argument("--dev", action="store_true")
parser.add_argument("--webui", action="store_true")

self.args = parser.parse_args()
self.logger.info("Parsed command-line arguments: %r", self.args)
Expand Down Expand Up @@ -162,17 +163,21 @@ def update_volume(self, volumes, container_dir, host_dir):
target = target[0]
target["host"] = host_dir

def update_ports(self, node, parsed):
def update_ports(self, node, parsed, mapping=None):
if "expose-ports" in parsed:
value = parsed["expose-ports"]
for p in value:
if mapping and p in mapping:
p = mapping[p]
p = PortPublish(str(p))
if p not in node["ports"]:
node["ports"].append(p)
opt = "{}.expose_ports".format(node["name"])
if hasattr(self.args, opt):
value = getattr(self.args, opt)
for p in value.split(","):
if mapping and p in mapping:
p = mapping[p]
p = PortPublish(p.strip())
if p not in node["ports"]:
node["ports"].append(p)
Expand Down Expand Up @@ -401,26 +406,28 @@ def update_connext(self, parsed):
node = self.nodes["connext"]
self.update_ports(node, parsed)

def update_webui(self, parsed):
"""Update webui related configurations from parsed TOML webui section
:param parsed: Parsed raiden TOML section
def update_xud(self, parsed):
"""Update xud related configurations from parsed TOML xud section
:param parsed: Parsed xud TOML section
"""
node = self.nodes.get("webui", None)
node = self.nodes["xud"]
self.update_ports(node, parsed)

opt = "webui"
def update_disabled(self, node, parsed, opt):
if "disabled" in parsed:
value = parsed["disabled"]
assert isinstance(value, bool)
node["disabled"] = value
if hasattr(self.args, opt):
value = getattr(self.args, opt)
node["disabled"] = False

def update_raiden(self, parsed):
"""Update raiden related configurations from parsed TOML raiden section
:param parsed: Parsed raiden TOML section
"""
if self.network in ["simnet", "testnet", "mainnet"]:
return
node = self.nodes["raiden"]
self.update_ports(node, parsed)
value: str = getattr(self.args, opt)
if value:
value = value.strip().lower()
if not value or value == "true" or value == "":
node["disabled"] = True
elif value == "false":
node["disabled"] = False
else:
raise ValueError("Invalid value of option \"{}\": {}".format(opt, value))

def update_arby(self, parsed):
"""Update arby related configurations from parsed TOML arby section
Expand Down Expand Up @@ -487,41 +494,28 @@ def update_arby(self, parsed):
if value:
node["margin"] = value

if "disabled" in parsed:
value = parsed["disabled"]
assert isinstance(value, bool)
node["disabled"] = value
opt = "arby.disabled"
if hasattr(self.args, opt):
value: str = getattr(self.args, opt)
if value:
value = value.strip().lower()
if not value or value == "true" or value == "":
node["disabled"] = True
elif value == "false":
node["disabled"] = False
else:
raise ValueError("Invalid value of option \"arby.disabled\": {}".format(value))

self.update_disabled(node, parsed, "arby.disabled")
self.update_ports(node, parsed)

def update_xud(self, parsed):
"""Update xud related configurations from parsed TOML xud section
:param parsed: Parsed xud TOML section
def update_boltz(self, parsed):
"""Update webui related configurations from parsed TOML boltz section
:param parsed: Parsed raiden TOML section
"""
node = self.nodes["xud"]
node = self.nodes["boltz"]
self.update_disabled(node, parsed, "boltz.disabled")
self.update_ports(node, parsed)

def update_ltcd(self, parsed):
"""Update ltcd related configurations from parsed TOML ltcd section
:param parsed: Parsed ltcd TOML section
def update_webui(self, parsed):
"""Update webui related configurations from parsed TOML webui section
:param parsed: Parsed raiden TOML section
"""
node = self.nodes["ltcd"]
self.update_ports(node, parsed)

def update_boltz(self, parsed):
node = self.nodes["boltz"]
self.update_ports(node, parsed)
node = self.nodes["webui"]
self.update_disabled(node, parsed, "webui.disabled")
self.update_ports(node, parsed, mapping={
"8888": "8888:8080",
"18888": "18888:8080",
"28888": "28888:8080",
})

def parse_network_config(self):
network = self.network
Expand Down
4 changes: 4 additions & 0 deletions images/utils/launcher/config/mainnet.conf
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,7 @@
#binance-api-secret = "your api secret"
#margin = "0.04"
#disabled = false

[webui]
#disabled = false
#expose-ports = ["8888"]
4 changes: 4 additions & 0 deletions images/utils/launcher/config/simnet.conf
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,7 @@
#binance-api-secret = "your api secret"
#margin = "0.04"
#disabled = false

[webui]
#disabled = false
#expose-ports = ["28888"]
6 changes: 3 additions & 3 deletions images/utils/launcher/config/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def __eq__(self, other):
"container": "/root/.xud",
}
],
"ports": [PortPublish("8080")],
"ports": [],
"mode": "native",
"preserve_config": False,
"use_local_image": False,
Expand Down Expand Up @@ -340,7 +340,7 @@ def __eq__(self, other):
"container": "/root/.xud",
}
],
"ports": [PortPublish("8080")],
"ports": [],
"mode": "native",
"preserve_config": False,
"use_local_image": False,
Expand Down Expand Up @@ -526,7 +526,7 @@ def __eq__(self, other):
"container": "/root/.xud",
}
],
"ports": [PortPublish("8080")],
"ports": [],
"mode": "native",
"preserve_config": False,
"use_local_image": False,
Expand Down
4 changes: 4 additions & 0 deletions images/utils/launcher/config/testnet.conf
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,7 @@

[boltz]
#disabled = false

[webui]
#disabled = false
#expose-ports = ["18888"]
2 changes: 2 additions & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ pytest-html
pytest-integration
pytest-timeout
pytest-dotenv
toml
demjson

0 comments on commit a147a4c

Please sign in to comment.