Skip to content

Commit 3abf5fa

Browse files
committed
CP-54010: Use xapi for ssh in xsconsole
Currently, xsconsole uses systemd to manage ssh service. In the ssh configuration feature (CP-50702), ssh's status is saved in xapi DB and is updated by xapi API. So change the way of managing ssh to xapi API in xsconsole to keep the ssh's status updating. Signed-off-by: Bengang Yuan <[email protected]>
1 parent 1f9a211 commit 3abf5fa

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

XSConsoleData.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1089,6 +1089,16 @@ def LocalHostDisable(self):
10891089
self.RequireSession()
10901090
self.session.xenapi.host.disable(self.host.opaqueref())
10911091

1092+
def EnableSSH(self):
1093+
Auth.Inst().AssertAuthenticatedOrPasswordUnset()
1094+
self.RequireSession()
1095+
self.session.xenapi.host.enable_ssh(self.host.opaqueref())
1096+
1097+
def DisableSSH(self):
1098+
Auth.Inst().AssertAuthenticatedOrPasswordUnset()
1099+
self.RequireSession()
1100+
self.session.xenapi.host.disable_ssh(self.host.opaqueref())
1101+
10921102
def Ping(self, inDest):
10931103
# Must be careful that no unsanitised data is passed to the command
10941104
if not re.match(r'[0-9a-zA-Z][-0-9a-zA-Z.]*$', inDest):

plugins-base/XSFeatureRemoteShell.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,9 @@ def HandleChoice(self, inChoice):
5757
try:
5858
message = Lang("Configuration Successful")
5959
if inChoice:
60-
data.EnableService('sshd')
61-
data.StartService('sshd')
60+
data.EnableSSH()
6261
else:
63-
data.DisableService('sshd')
64-
data.StopService('sshd')
62+
data.DisableSSH()
6563

6664
if ShellPipe(['/sbin/pidof', 'sshd']).CallRC() == 0: # If PIDs are available
6765
message = Lang("New connections via the remote shell are now disabled, but there are "

0 commit comments

Comments
 (0)