def getInstance(cls, userAPIUrl=None, username=None, password=None): if cls._instance is None or (userAPIUrl is not None or username is not None or password is not None): if userAPIUrl is None: userAPIUrl = getVidyoOptionValue('userAPIURL') if username is None: username = getVidyoOptionValue('indicoUsername') if password is None: password = getVidyoOptionValue('indicoPassword') location = getVidyoOptionValue( 'baseAPILocation') + getVidyoOptionValue('userAPIService') try: cls._instance = client.Client( userAPIUrl, transport=ClientBase.getTransport(userAPIUrl, username, password), location=location, cache=ClientBase.getCache()) except Exception: Logger.get("Vidyo").exception("Problem building UserClient") raise return cls._instance
def getInformation(cls, booking, displayTz=None): sections = [] sections.append({"title": _("Room name"), "lines": [booking.getBookingParamByName("roomName")]}) sections.append({"title": _("Extension"), "lines": [booking.getExtension()]}) if booking.getHasPin(): pinSection = {} pinSection["title"] = _("Meeting PIN") if booking.getBookingParamByName("displayPin"): pinSection["lines"] = [booking.getPin()] else: pinSection["lines"] = [_("This Vidyo room is protected by a PIN")] sections.append(pinSection) sections.append({"title": _("Moderator"), "lines": [booking.getOwnerObject().getStraightFullName()]}) if booking.getBookingParamByName("displayPhoneNumbers") and getVidyoOptionValue("phoneNumbers"): sections.append( {"title": _("VidyoVoice phone numbers"), "lines": [", ".join(getVidyoOptionValue("phoneNumbers"))]} ) sections.append({"title": _("Description"), "lines": [booking.getBookingParamByName("roomDescription")]}) if booking.getBookingParamByName("displayURL"): autojoinSection = {} autojoinSection["title"] = _("Auto-join URL") autojoinSection["linkLines"] = [(booking.getURL(), booking.getURL())] sections.append(autojoinSection) return sections
def getCustomBookingXML(cls, booking, displayTz, out): if (booking.canBeStarted()): out.openTag("launchInfo") out.writeTag("launchText", _("Join Now!")) out.writeTag("launchLink", booking.getURL()) out.writeTag("launchTooltip", _('Click here to join the Vidyo room!')) out.closeTag("launchInfo") out.writeTag("firstLineInfo", booking.getBookingParamByName("roomName")) out.openTag("information") out.openTag("section") out.writeTag("title", _('Room name:')) out.writeTag("line", booking.getBookingParamByName("roomName")) out.closeTag("section") out.openTag("section") out.writeTag("title", _('Extension:')) out.writeTag("line", booking.getExtension()) out.closeTag("section") if booking.getHasPin(): out.openTag("section") out.writeTag("title", _('Meeting PIN:')) """ if booking.getBookingParamByName("displayPin"): out.writeTag("line", booking.getPin()) else: out.writeTag("line", _('This Vidyo room is protected by a PIN')) """ out.writeTag("line", _('This Vidyo room is protected by a PIN')) out.closeTag("section") out.openTag("section") out.writeTag("title", _('Owner:')) out.writeTag("line", booking.getOwnerObject().getFullName()) out.closeTag("section") if booking.getBookingParamByName("displayURL"): out.openTag("section") out.writeTag("title", _('Auto-join URL:')) out.openTag("linkLine") out.writeTag("href", booking.getURL()) out.writeTag("caption", booking.getURL()) out.closeTag("linkLine") out.closeTag("section") if booking.getBookingParamByName("displayPhoneNumbers") and getVidyoOptionValue("phoneNumbers"): out.openTag("section") out.writeTag("title", _('VidyoVoice phone numbers:')) out.writeTag("line", ', '.join(getVidyoOptionValue("phoneNumbers"))) out.closeTag("section") out.openTag("section") out.writeTag("title", _('Description:')) out.writeTag("line", booking.getBookingParamByName("roomDescription")) out.closeTag("section") out.closeTag("information")
def createRoom(cls, name, description, ownerName, extension, pin, moderatorPin): """ Creates a SOAP room object """ vidyoClient = AdminClient.getInstance() newRoom = vidyoClient.factory.create('Room') newRoom.name = name newRoom.RoomType = 'Public' newRoom.ownerName = ownerName newRoom.extension = extension newRoom.groupName = getVidyoOptionValue("indicoGroup") newRoom.description = description newRoom.RoomMode.isLocked = False if pin: newRoom.RoomMode.hasPIN = True newRoom.RoomMode.roomPIN = pin else: newRoom.RoomMode.hasPIN = False if moderatorPin: newRoom.RoomMode.hasModeratorPIN = True newRoom.RoomMode.moderatorPIN = moderatorPin else: newRoom.RoomMode.hasModeratorPIN = False return newRoom
def getVars(self): variables = WCSPageTemplateBase.getVars(self) variables["Booking"] = self._booking variables["PhoneNumbers"] = getVidyoOptionValue("phoneNumbers") return variables
def _connect(self, force=False): self._checkStatus() connectionStatus = self.connectionStatus() if isinstance(connectionStatus, VidyoError): return connectionStatus confRoomIp = VidyoTools.getLinkRoomIp(self.getLinkObject()) if confRoomIp == "": return VidyoError("noValidConferenceRoom", "connect") if connectionStatus.get("isConnected") == True: if connectionStatus.get("roomName") == self.getBookingParamByName( "roomName"): return VidyoError( "alreadyConnected", "connect", _("It seems that the room has been already connected to the room, please refresh the page." )) if not force: # if connect is not forced, give up return VidyoError( "alreadyConnected", "connect", _("The room is already connected to some other endpoint. Please refresh the page." )) else: # otherwise, replace whatever call is going on ExternalOperationsManager.execute( self, "disconnectRoom", VidyoOperations.disconnectRoom, self, confRoomIp, connectionStatus.get("service")) retry = 15 connected = True # wait for the current call to be disconnected while retry: connectionStatus = self.connectionStatus() time.sleep(2) retry -= 1 if connectionStatus.get("isConnected") == False: connected = False break if connected: return VidyoError( "couldntStop", "connect", _("It seems like we haven't managed to stop " "the current call. Please refresh the page and try again." )) else: # give it some time before trying to connect time.sleep(5) prefixConnect = getVidyoOptionValue("prefixConnect") result = ExternalOperationsManager.execute(self, "connectRoom", VidyoOperations.connectRoom, self, self._roomId, prefixConnect + confRoomIp) if isinstance(result, VidyoError): return result return self
def getInformation(cls, booking, displayTz=None): sections = [] sections.append({ "title": _('Room name'), 'lines': [booking.getBookingParamByName("roomName")], }) sections.append({ "title": _('Extension'), 'lines': [booking.getExtension()], }) if booking.getHasPin(): pinSection = {} pinSection['title'] = _('Meeting PIN') if booking.getBookingParamByName("displayPin"): pinSection['lines'] = [booking.getPin()] else: pinSection['lines'] = [ _('This Vidyo room is protected by a PIN') ] sections.append(pinSection) sections.append({ "title": _('Moderator'), 'lines': [booking.getOwnerObject().getStraightFullName()], }) if booking.getBookingParamByName( "displayPhoneNumbers") and getVidyoOptionValue("phoneNumbers"): sections.append({ "title": _('VidyoVoice phone numbers'), 'lines': [', '.join(getVidyoOptionValue("phoneNumbers"))], }) sections.append({ "title": _('Description'), 'lines': [booking.getBookingParamByName("roomDescription")], }) if booking.getBookingParamByName("displayURL"): autojoinSection = {} autojoinSection['title'] = _('Auto-join URL') autojoinSection['linkLines'] = [(booking.getURL(), booking.getURL())] sections.append(autojoinSection) return sections
def getInstance(cls, userAPIUrl = None, username = None, password = None): if cls._instance is None or (userAPIUrl is not None or username is not None or password is not None): if userAPIUrl is None: userAPIUrl = getVidyoOptionValue('userAPIURL') if username is None: username = getVidyoOptionValue('indicoUsername') if password is None: password = getVidyoOptionValue('indicoPassword') try: cls._instance = suds.client.Client(userAPIUrl, transport = ClientBase.getTransport(userAPIUrl, username , password)) except Exception: Logger.get("Vidyo").exception("Problem building UserClient") raise return cls._instance
def getInformation(cls, booking, displayTz=None): sections = [] sections.append({ "title": _('Room name'), 'lines': [booking.getBookingParamByName("roomName")], }) sections.append({ "title": _('Extension'), 'lines': [booking.getExtension()], }) if booking.getHasPin(): pinSection = {} pinSection['title'] = _('Meeting PIN') """ if booking.getBookingParamByName("displayPin"): pinSection['lines'] = [booking.getPin()] else: pinSection['lines'] = [_('This Vidyo room is protected by a PIN')] """ pinSection['lines'] = [_('This Vidyo room is protected by a PIN')] sections.append(pinSection) sections.append({ "title": _('Moderator'), 'lines': [booking.getOwnerObject().getStraightFullName()], }) if booking.getBookingParamByName("displayPhoneNumbers") and getVidyoOptionValue("phoneNumbers"): sections.append({ "title": _('VidyoVoice phone numbers'), 'lines': [', '.join(getVidyoOptionValue("phoneNumbers"))], }) sections.append({ "title": _('Description'), 'lines': [booking.getBookingParamByName("roomDescription")], }) if booking.getBookingParamByName("displayURL"): autojoinSection = {} autojoinSection['title'] = _('Auto-join URL') autojoinSection['linkLines'] = [(booking.getURL(), booking.getURL())] sections.append(autojoinSection) return sections
def _connect(self): self._checkStatus() if self.canBeConnected(): confRoomIp = VidyoTools.getLinkRoomIp(self.getLinkObject()) if confRoomIp == "": return VidyoError("noValidConferenceRoom", "connect") prefixConnect = getVidyoOptionValue("prefixConnect") result = ExternalOperationsManager.execute(self, "connectRoom", VidyoOperations.connectRoom, self, self._roomId, prefixConnect + confRoomIp) if isinstance(result, VidyoError): return result return self
def connectRoom(cls, booking, roomId, extension): confId = booking.getConference().getId() bookingId = booking.getId() try: searchFilter = SOAPObjectFactory.createFilter('user', extension) userApiAnswer = UserApi.search(searchFilter, confId, bookingId) legacyMember = userApiAnswer.Entity[0].entityID AdminApi.connectRoom(roomId, confId, bookingId, legacyMember) except WebFault, e: faultString = e.fault.faultstring if faultString.startswith('ConferenceID is invalid'): return VidyoError("unknownRoom", "connect") if faultString.startswith('Failed to Invite to Conference'): message = _("The connection has failed.") if getVidyoOptionValue("contactSupport"): message += _("""\nPlease try again or contact %s for help.""")%getVidyoOptionValue("contactSupport") return VidyoError("connectFailed", "connect", message) else: Logger.get('Vidyo').exception("""Evt:%s, booking:%s, Admin API's connectRoom operation got WebFault: %s""" % (confId, bookingId, e.fault.faultstring)) raise
def getInstance(cls, adminAPIUrl = None, username = None, password = None): if cls._instance is None or (adminAPIUrl is not None or username is not None or password is not None): if adminAPIUrl is None: adminAPIUrl = getVidyoOptionValue('adminAPIURL') if username is None: username = getVidyoOptionValue('indicoUsername') if password is None: password = getVidyoOptionValue('indicoPassword') location = getVidyoOptionValue('baseAPILocation') + getVidyoOptionValue('adminAPIService') try: cls._instance = suds.client.Client(adminAPIUrl, transport = ClientBase.getTransport(adminAPIUrl, username , password), location = location) except Exception: Logger.get("Vidyo").exception("Problem building AdminClient") raise return cls._instance
def _connect(self, force=False): self._checkStatus() connectionStatus = self.connectionStatus() if isinstance(connectionStatus, VidyoError): return connectionStatus confRoomIp = VidyoTools.getLinkRoomAttribute(self.getLinkObject(), attName="H323 IP") confRoomPanoramaUser = VidyoTools.getLinkRoomAttribute(self.getLinkObject(), attName="VidyoPanorama ID") if confRoomIp == "" and confRoomPanoramaUser == "": return VidyoError("noValidConferenceRoom", "connect") if connectionStatus.get("isConnected") == True: if connectionStatus.get("roomName") == self.getBookingParamByName("roomName"): return VidyoError("alreadyConnected", "connect", _("It seems that the room has been already connected to the room, please refresh the page.")) if not force: # if connect is not forced, give up return VidyoError("alreadyConnected", "connect", _("The room is already connected to some other endpoint. Please refresh the page.")) else: # otherwise, replace whatever call is going on ExternalOperationsManager.execute( self, "disconnectRoom", VidyoOperations.disconnectRoom, self, connectionStatus, confRoomIp, confRoomPanoramaUser) retry = 15 connected = True # wait for the current call to be disconnected while retry: connectionStatus = self.connectionStatus() time.sleep(2) retry -= 1 if connectionStatus.get("isConnected") == False: connected = False break if connected: return VidyoError("couldntStop", "connect", _("It seems like we haven't managed to stop " "the current call. Please refresh the page and try again.")) else: # give it some time before trying to connect time.sleep(5) query = (getVidyoOptionValue("prefixConnect") + confRoomIp) if confRoomIp else confRoomPanoramaUser result = ExternalOperationsManager.execute(self, "connectRoom", VidyoOperations.connectRoom, self, self._roomId, query) if isinstance(result, VidyoError): return result return self
def call(self): """ We try to clear the persistent, file-based cache. In Linux it's located in /tmp/suds """ cacheLocation = getVidyoOptionValue("sudsCacheLocation").strip() if cacheLocation: import os.path if os.path.isdir(cacheLocation): import shutil shutil.rmtree(cacheLocation) return _("The cache directory: ") + cacheLocation + _(" has been deleted") else: return _("The cache location supplied: ") + cacheLocation + _(" does not exist or is not a directory") else: return _("No cache location was defined. Nothing to clean")
def call(self): """ We try to clear the persistent, file-based cache. In Linux it's located in /tmp/suds """ cacheLocation = getVidyoOptionValue("sudsCacheLocation").strip() if cacheLocation: import os.path if os.path.isdir(cacheLocation): import shutil shutil.rmtree(cacheLocation) return _("The cache directory: ") + cacheLocation + _( " has been deleted") else: return _("The cache location supplied: ") + cacheLocation + _( " does not exist or is not a directory") else: return _("No cache location was defined. Nothing to clean")
def __init__(self, booking): VidyoAdminNotificationBase.__init__(self, booking) currentCount = VidyoTools.getEventEndDateIndex().getCount() self.setSubject("""[Vidyo] Too many public rooms (%s)""" % str(currentCount)) self.setBody("""Dear Vidyo Manager,<br /> <br /> There are currently %s Vidyo public rooms created by Indico in <a href="%s">%s</a>.<br /> The system was setup to send you a notification if this number was more than %s.<br /> Please go to the <a href="%s">Vidyo Plugin configuration</a> in the Server Admin interface and press the "Clean old rooms" button.<br /> """ % (str(currentCount), MailTools.getServerName(), MailTools.getServerName(), getVidyoOptionValue("cleanWarningAmount"), str( urlHandlers.UHAdminPlugins.getURL( CollaborationTools.getCollaborationPluginType()))))
def __init__(self, booking): VidyoAdminNotificationBase.__init__(self, booking) currentCount = VidyoTools.getEventEndDateIndex().getCount() self.setSubject("""[Vidyo] Too many public rooms (%s)""" % str(currentCount)) self.setBody("""Dear Vidyo Manager,<br /> <br /> There are currently %s Vidyo public rooms created by Indico in <a href="%s">%s</a>.<br /> The system was setup to send you a notification if this number was more than %s.<br /> Please go to the <a href="%s">Vidyo Plugin configuration</a> in the Server Admin interface and press the "Clean old rooms" button.<br /> """ % (str(currentCount), MailTools.getServerName(), MailTools.getServerName(), getVidyoOptionValue("cleanWarningAmount"), str(urlHandlers.UHAdminPlugins.getURL(CollaborationTools.getCollaborationPluginType()))))
def createRoom(cls, booking): """ Attempts to create a public room in Vidyo. Returns None on success. Will also set booking.setAccountName() if success, with the Indico & Vidyo login used successfully. Returns a VidyoError instance if there are problems. :param booking: the CSBooking object inside which we try to create the room :type booking: MaKaC.plugins.Collaboration.Vidyo.collaboration.CSBooking """ # we extract the different parameters # We set the original conference id because the bookings can belong to more than one conference and being cloned # and it is used for the long name, we need to keep always the same confId confId = booking.getConference().getId() bookingId = booking.getId() roomName = booking.getBookingParamByName("roomName") description = booking.getBookingParamByName("roomDescription") owner = booking.getOwnerObject() pin = booking.getPin() moderatorPin = booking.getModeratorPin() #we obtain the unicode object with the proper format for the room name roomNameForVidyo = VidyoTools.roomNameForVidyo(roomName) if isinstance(roomNameForVidyo, VidyoError): return roomNameForVidyo #we turn the description into a unicode object description = VidyoTools.descriptionForVidyo(description) if isinstance(description, VidyoError): return description #we obtain the most probable extension #TODO: there's a length limit for extensions, check this baseExtension = getVidyoOptionValue("prefix") + confId extension = baseExtension extensionSuffix = 1 #we produce the list of possible account names. We will loop through them to attempt to create the room possibleLogins = VidyoTools.getAvatarLoginList(owner) if not possibleLogins: return VidyoError("userHasNoAccounts", "create") # We check the moderator PIN is a 3-10 digit number if moderatorPin and (not moderatorPin.isdigit() or len(moderatorPin) < 3 or len(moderatorPin) > 10): return VidyoError("PINLength", "create") roomCreated = False loginToUse = 0 while not roomCreated and loginToUse < len(possibleLogins): #we loop changing the ownerName and the extension until room is created newRoom = SOAPObjectFactory.createRoom(roomNameForVidyo, description, possibleLogins[loginToUse], extension, pin, moderatorPin) try: AdminApi.addRoom(newRoom) roomCreated = True except WebFault, e: faultString = e.fault.faultstring if faultString.startswith('Room exist for name'): if VidyoOperations.roomWithSameOwner(possibleLogins[loginToUse], roomNameForVidyo): return VidyoError("duplicatedWithOwner", "create") else: return VidyoError("duplicated", "create") elif faultString.startswith('Member not found for ownerName'): loginToUse = loginToUse + 1 elif faultString.startswith('PIN should be a 3-10 digit number'): return VidyoError("PINLength", "create") elif faultString.startswith('Room exist for extension'): extension = baseExtension + str(extensionSuffix) extensionSuffix = extensionSuffix + 1 else: Logger.get('Vidyo').exception("""Evt:%s, booking:%s, Admin API's addRoom operation got WebFault: %s""" % (confId, bookingId, e.fault.faultstring)) raise
def createRoom(cls, booking): """ Attempts to create a public room in Vidyo. Returns None on success. Will also set booking.setAccountName() if success, with the Indico & Vidyo login used successfully. Returns a VidyoError instance if there are problems. :param booking: the CSBooking object inside which we try to create the room :type booking: MaKaC.plugins.Collaboration.Vidyo.collaboration.CSBooking """ # we extract the different parameters # We set the original conference id because the bookings can belong to more than one conference and being cloned # and it is used for the long name, we need to keep always the same confId confId = booking.getConference().getId() bookingId = booking.getId() roomName = booking.getBookingParamByName("roomName") description = booking.getBookingParamByName("roomDescription") owner = booking.getOwnerObject() pin = booking.getPin() moderatorPin = booking.getModeratorPin() #we obtain the unicode object with the proper format for the room name roomNameForVidyo = VidyoTools.roomNameForVidyo(roomName) if isinstance(roomNameForVidyo, VidyoError): return roomNameForVidyo #we turn the description into a unicode object description = VidyoTools.descriptionForVidyo(description) if isinstance(description, VidyoError): return description #we obtain the most probable extension #TODO: there's a length limit for extensions, check this baseExtension = getVidyoOptionValue("prefix") + confId extension = baseExtension extensionSuffix = 1 #we produce the list of possible account names. We will loop through them to attempt to create the room possibleLogins = VidyoTools.getAvatarLoginList(owner) if not possibleLogins: return VidyoError("userHasNoAccounts", "create") # We check the moderator PIN is a 3-10 digit number if moderatorPin and (not moderatorPin.isdigit() or len(moderatorPin) < 3 or len(moderatorPin) > 10): return VidyoError("PINLength", "create") roomCreated = False loginToUse = 0 while not roomCreated and loginToUse < len(possibleLogins): #we loop changing the ownerName and the extension until room is created newRoom = SOAPObjectFactory.createRoom(roomNameForVidyo, description, possibleLogins[loginToUse], extension, pin, moderatorPin) try: AdminApi.addRoom(newRoom) roomCreated = True except WebFault, e: faultString = e.fault.faultstring if faultString.startswith('Room exist for name'): if VidyoOperations.roomWithSameOwner( possibleLogins[loginToUse], roomNameForVidyo): return VidyoError("duplicatedWithOwner", "create") else: return VidyoError("duplicated", "create") elif faultString.startswith('Member not found for ownerName'): loginToUse = loginToUse + 1 elif faultString.startswith( 'PIN should be a 3-10 digit number'): return VidyoError("PINLength", "create") elif faultString.startswith('Room exist for extension'): extension = baseExtension + str(extensionSuffix) extensionSuffix = extensionSuffix + 1 else: Logger.get('Vidyo').exception( """Evt:%s, booking:%s, Admin API's addRoom operation got WebFault: %s""" % (confId, bookingId, e.fault.faultstring)) raise
def getCustomBookingXML(cls, booking, displayTz, out): if (booking.canBeStarted()): out.openTag("launchInfo") out.writeTag("launchText", _("Join Now!")) out.writeTag("launchLink", booking.getURL()) out.writeTag("launchTooltip", _('Click here to join the Vidyo room!')) out.closeTag("launchInfo") out.writeTag("firstLineInfo", booking.getBookingParamByName("roomName")) out.openTag("information") out.openTag("section") out.writeTag("title", _('Room name:')) out.writeTag("line", booking.getBookingParamByName("roomName")) out.closeTag("section") out.openTag("section") out.writeTag("title", _('Extension:')) out.writeTag("line", booking.getExtension()) out.closeTag("section") if booking.getHasPin(): out.openTag("section") out.writeTag("title", _('Meeting PIN:')) if booking.getBookingParamByName("displayPin"): out.writeTag("line", booking.getPin()) else: out.writeTag("line", _('This Vidyo room is protected by a PIN')) out.closeTag("section") out.openTag("section") out.writeTag("title", _('Owner:')) out.writeTag("line", booking.getOwnerObject().getFullName()) out.closeTag("section") if booking.getBookingParamByName("displayURL"): out.openTag("section") out.writeTag("title", _('Auto-join URL:')) out.openTag("linkLine") out.writeTag("href", booking.getURL()) out.writeTag("caption", booking.getURL()) out.closeTag("linkLine") out.closeTag("section") if booking.getBookingParamByName( "displayPhoneNumbers") and getVidyoOptionValue("phoneNumbers"): out.openTag("section") out.writeTag("title", _('VidyoVoice phone numbers:')) out.writeTag("line", ', '.join(getVidyoOptionValue("phoneNumbers"))) out.closeTag("section") out.openTag("section") out.writeTag("title", _('Description:')) out.writeTag("line", booking.getBookingParamByName("roomDescription")) out.closeTag("section") out.closeTag("information")