summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--interface-definitions/container.xml.in12
-rw-r--r--op-mode-definitions/container.xml.in8
-rwxr-xr-xsrc/validators/port-range40
3 files changed, 50 insertions, 10 deletions
diff --git a/interface-definitions/container.xml.in b/interface-definitions/container.xml.in
index b61664125..1c971b58a 100644
--- a/interface-definitions/container.xml.in
+++ b/interface-definitions/container.xml.in
@@ -111,7 +111,7 @@
</leafNode>
<leafNode name="memory">
<properties>
- <help>Memory (RAM) available to this container</help>
+ <help>Memory (RAM) available to this container (default: 512)</help>
<valueHelp>
<format>u32:0</format>
<description>Unlimited</description>
@@ -129,7 +129,7 @@
</leafNode>
<leafNode name="shared-memory">
<properties>
- <help>Shared memory available to this container</help>
+ <help>Shared memory available to this container (default: 64)</help>
<valueHelp>
<format>u32:0</format>
<description>Unlimited</description>
@@ -207,7 +207,7 @@
</leafNode>
<leafNode name="protocol">
<properties>
- <help>Transport protocol used for port mapping</help>
+ <help>Transport protocol used for port mapping (default: tcp)</help>
<completionHelp>
<list>tcp udp</list>
</completionHelp>
@@ -229,7 +229,7 @@
</tagNode>
<leafNode name="restart">
<properties>
- <help>Restart options for container</help>
+ <help>Restart options for container (default: on-failure)</help>
<completionHelp>
<list>no on-failure always</list>
</completionHelp>
@@ -276,7 +276,7 @@
</leafNode>
<leafNode name="mode">
<properties>
- <help>Volume access mode ro/rw</help>
+ <help>Volume access mode ro/rw (default: rw)</help>
<completionHelp>
<list>ro rw</list>
</completionHelp>
@@ -334,7 +334,7 @@
</tagNode>
<leafNode name="registry">
<properties>
- <help>Registry Name</help>
+ <help>Registry Name (default: docker.io, quay.io)</help>
<multi/>
</properties>
<defaultValue>docker.io quay.io</defaultValue>
diff --git a/op-mode-definitions/container.xml.in b/op-mode-definitions/container.xml.in
index 786bd66d3..78b3b7335 100644
--- a/op-mode-definitions/container.xml.in
+++ b/op-mode-definitions/container.xml.in
@@ -100,13 +100,13 @@
<properties>
<help>Show containers</help>
</properties>
- <command>sudo ${vyos_op_scripts_dir}/container.py show_container</command>
+ <command>sudo podman ps --all</command>
<children>
<leafNode name="image">
<properties>
<help>Show container image</help>
</properties>
- <command>sudo ${vyos_op_scripts_dir}/container.py show_image</command>
+ <command>sudo podman image ls</command>
</leafNode>
<tagNode name="log">
<properties>
@@ -121,7 +121,7 @@
<properties>
<help>Show available container networks</help>
</properties>
- <command>sudo ${vyos_op_scripts_dir}/container.py show_network</command>
+ <command>sudo podman network ls</command>
</leafNode>
</children>
</node>
@@ -149,7 +149,7 @@
<path>container name</path>
</completionHelp>
</properties>
- <command>sudo ${vyos_op_scripts_dir}/container.py restart --name="$3"</command>
+ <command>sudo podman restart "$3"</command>
</tagNode>
</children>
</node>
diff --git a/src/validators/port-range b/src/validators/port-range
new file mode 100755
index 000000000..5468000a7
--- /dev/null
+++ b/src/validators/port-range
@@ -0,0 +1,40 @@
+#!/usr/bin/python3
+
+import sys
+import re
+
+from vyos.util import read_file
+
+services_file = '/etc/services'
+
+def get_services():
+ names = []
+ service_data = read_file(services_file, "")
+ for line in service_data.split("\n"):
+ if not line or line[0] == '#':
+ continue
+ names.append(line.split(None, 1)[0])
+ return names
+
+def error(port_range):
+ print(f'Error: {port_range} is not a valid port or port range')
+ sys.exit(1)
+
+if __name__ == '__main__':
+ if len(sys.argv)>1:
+ port_range = sys.argv[1]
+ if re.match('^[0-9]{1,5}-[0-9]{1,5}$', port_range):
+ port_1, port_2 = port_range.split('-')
+ if int(port_1) not in range(1, 65536) or int(port_2) not in range(1, 65536):
+ error(port_range)
+ if int(port_1) > int(port_2):
+ error(port_range)
+ elif port_range.isnumeric() and int(port_range) not in range(1, 65536):
+ error(port_range)
+ elif not port_range.isnumeric() and port_range not in get_services():
+ print(f'Error: {port_range} is not a valid service name')
+ sys.exit(1)
+ else:
+ sys.exit(2)
+
+ sys.exit(0)