Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker enhancement to grant the user the ability to modify the contai… #3150

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion gns3/modules/docker/docker_vm.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ def __init__(self, module, server, project):
"console_http_port": DOCKER_CONTAINER_SETTINGS["console_http_port"],
"console_http_path": DOCKER_CONTAINER_SETTINGS["console_http_path"],
"extra_hosts": DOCKER_CONTAINER_SETTINGS["extra_hosts"],
"extra_volumes": DOCKER_CONTAINER_SETTINGS["extra_volumes"]}
"extra_volumes": DOCKER_CONTAINER_SETTINGS["extra_volumes"],
"extra_parameters": DOCKER_CONTAINER_SETTINGS["extra_parameters"]}

self.settings().update(docker_vm_settings)

Expand Down
2 changes: 2 additions & 0 deletions gns3/modules/docker/pages/docker_vm_configuration_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ def loadSettings(self, settings, node=None, group=False):
self.uiHttpConsolePathLineEdit.setText(settings["console_http_path"])
self.uiExtraHostsTextEdit.setPlainText(settings["extra_hosts"])
self.uiExtraVolumeTextEdit.setPlainText("\n".join(settings["extra_volumes"]))
self.uiExtraParametersTextEdit.setPlainText(settings["extra_parameters"])

if not group:
self.uiNameLineEdit.setText(settings["name"])
Expand Down Expand Up @@ -178,6 +179,7 @@ def saveSettings(self, settings, node=None, group=False):
settings["extra_hosts"] = self.uiExtraHostsTextEdit.toPlainText()
# only tidy input here, validation is performed server side
settings["extra_volumes"] = [ y for x in self.uiExtraVolumeTextEdit.toPlainText().split("\n") for y in [ x.strip() ] if y ]
settings["extra_parameters"] = self.uiExtraParametersTextEdit.toPlainText()

if not group:
adapters = self.uiAdapterSpinBox.value()
Expand Down
3 changes: 3 additions & 0 deletions gns3/modules/docker/pages/docker_vm_preferences_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ def _refreshInfo(self, docker_container):

if docker_container["extra_volumes"]:
QtWidgets.QTreeWidgetItem(section_item, ["Extra volumes:", "\n".join(docker_container["extra_volumes"])])

if docker_container["extra_parameters"]:
QtWidgets.QTreeWidgetItem(section_item, ["Extra parameters:", str(docker_container["extra_parameters"])])

self.uiDockerVMInfoTreeWidget.expandAll()
self.uiDockerVMInfoTreeWidget.resizeColumnToContents(0)
Expand Down
1 change: 1 addition & 0 deletions gns3/modules/docker/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,6 @@
"console_http_path": "/",
"extra_hosts": "",
"extra_volumes": [],
"extra_parameters": "",
"node_type": "docker"
}
53 changes: 44 additions & 9 deletions gns3/modules/docker/ui/docker_vm_configuration_page.ui
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<item>
<widget class="QTabWidget" name="uiTabWidget">
<property name="currentIndex">
<number>0</number>
<number>1</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
Expand Down Expand Up @@ -324,18 +324,53 @@ directory per line.</string>
</property>
</widget>
</item>
<item row="2" column="1">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<item row="2" column="0">
<widget class="QLabel" name="uiExtraParametersLabel">
<property name="minimumSize">
<size>
<width>20</width>
<width>10</width>
<height>388</height>
</size>
</property>
</spacer>
<property name="text">
<string>Modify parameters to
create the container
using the JSON format of
the Docker API, use only
if you have a specific
requirement e.g. systemd.</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QPlainTextEdit" name="uiExtraParametersTextEdit">
<property name="plainText">
<string/>
</property>
<property name="placeholderText">
<string>e.g. systemd
{
&quot;StopSignal&quot;: &quot;SIGRTMIN+3&quot;,
&quot;HostConfig&quot;: {
&quot;CapAdd&quot;: [&quot;ALL&quot;],
&quot;Runtime&quot;: &quot;runc&quot;,
&quot;Privileged&quot;: true,
&quot;Binds&quot;: [
&quot;/sys/fs/cgroup:/sys/fs/cgroup:ro&quot;,
&quot;/sys/fs/fuse:/sys/fs/fuse&quot;
],
&quot;Tmpfs&quot;: {
&quot;/tmp&quot;: &quot;&quot;,
&quot;/run&quot;: &quot;&quot;,
&quot;/run/lock&quot;: &quot;&quot;
}
}
}</string>
</property>
</widget>
</item>
</layout>
</widget>
Expand Down
36 changes: 34 additions & 2 deletions gns3/modules/docker/ui/docker_vm_configuration_page_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,16 @@ def setupUi(self, dockerVMConfigPageWidget):
self.uiExtraVolumeTextEdit.setPlainText("")
self.uiExtraVolumeTextEdit.setObjectName("uiExtraVolumeTextEdit")
self.gridLayout_2.addWidget(self.uiExtraVolumeTextEdit, 1, 1, 1, 1)
spacerItem = QtWidgets.QSpacerItem(20, 388, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
self.gridLayout_2.addItem(spacerItem, 2, 1, 1, 1)

self.uiExtraParametersLabel = QtWidgets.QLabel(self.tab_2)
self.uiExtraParametersLabel.setObjectName("uiExtraParametersLabel")
self.uiExtraParametersLabel.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignLeading | QtCore.Qt.AlignTop)
self.gridLayout_2.addWidget(self.uiExtraParametersLabel, 2, 0, 1, 1)

self.uiExtraParametersTextEdit = QtWidgets.QPlainTextEdit(self.tab_2)
self.uiExtraParametersTextEdit.setPlainText("")
self.uiExtraParametersTextEdit.setObjectName("uiExtraParametersTextEdit")
self.gridLayout_2.addWidget(self.uiExtraParametersTextEdit, 2, 1, 1, 1)
self.uiTabWidget.addTab(self.tab_2, "")
self.tab_3 = QtWidgets.QWidget()
self.tab_3.setObjectName("tab_3")
Expand Down Expand Up @@ -215,6 +223,30 @@ def retranslateUi(self, dockerVMConfigPageWidget):
"VOLUMES config. One\n"
"directory per line."))
self.uiExtraVolumeTextEdit.setPlaceholderText(_translate("dockerVMConfigPageWidget", "e.g. /etc/sysctl.d"))
self.uiExtraParametersLabel.setText(_translate("dockerVMConfigPageWidget", "Modify parameters to\n"
"create the container\n"
"using the JSON format of\n"
"the Docker API, use only\n"
"if you have a specific\n"
"requirement"))
self.uiExtraParametersTextEdit.setPlaceholderText(_translate("dockerVMConfigPageWidget", """e.g. systemd
{
"StopSignal": "SIGRTMIN+3",
"HostConfig": {
"CapAdd": ["ALL"],
"Runtime": "runc",
"Privileged": true,
"Binds": [
"/sys/fs/cgroup:/sys/fs/cgroup:ro",
"/sys/fs/fuse:/sys/fs/fuse"
],
"Tmpfs": {
"/tmp": "",
"/run": "",
"/run/lock": ""
}
}
}"""))
self.uiTabWidget.setTabText(self.uiTabWidget.indexOf(self.tab_2), _translate("dockerVMConfigPageWidget", "Advanced"))
self.uiTabWidget.setTabText(self.uiTabWidget.indexOf(self.tab_3), _translate("dockerVMConfigPageWidget", "Usage"))