from ganeti import utils
from ganeti import constants
from ganeti import errors
+from ganeti import netutils
_DEFAULT_RUN_USER = "root"
if self.family == socket.AF_UNIX:
# override the client address, as for unix sockets nothing meaningful
# is passed in from accept anyway
- client_address = utils.GetSocketCredentials(connected_socket)
+ client_address = netutils.GetSocketCredentials(connected_socket)
logging.info("Accepted connection from %s",
FormatAddress(self.family, client_address))
self.handle_connection(connected_socket, client_address)
"""An improved asyncore udp socket.
"""
- def __init__(self):
+ def __init__(self, family):
"""Constructor for AsyncUDPSocket
"""
GanetiBaseAsyncoreDispatcher.__init__(self)
self._out_queue = []
- self.create_socket(socket.AF_INET, socket.SOCK_DGRAM)
+ self._family = family
+ self.create_socket(family, socket.SOCK_DGRAM)
# this method is overriding an asyncore.dispatcher method
def handle_connect(self):
constants.MAX_UDP_DATA_SIZE)
if recv_result is not None:
payload, address = recv_result
- ip, port = address
+ if self._family == socket.AF_INET6:
+ # we ignore 'flow info' and 'scope id' as we don't need them
+ ip, port, _, _ = address
+ else:
+ ip, port = address
+
self.handle_datagram(payload, ip, port)
def handle_datagram(self, payload, ip, port):
choices=["no", "yes", "only"])
if daemon_name in constants.DAEMONS_PORTS:
- default_bind_address = "0.0.0.0"
- default_port = utils.GetDaemonPort(daemon_name)
+ default_bind_address = constants.IP4_ADDRESS_ANY
+ default_port = netutils.GetDaemonPort(daemon_name)
# For networked daemons we allow choosing the port and bind address
optionparser.add_option("-p", "--port", dest="port",