Revision f3044516 lib/netutils.py

b/lib/netutils.py
98 98
    @param name: hostname or None
99 99

  
100 100
    """
101
    if name is None:
102
      name = self.GetSysName()
103

  
104
    self.name = self.GetNormalizedName(name)
101
    self.name = self.GetNormalizedName(self.GetFqdn(name))
105 102
    self.ip = self.GetIP(self.name, family=family)
106 103

  
104
  @classmethod
105
  def GetSysName(cls):
106
    """Legacy method the get the current system's name.
107

  
108
    """
109
    return cls.GetFqdn()
110

  
107 111
  @staticmethod
108
  def GetSysName():
109
    """Return the current system's name.
112
  def GetFqdn(hostname=None):
113
    """Return fqdn.
110 114

  
111
    This is simply a wrapper over C{socket.gethostname()}.
115
    If hostname is None the system's fqdn is returned.
116

  
117
    @type hostname: str
118
    @param hostname: name to be fqdn'ed
119
    @rtype: str
120
    @return: fqdn of given name, if it exists, unmodified name otherwise
112 121

  
113 122
    """
114
    return socket.gethostname()
123
    if hostname is None:
124
      return socket.getfqdn()
125
    else:
126
      return socket.getfqdn(hostname)
115 127

  
116 128
  @staticmethod
117 129
  def GetIP(hostname, family=None):

Also available in: Unified diff