def _handle_open_msg(self, conn, vns_msg): # client wants to connect to some topology. log.debug("open-msg: %s, %s" % (vns_msg.topo_id, vns_msg.vhost)) try: conn.send(VNSHardwareInfo(self.interfaces)) except: log.debug('interfaces not populated yet') return
def handle_open_msg(self, conn, vns_msg): dev = self.devsByName[vns_msg.vhost] if (dev is None): log.debug('interfaces for %s not populated yet' % (vns_msg.vhost)) return self.devsByConn[conn] = dev dev.conn = conn conn.send(VNSHardwareInfo(dev.interfaces)) return
def _handle_open_msg(self, conn, vns_msg): # client wants to connect to some topology. log.debug("open-msg: %s, vhost:%s" % (vns_msg.topo_id, vns_msg.vhost)) self.srclients['%s' % vns_msg.vhost] = conn self.srclients_reverse[conn] = '%s' % vns_msg.vhost try: conn.send(VNSHardwareInfo(self.interfaces['%s' % vns_msg.vhost])) except: log.debug('interfaces not populated yet') return
def connect_client(self, client_conn, client_user, requested_name): """Called when a user tries to connect to a node in this topology. Returns True if the requested node exists and the client was able to connect to it. Otherwise it returns an error message.""" if self.permitted_clients is not None: # otherwise anyone can use it if client_user not in self.permitted_clients: return ConnectionReturn('%s is not authorized to use this topology' % client_user) for n in self.nodes: if n.name == requested_name: self.clients[client_conn] = n ret = n.connect(client_conn) if ret.is_success(): client_conn.send(VNSHardwareInfo(n.interfaces)) fmt = 'client (%s) has connected to node %s on topology %d' logging.info(fmt % (client_conn, n, self.id)) return ret return ConnectionReturn('there is no node named %s' % requested_name)