Skip to content

Commit b5083d4

Browse files
author
Dan Lavu
committed
changing nslookup for assertions and adding hostname method
1 parent 013284a commit b5083d4

1 file changed

Lines changed: 20 additions & 4 deletions

File tree

sssd_test_framework/utils/network.py

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,22 @@ def ip(self, name: str | None = None) -> IPUtils:
4040

4141
return inst
4242

43+
def hostname(self, hostname: str | None = None) -> str:
44+
"""
45+
Get or change hostname.
46+
47+
:param hostname: Hostname.
48+
:type hostname: str
49+
:return: Configured hostname.
50+
:rtype: str
51+
"""
52+
if hostname is not None:
53+
_hostname = self.host.conn.run("hostname").stdout
54+
self.__rollback.append(f"hostname {_hostname}")
55+
self.host.conn.run(f"hostname {hostname}")
56+
57+
return self.host.conn.run("hostname").stdout
58+
4359
def tcpdump(self, pcap_path: str, args: list[Any] | None = None) -> SSHKillableProcess:
4460
"""
4561
Run tcpdump. The packets are captured in ``pcap_path``.
@@ -136,17 +152,17 @@ def dig(self, address: str, server: str = "", reverse: bool = False) -> dict[str
136152

137153
return None if not records else records[0]
138154

139-
def nslookup(self, args: list[str]) -> ProcessResult:
155+
def nslookup(self, args: list[str]) -> int:
140156
"""
141157
Execute nslookup command with given arguments.
142158
143159
:param args: Arguments to ``nslookup``, defaults to None
144160
:type args: list[str]
145-
:return: SSH Process result
146-
:rtype: ProcessResult
161+
:return: Return code
162+
:rtype: int
147163
"""
148164

149-
return self.host.conn.exec(["nslookup", *args], raise_on_error=False)
165+
return self.host.conn.exec(["nslookup", *args], raise_on_error=False).rc
150166

151167
def teardown(self):
152168
"""

0 commit comments

Comments
 (0)