openc2lib.types.data.hostname

 1import fqdn
 2
 3class Hostname:
 4	""" A hostname that can be used to connect to this device over a network """
 5		
 6	def __init__(self, hostname):
 7		self.set(hostname)
 8
 9	def set(self, hostname):
10		""" Check hostname fullfils RFC 1123 requirements """
11		if fqdn.FQDN(hostname, min_labels=1).is_valid:
12			self._hostname = str(hostname)
13		else:
14			raise ValueError("Invalid hostname -- not compliant to RFC 1123")
15
16	def get(self):
17		""" Returns the hostname as string """
18		return self._hostname
19
20	def __str__(self):
21		return self._hostname
class Hostname:
 4class Hostname:
 5	""" A hostname that can be used to connect to this device over a network """
 6		
 7	def __init__(self, hostname):
 8		self.set(hostname)
 9
10	def set(self, hostname):
11		""" Check hostname fullfils RFC 1123 requirements """
12		if fqdn.FQDN(hostname, min_labels=1).is_valid:
13			self._hostname = str(hostname)
14		else:
15			raise ValueError("Invalid hostname -- not compliant to RFC 1123")
16
17	def get(self):
18		""" Returns the hostname as string """
19		return self._hostname
20
21	def __str__(self):
22		return self._hostname

A hostname that can be used to connect to this device over a network

Hostname(hostname)
7	def __init__(self, hostname):
8		self.set(hostname)
def set(self, hostname):
10	def set(self, hostname):
11		""" Check hostname fullfils RFC 1123 requirements """
12		if fqdn.FQDN(hostname, min_labels=1).is_valid:
13			self._hostname = str(hostname)
14		else:
15			raise ValueError("Invalid hostname -- not compliant to RFC 1123")

Check hostname fullfils RFC 1123 requirements

def get(self):
17	def get(self):
18		""" Returns the hostname as string """
19		return self._hostname

Returns the hostname as string