Exemplo n.º 1
0
    def getVars(self):
        vars = WJSBase.getVars( self )

        roomsWithH323IP = []

        if self._conf:

            vars["ConferenceId"] = self._conf.getId()

            # Code to get a list of H.323 Videoconference-able rooms
            # by querying Indico's RB database
            location = self._conf.getLocation()

            if location and location.getName():
                locationName = location.getName()

                # TODO: get list of room from a plugin option instead of querying the RB DB everytime
                try:
                    minfo = info.HelperMaKaCInfo.getMaKaCInfoInstance()
                    if minfo.getRoomBookingModuleActive():
                        Logger.get("CERNMCU").info("Connecting with Room Booking DB to get the list of all rooms with a H323 IP")
                        CrossLocationDB.connect()
                        Logger.get("CERNMCU").info("Connection successful")

                        attName = getCERNMCUOptionValueByName("H323_IP_att_name")

                        try:
                            returnedRooms = CrossLocationQueries.getRooms( location = locationName,
                                                                           customAtts = [{"name":attName, "allowEmpty":False,
                                                                                          "filter": (lambda ip: validIP(ip))}] )
                            if not isinstance(returnedRooms, list):
                                if returnedRooms:
                                    returnedRooms = [returnedRooms]
                                else:
                                    returnedRooms = []

                            for room in returnedRooms:
                                roomsWithH323IP.append(RoomWithH323(locationName, room.getFullName(), room.customAtts[attName]))

                        except AttributeError:
                            #CrossLocationQueries.getRooms fails because it does not handle location names that are not in the DB
                            pass
                        except Exception, e:
                            Logger.get("CERNMCU").warning("Location: " + locationName + "Problem with CrossLocationQueries when retrieving the list of all rooms with a H323 IP: " + str(e))

                except MaKaCError, e:
                    Logger.get("CERNMCU").warning("Location: " + locationName + "MaKaCError when retrieving the list of all rooms with a H323 IP: " + e.getMsg())
                except Exception, e:
                    Logger.get("CERNMCU").warning("Location: " + locationName + "Exception when retrieving the list of all rooms with a H323 IP: " + str(e))
Exemplo n.º 2
0
 def getLinkRoomIp(cls, linkVideo):
     if linkVideo is None:
         return ""
     location = linkVideo.getLocation()
     room = linkVideo.getRoom()
     roomIp = ""
     if location and room and location.getName() and room.getName() and location.getName().strip() and room.getName().strip():
         minfo = info.HelperMaKaCInfo.getMaKaCInfoInstance()
         if minfo.getRoomBookingModuleActive():
             CrossLocationDB.connect()
             try:
                 roomInfo = CrossLocationQueries.getRooms( location = location.getName(), roomName = room.getName())
                 roomIp = roomInfo.customAtts["H323 IP"]
             except Exception, e:
                 Logger.get("Vidyo").warning("Location: " + location.getName() + "Problem with CrossLocationQueries when retrieving the list of all rooms with a H323 IP: " + str(e))
Exemplo n.º 3
0
 def getLinkRoomIp(cls, linkVideo, ipAttName="H323 IP"):
     if linkVideo is None:
         return ""
     location = linkVideo.getLocation()
     room = linkVideo.getRoom()
     roomIp = ""
     if location and room and location.getName() and room.getName() and location.getName().strip() and room.getName().strip():
         minfo = info.HelperMaKaCInfo.getMaKaCInfoInstance()
         if minfo.getRoomBookingModuleActive():
             CrossLocationDB.connect()
             try:
                 roomInfo = CrossLocationQueries.getRooms( location = location.getName(), roomName = room.getName())
                 roomIp = roomInfo.customAtts[ipAttName]
             except Exception, e:
                 Logger.get("Vidyo").warning("Location: '%s' - Problem with CrossLocationQueries: '%s'" % (location.getName(), str(e)))
Exemplo n.º 4
0
    def _getSideMenu(self):
        minfo = info.HelperMaKaCInfo.getMaKaCInfoInstance()
        
        self._leftMenu = wcomponents.BasicSideMenu(self._getAW().getUser() != None)

        self._showResponsible = False


        if minfo.getRoomBookingModuleActive() and CrossLocationDB.isConnected(): 
            self._showResponsible = ( self._getAW().getUser() != None ) and self._getAW().getUser().isResponsibleForRooms()
                           
        self._roomsOpt = wcomponents.SideMenuSection(_("View Rooms"), \
                                        urlHandlers.UHRoomBookingSearch4Rooms.getURL() )
        self._roomSearchOpt = wcomponents.SideMenuItem(_("Search rooms"),
                                        urlHandlers.UHRoomBookingSearch4Rooms.getURL(),
                                        enabled=True)
        self._roomMapOpt = wcomponents.SideMenuItem(_("Map of rooms"),
                                        urlHandlers.UHRoomBookingMapOfRooms.getURL(),
                                        enabled=True)
        self._myRoomListOpt = wcomponents.SideMenuItem(_("My rooms"),
                                        urlHandlers.UHRoomBookingRoomList.getURL( onlyMy = True ),
                                        enabled=self._showResponsible)
        self._bookingsOpt = wcomponents.SideMenuSection(_("View Bookings"), \
                                        urlHandlers.UHRoomBookingSearch4Bookings.getURL())
        self._bookARoomOpt = wcomponents.SideMenuItem(_("Book a Room"), \
                                        urlHandlers.UHRoomBookingSearch4Rooms.getURL( forNewBooking = True ),
                                        enabled=True)
        self._bookingListSearchOpt = wcomponents.SideMenuItem(_("Search bookings"),
                                        urlHandlers.UHRoomBookingSearch4Bookings.getURL(),
                                        enabled=True)
        self._bookingListCalendarOpt = wcomponents.SideMenuItem(_("Calendar"),
                                        urlHandlers.UHRoomBookingBookingList.getURL( today = True, allRooms = True ),
                                        enabled=True)
        self._myBookingListOpt = wcomponents.SideMenuItem(_("My bookings"),
                                        urlHandlers.UHRoomBookingBookingList.getURL( onlyMy = True, autoCriteria = True ),
                                        enabled=True)
        self._myPreBookingListOpt = wcomponents.SideMenuItem(_("My PRE-bookings"),
                                        urlHandlers.UHRoomBookingBookingList.getURL( onlyMy = True, onlyPrebookings = True, autoCriteria = True ),
                                        enabled=True)
        self._usersBookings = wcomponents.SideMenuItem(_("Bookings in my rooms"),
                                        urlHandlers.UHRoomBookingBookingList.getURL( ofMyRooms = True, autoCriteria = True ),
                                        enabled=self._showResponsible)
        self._usersPrebookings = wcomponents.SideMenuItem(_("PRE-bookings in my rooms"),
                                        urlHandlers.UHRoomBookingBookingList.getURL( ofMyRooms = True, onlyPrebookings = True, autoCriteria = True ),
                                        enabled=self._showResponsible)

        
        self._leftMenu.addSection( self._roomsOpt )
        self._roomsOpt.addItem( self._roomSearchOpt )
        self._roomsOpt.addItem( self._roomMapOpt )
        self._roomsOpt.addItem( self._myRoomListOpt )
        self._leftMenu.addSection( self._bookingsOpt )
        self._bookingsOpt.addItem( self._bookARoomOpt )
        self._bookingsOpt.addItem( self._bookingListSearchOpt )
        self._bookingsOpt.addItem( self._bookingListCalendarOpt )
        self._bookingsOpt.addItem( self._myBookingListOpt )
        self._bookingsOpt.addItem( self._myPreBookingListOpt )
        self._bookingsOpt.addItem( self._usersBookings )
        self._bookingsOpt.addItem( self._usersPrebookings )
        return self._leftMenu
Exemplo n.º 5
0
    def getVars(self):
        vars = WJSBase.getVars( self )

        roomsWithH323IP = []

        if self._conf:
            
            # Code to get a list of H.323 Videoconference-able rooms
            # by querying Indico's RB database
            location = self._conf.getLocation()

            if location and location.getName():
                locationName = location.getName()

                # TODO: get list of room from a plugin option instead of querying the RB DB everytime
                try:
                    minfo = info.HelperMaKaCInfo.getMaKaCInfoInstance()
                    if minfo.getRoomBookingModuleActive():
                        Logger.get("CERNMCU").info("Connecting with Room Booking DB to get the list of all rooms with a H323 IP")
                        CrossLocationDB.connect()
                        Logger.get("CERNMCU").info("Connection successful")

                        attName = getCERNMCUOptionValueByName("H323_IP_att_name")

                        try:
                            returnedRooms = CrossLocationQueries.getRooms( location = locationName,
                                                                           customAtts = [{"name":attName, "allowEmpty":False,
                                                                                          "filter": (lambda ip: validIP(ip))}] )
                            if not isinstance(returnedRooms, list):
                                if returnedRooms:
                                    returnedRooms = [returnedRooms]
                                else:
                                    returnedRooms = []
    
                            for room in returnedRooms:
                                roomsWithH323IP.append(RoomWithH323(locationName, room._getName(), room.customAtts[attName]))
                                
                        except AttributeError:
                            #CrossLocationQueries.getRooms fails because it does not handle location names that are not in the DB
                            pass
                        except Exception, e:
                            Logger.get("CERNMCU").warning("Location: " + locationName + "Problem with CrossLocationQueries when retrieving the list of all rooms with a H323 IP: " + str(e))

                except MaKaCError, e:
                    Logger.get("CERNMCU").warning("Location: " + locationName + "MaKaCError when retrieving the list of all rooms with a H323 IP: " + e.getMsg())
                except Exception, e:
                    Logger.get("CERNMCU").warning("Location: " + locationName + "Exception when retrieving the list of all rooms with a H323 IP: " + str(e))
Exemplo n.º 6
0
    def rebuildRoomReservationsIndex():
        from MaKaC.common.db import DBMgr
        from MaKaC.rb_location import CrossLocationDB
        from MaKaC.rb_room import RoomBase
        from MaKaC.plugins.RoomBooking.default.dalManager import DALManager
        from BTrees.OOBTree import OOBTree

        DBMgr.getInstance().startRequest()
        CrossLocationDB.connect()
        root = DALManager.root

        resvEx = ReservationBase()
        resvEx.isConfirmed = None
        allResvs = CrossLocationQueries.getReservations( resvExample = resvEx )
        print "There are " + str( len( allResvs ) ) + " resvs and pre-resvs to index..."
        c = 0
        
        root[_ROOM_RESERVATIONS_INDEX] = OOBTree()
        print "Room => Reservations Index branch created"
        
        for resv in allResvs:
            roomReservationsIndexBTree = root[_ROOM_RESERVATIONS_INDEX]
            resvs = roomReservationsIndexBTree.get( resv.room.id )
            if resvs == None:
                resvs = [] # New list of reservations for this room
                roomReservationsIndexBTree.insert( resv.room.id, resvs )
            resvs.append( resv )
            roomReservationsIndexBTree[resv.room.id] = resvs
            c += 1
            if c % 100 == 0:
                print c
        
        CrossLocationDB.commit()
        CrossLocationDB.disconnect()
        DBMgr.getInstance().endRequest()
Exemplo n.º 7
0
def _endRequestSpecific2RH( commit = True ):
    minfo = info.HelperMaKaCInfo.getMaKaCInfoInstance()
    if minfo.getRoomBookingModuleActive():
        if commit:
            CrossLocationDB.commit()
        else:
            CrossLocationDB.rollback()
        CrossLocationDB.disconnect()
Exemplo n.º 8
0
    def play():
        from MaKaC.rb_location import CrossLocationDB
        from MaKaC.rb_room import RoomBase
        from MaKaC.common.db import DBMgr

        DBMgr.getInstance().startRequest()
        CrossLocationDB.connect()

        roomEx = RoomBase()
        roomEx.isActive = False
        rooms = CrossLocationQueries.getRooms( roomExample = roomEx )
        for r in rooms:
            print r
            
        CrossLocationDB.commit()
        CrossLocationDB.disconnect()
        DBMgr.getInstance().endRequest()
Exemplo n.º 9
0
    def indexByDay():
        from MaKaC.rb_location import CrossLocationDB
        from MaKaC.rb_room import RoomBase
        from MaKaC.common.db import DBMgr

        DBMgr.getInstance().startRequest()
        CrossLocationDB.connect()

#        resvEx = ReservationBase()
#        resvEx.isConfirmed = None
#        resvs = CrossLocationQueries.getReservations( resvExample = resvEx )
#        print "There are " + str( len( resvs ) ) + " resvs to index..."
#        c = 0
#        for resv in resvs:
#            resv._addToDayReservationsIndex()
#            c += 1
#            if c % 100 == 0:
#                print c
        
        CrossLocationDB.commit()
        CrossLocationDB.disconnect()
        DBMgr.getInstance().endRequest()
Exemplo n.º 10
0
 def _abortSpecific2RH( self ):
     minfo = info.HelperMaKaCInfo.getMaKaCInfoInstance()
     if minfo.getRoomBookingModuleActive():
         CrossLocationDB.rollback()
Exemplo n.º 11
0
 def _syncSpecific2RH( self ):
     minfo = info.HelperMaKaCInfo.getMaKaCInfoInstance()
     if minfo.getRoomBookingModuleActive():
         CrossLocationDB.sync()
Exemplo n.º 12
0
 def _startRequestSpecific2RH( self ):
     minfo = info.HelperMaKaCInfo.getMaKaCInfoInstance()
     if minfo.getRoomBookingModuleActive():
         CrossLocationDB.connect()
Exemplo n.º 13
0
    def _getSideMenu(self):
        minfo = info.HelperMaKaCInfo.getMaKaCInfoInstance()

        self._leftMenu = wcomponents.BasicSideMenu(self._getAW().getUser() != None)

        self._showResponsible = False


        if minfo.getRoomBookingModuleActive() and CrossLocationDB.isConnected():
            self._showResponsible = \
                (self._getAW().getUser() != None) and \
                (Room.isAvatarResponsibleForRooms(self._getAW().getUser()) \
                 or self._getAW().getUser().isAdmin() \
                 or self._getAW().getUser().isRBAdmin())

        self._roomsOpt = wcomponents.SideMenuSection(_("View Rooms"), \
                                        urlHandlers.UHRoomBookingSearch4Rooms.getURL() )
        self._roomSearchOpt = wcomponents.SideMenuItem(_("Search rooms"),
                                        urlHandlers.UHRoomBookingSearch4Rooms.getURL(),
                                        enabled=True)
        self._roomMapOpt = wcomponents.SideMenuItem(_("Map of rooms"),
                                        urlHandlers.UHRoomBookingMapOfRooms.getURL(),
                                        enabled=True)
        self._myRoomListOpt = wcomponents.SideMenuItem(_("My rooms"),
                                        urlHandlers.UHRoomBookingRoomList.getURL( onlyMy = True ),
                                        enabled=self._showResponsible)
        self._bookingsOpt = wcomponents.SideMenuSection(_("View Bookings"), \
                                        urlHandlers.UHRoomBookingSearch4Bookings.getURL())
        self._bookARoomOpt = wcomponents.SideMenuItem(_("Book a Room"), \
                                        urlHandlers.UHRoomBookingSearch4Rooms.getURL( forNewBooking = True ),
                                        enabled=True)
        self._bookingListSearchOpt = wcomponents.SideMenuItem(_("Search bookings"),
                                        urlHandlers.UHRoomBookingSearch4Bookings.getURL(),
                                        enabled=True)
        self._bookingListCalendarOpt = wcomponents.SideMenuItem(_("Calendar"),
                                        urlHandlers.UHRoomBookingBookingList.getURL( today = True, allRooms = True ),
                                        enabled=True)
        self._myBookingListOpt = wcomponents.SideMenuItem(_("My bookings"),
                                        urlHandlers.UHRoomBookingBookingList.getURL( onlyMy = True, autoCriteria = True ),
                                        enabled=True)
        self._myPreBookingListOpt = wcomponents.SideMenuItem(_("My PRE-bookings"),
                                        urlHandlers.UHRoomBookingBookingList.getURL( onlyMy = True, onlyPrebookings = True, autoCriteria = True ),
                                        enabled=True)
        self._usersBookings = wcomponents.SideMenuItem(_("Bookings in my rooms"),
                                        urlHandlers.UHRoomBookingBookingList.getURL( ofMyRooms = True, autoCriteria = True ),
                                        enabled=self._showResponsible)
        self._usersPrebookings = wcomponents.SideMenuItem(_("PRE-bookings in my rooms"),
                                        urlHandlers.UHRoomBookingBookingList.getURL( ofMyRooms = True, onlyPrebookings = True, autoCriteria = True ),
                                        enabled=self._showResponsible)

        self._blockingsOpt = wcomponents.SideMenuSection(_("Room Blocking"))
        self._usersBlockings = wcomponents.SideMenuItem(_("Blockings for my rooms"),
                                        urlHandlers.UHRoomBookingBlockingsMyRooms.getURL( filterState='pending' ),
                                        enabled=self._showResponsible)
        if self._showResponsible:
            self._myBlockingListOpt = wcomponents.SideMenuItem(_("My blockings"),
                                            urlHandlers.UHRoomBookingBlockingList.getURL( onlyMine = True, onlyRecent = True ),
                                            enabled=True)
        else:
            self._myBlockingListOpt = wcomponents.SideMenuItem(_("Blockings"),
                                            urlHandlers.UHRoomBookingBlockingList.getURL( onlyRecent = True ),
                                            enabled=True)
        self._blockRooms = wcomponents.SideMenuItem(_("Block rooms"),
                                        urlHandlers.UHRoomBookingBlockingForm.getURL(),
                                        enabled=self._showResponsible)


        if self._rh._getUser().isRBAdmin():
            self._adminSect = wcomponents.SideMenuSection(_("Administration"), \
                                            urlHandlers.UHRoomBookingAdmin.getURL() )
            self._adminOpt = wcomponents.SideMenuItem(_("Administration"), \
                                            urlHandlers.UHRoomBookingAdmin.getURL() )

        self._leftMenu.addSection( self._roomsOpt )
        self._roomsOpt.addItem( self._roomSearchOpt )
        if Location.getDefaultLocation() and Location.getDefaultLocation().isMapAvailable():
            self._roomsOpt.addItem( self._roomMapOpt )
        self._roomsOpt.addItem( self._myRoomListOpt )
        self._leftMenu.addSection( self._bookingsOpt )
        self._bookingsOpt.addItem( self._bookARoomOpt )
        self._bookingsOpt.addItem( self._bookingListSearchOpt )
        self._bookingsOpt.addItem( self._bookingListCalendarOpt )
        self._bookingsOpt.addItem( self._myBookingListOpt )
        self._bookingsOpt.addItem( self._myPreBookingListOpt )
        self._bookingsOpt.addItem( self._usersBookings )
        self._bookingsOpt.addItem( self._usersPrebookings )
        self._leftMenu.addSection( self._blockingsOpt )
        self._blockingsOpt.addItem( self._blockRooms )
        self._blockingsOpt.addItem( self._myBlockingListOpt )
        self._blockingsOpt.addItem( self._usersBlockings )
        if self._rh._getUser().isRBAdmin():
            self._leftMenu.addSection( self._adminSect )
            self._adminSect.addItem( self._adminOpt )
        return self._leftMenu
Exemplo n.º 14
0
def _abortSpecific2RH():
    minfo = info.HelperMaKaCInfo.getMaKaCInfoInstance()
    if minfo.getRoomBookingModuleActive():
        CrossLocationDB.rollback()
Exemplo n.º 15
0
def _syncSpecific2RH():
    minfo = info.HelperMaKaCInfo.getMaKaCInfoInstance()
    if minfo.getRoomBookingModuleActive():
        CrossLocationDB.sync()
Exemplo n.º 16
0
def _startRequestSpecific2RH():
        minfo = info.HelperMaKaCInfo.getMaKaCInfoInstance()
        if minfo.getRoomBookingModuleActive():
            CrossLocationDB.connect()
Exemplo n.º 17
0
    def _getSideMenu(self):
        minfo = info.HelperMaKaCInfo.getMaKaCInfoInstance()

        self._leftMenu = wcomponents.BasicSideMenu(
            self._getAW().getUser() != None)

        self._showResponsible = False

        if minfo.getRoomBookingModuleActive() and CrossLocationDB.isConnected(
        ):
            self._showResponsible = \
                (self._getAW().getUser() != None) and \
                (Room.isAvatarResponsibleForRooms(self._getAW().getUser()) \
                 or self._getAW().getUser().isAdmin() \
                 or self._getAW().getUser().isRBAdmin())

        self._roomsOpt = wcomponents.SideMenuSection(_("View Rooms"), \
                                        urlHandlers.UHRoomBookingSearch4Rooms.getURL() )
        self._roomSearchOpt = wcomponents.SideMenuItem(
            _("Search rooms"),
            urlHandlers.UHRoomBookingSearch4Rooms.getURL(),
            enabled=True)
        self._roomMapOpt = wcomponents.SideMenuItem(
            _("Map of rooms"),
            urlHandlers.UHRoomBookingMapOfRooms.getURL(),
            enabled=True)
        self._myRoomListOpt = wcomponents.SideMenuItem(
            _("My rooms"),
            urlHandlers.UHRoomBookingRoomList.getURL(onlyMy=True),
            enabled=self._showResponsible)
        self._bookingsOpt = wcomponents.SideMenuSection(_("View Bookings"), \
                                        urlHandlers.UHRoomBookingSearch4Bookings.getURL())
        self._bookARoomOpt = wcomponents.SideMenuItem(_("Book a Room"), \
                                        urlHandlers.UHRoomBookingSearch4Rooms.getURL( forNewBooking = True ),
                                        enabled=True)
        self._bookingListSearchOpt = wcomponents.SideMenuItem(
            _("Search bookings"),
            urlHandlers.UHRoomBookingSearch4Bookings.getURL(),
            enabled=True)
        self._bookingListCalendarOpt = wcomponents.SideMenuItem(
            _("Calendar"),
            urlHandlers.UHRoomBookingBookingList.getURL(today=True,
                                                        allRooms=True),
            enabled=True)
        self._myBookingListOpt = wcomponents.SideMenuItem(
            _("My bookings"),
            urlHandlers.UHRoomBookingBookingList.getURL(onlyMy=True,
                                                        autoCriteria=True),
            enabled=True)
        self._myPreBookingListOpt = wcomponents.SideMenuItem(
            _("My PRE-bookings"),
            urlHandlers.UHRoomBookingBookingList.getURL(onlyMy=True,
                                                        onlyPrebookings=True,
                                                        autoCriteria=True),
            enabled=True)
        self._usersBookings = wcomponents.SideMenuItem(
            _("Bookings in my rooms"),
            urlHandlers.UHRoomBookingBookingList.getURL(ofMyRooms=True,
                                                        autoCriteria=True),
            enabled=self._showResponsible)
        self._usersPrebookings = wcomponents.SideMenuItem(
            _("PRE-bookings in my rooms"),
            urlHandlers.UHRoomBookingBookingList.getURL(ofMyRooms=True,
                                                        onlyPrebookings=True,
                                                        autoCriteria=True),
            enabled=self._showResponsible)

        self._blockingsOpt = wcomponents.SideMenuSection(_("Room Blocking"))
        self._usersBlockings = wcomponents.SideMenuItem(
            _("Blockings for my rooms"),
            urlHandlers.UHRoomBookingBlockingsMyRooms.getURL(
                filterState='pending'),
            enabled=self._showResponsible)
        if self._showResponsible:
            self._myBlockingListOpt = wcomponents.SideMenuItem(
                _("My blockings"),
                urlHandlers.UHRoomBookingBlockingList.getURL(onlyMine=True,
                                                             onlyRecent=True),
                enabled=True)
        else:
            self._myBlockingListOpt = wcomponents.SideMenuItem(
                _("Blockings"),
                urlHandlers.UHRoomBookingBlockingList.getURL(onlyRecent=True),
                enabled=True)
        self._blockRooms = wcomponents.SideMenuItem(
            _("Block rooms"),
            urlHandlers.UHRoomBookingBlockingForm.getURL(),
            enabled=self._showResponsible)

        if self._rh._getUser().isRBAdmin():
            self._adminSect = wcomponents.SideMenuSection(_("Administration"), \
                                            urlHandlers.UHRoomBookingAdmin.getURL() )
            self._adminOpt = wcomponents.SideMenuItem(_("Administration"), \
                                            urlHandlers.UHRoomBookingAdmin.getURL() )

        self._leftMenu.addSection(self._roomsOpt)
        self._roomsOpt.addItem(self._roomSearchOpt)
        if Location.getDefaultLocation() and Location.getDefaultLocation(
        ).isMapAvailable():
            self._roomsOpt.addItem(self._roomMapOpt)
        self._roomsOpt.addItem(self._myRoomListOpt)
        self._leftMenu.addSection(self._bookingsOpt)
        self._bookingsOpt.addItem(self._bookARoomOpt)
        self._bookingsOpt.addItem(self._bookingListSearchOpt)
        self._bookingsOpt.addItem(self._bookingListCalendarOpt)
        self._bookingsOpt.addItem(self._myBookingListOpt)
        self._bookingsOpt.addItem(self._myPreBookingListOpt)
        self._bookingsOpt.addItem(self._usersBookings)
        self._bookingsOpt.addItem(self._usersPrebookings)
        self._leftMenu.addSection(self._blockingsOpt)
        self._blockingsOpt.addItem(self._blockRooms)
        self._blockingsOpt.addItem(self._myBlockingListOpt)
        self._blockingsOpt.addItem(self._usersBlockings)
        if self._rh._getUser().isRBAdmin():
            self._leftMenu.addSection(self._adminSect)
            self._adminSect.addItem(self._adminOpt)
        return self._leftMenu
Exemplo n.º 18
0
    def getVars(self):
        vars = WJSBase.getVars( self )

        vars["MinStartDate"] = formatDateTime(self._conf.getAdjustedStartDate())
        vars["MaxEndDate"] = formatDateTime(self._conf.getAdjustedEndDate())

        # Code to retrieve the event's location and room in order to include the event's room
        # as an initial participant
        location = self._conf.getLocation()
        room = self._conf.getRoom()
        if location and room and location.getName() and room.getName() and location.getName().strip() and room.getName().strip():
            locationName = location.getName()
            roomName = room.getName()
            
            vars["IncludeInitialRoom"] = True
            vars["IPRetrievalResult"] = -1 # 0 = OK, 1 = room without H323 IP, 2 = room with invalid H323 IP, 3 = connection to RB problem, 4 = another unknown problem 
            vars["InitialRoomName"] = roomName
            if self._conf.getLocation():
                vars["InitialRoomInstitution"] = locationName
            else:
                vars["InitialRoomInstitution"] = ""

            # TODO: get IP of room from a plugin option instead of querying RB DB every time
            try:
                minfo = info.HelperMaKaCInfo.getMaKaCInfoInstance()
                if minfo.getRoomBookingModuleActive():
                    Logger.get("CERNMCU").info("Connecting with Room Booking DB to get a room's H323 IP")
                    CrossLocationDB.connect()
                    Logger.get("CERNMCU").info("Connection successful")

                    attName = getCERNMCUOptionValueByName("H323_IP_att_name")

                    try:
                        returnedRooms = CrossLocationQueries.getRooms( location = locationName, roomName = roomName )
    
                        if isinstance(returnedRooms, list):
                            if len(returnedRooms) == 0:
                                returnedRoom = None
                            else:
                                returnedRoom = returnedRooms[0]
                        else:
                            returnedRoom = returnedRooms
    
                        if (returnedRoom != None) and (attName in returnedRoom.customAtts):
    
                            initialRoomIp = returnedRoom.customAtts[attName]
                            if (initialRoomIp.strip() == ""):
                                vars["IPRetrievalResult"] = 1
                            elif not validIP(initialRoomIp):
                                vars["IPRetrievalResult"] = 2
                            else:
                                vars["IPRetrievalResult"] = 0
    
                        else:
                            initialRoomIp = "IP not defined for this room."
                            vars["IPRetrievalResult"] = 2
                            
                    except AttributeError:
                        #CrossLocationQueries.getRooms fails because it does not handle location names that are not in the DB
                        initialRoomIp = "Please enter IP"
                        vars["IPRetrievalResult"] = 1
                    except Exception, e:
                        initialRoomIp = "IP not found."
                        vars["IPRetrievalResult"] = 4
                        Logger.get("CERNMCU").warning("Location: " + locationName + "Problem with CrossLocationQueries when retrieving the list of all rooms with a H323 IP: " + str(e))
                else:
                    initialRoomIp = "Please enter IP"
                    vars["IPRetrievalResult"] = 3
                    Logger.get("CERNMCU").info("Tried to retrieve a room's H323 IP, but Room Booking module was not active.")
Exemplo n.º 19
0
    def execute(self):
        try:
            self._initLog()
            self._printOutput("***Starting execute***\n")
            ### Get the connection in order to avoid that to threads share the same one
            conn = db.DBMgr().getInstance()
            conn.startRequest()

            minfo = HelperMaKaCInfo.getMaKaCInfoInstance()

            if minfo.getRoomBookingModuleActive():
                CrossLocationDB.connect()
            ###
            taskList = HelperTaskList().getTaskListInstance()
            tasks = taskList.getTasks()
            if len(tasks) == 0:
                self._printOutput("--->No tasks!")
            else:
                self._printOutput("Execute at %s\n" % datetime.now())
            taskids = [i.getId() for i in tasks]
            for id in taskids:
                ### check if another thread have already removed the task
                conn.sync()
                if not id in taskList.listTask.keys():
                    continue
                task = taskList.getTaskById(id)
                ###
                if task.isRunning():
                    self._printOutput("\t--->Task <%s> already running" %
                                      task.getId())
                else:
                    try:
                        self._printOutput("\t--->Running task <%s>" %
                                          task.getId())

                        if task.getStartDate(
                        ) == None or task.getStartDate() < nowutc():
                            self._printOutput("\t (SINGLE RUN)")
                            # the task is started
                            if task.getInterval() == None or task.getLastDate(
                            ) == None:
                                # the task is run once or never runned
                                task.setRunning(True)
                                conn.commit()
                                abort = task.prerun()
                                if abort:
                                    self._printOutput(
                                        "\t<---Task <%s> was aborted." %
                                        task.getId())
                                    task.setRunning(False)
                                    conn.commit()
                                    continue
                                for obj in task.getObjList():
                                    self._printOutput(
                                        "\t\tRunning object <%s> (start date: %s)"
                                        % (obj.getId(), task.getStartDate()))
                                    #task.setLastDate(datetime.now())

                                    self._runObj(obj)

                                    self._printOutput("\t\tEnd object")
                                task.setLastDate(nowutc())
                                task.setRunning(False)
                                if task.getInterval() == None:
                                    # if run once, delete the task from list
                                    taskList.removeTask(task)
                                    self._printOutput("\t\tTask was removed")
                                else:
                                    self._printOutput(
                                        "\t\tTask is periodic (getInterval: %s)"
                                        % task.getInterval())
                            else:
                                self._printOutput("\t (PERIODIC TASK)")
                                # the task is to be run multiple times
                                if task.getLastDate() + task.getInterval(
                                ) < nowutc():
                                    task.setRunning(True)
                                    conn.commit()
                                    abort = task.prerun()
                                    if abort:
                                        self._printOutput(
                                            "\t<---Task <%s> was aborted." %
                                            task.getId())
                                        task.setRunning(False)
                                        conn.commit()
                                        continue
                                    # it's time to launch the task!!!
                                    for obj in task.getObjList():
                                        self._printOutput(
                                            "\tRunning object %s (last date: %s)"
                                            %
                                            (obj.getId(), task.getLastDate()))
                                        #task.setLastDate(datetime.now())

                                        self._runObj(obj)

                                        self._printOutput("\t\tEnd object")
                                    if task.getLastDate() and task.getEndDate(
                                    ):
                                        if task.getLastDate(
                                        ) + task.getInterval(
                                        ) > task.getEndDate():
                                            # the task is finish, delete it from list
                                            taskList.removeTask(task)
                                            self._printOutput(
                                                "\t\tTask was removed")
                                    task.setLastDate(nowutc())
                                    task.setRunning(False)
                        self._printOutput("\t<---end task <%s>\n" %
                                          task.getId())
                        conn.commit()
                    except Exception, e:
                        conn.sync()
                        task.setRunning(False)
                        conn.commit()
                        ty, ex, tb = sys.exc_info()
                        tracebackList = traceback.format_list(
                            traceback.extract_tb(tb))
                        self._printOutput(
                            "*****---->[ERROR]:%s\nTraceback:%s" %
                            (e, "\n".join(tracebackList)))
                        self._sendErrorEmail(e)

            if minfo.getRoomBookingModuleActive():
                CrossLocationDB.commit()
                CrossLocationDB.disconnect()

            conn.endRequest()

            self._printOutput("***end execute***\n\n")
            self._closeLog()
Exemplo n.º 20
0
    def execute(self):
        try:
            self._initLog()
            self._printOutput("***Starting execute***\n")
            ### Get the connection in order to avoid that to threads share the same one
            conn = db.DBMgr().getInstance()
            conn.startRequest()

            minfo = HelperMaKaCInfo.getMaKaCInfoInstance()

            if minfo.getRoomBookingModuleActive():
                CrossLocationDB.connect()
            ###
            taskList = HelperTaskList().getTaskListInstance()
            tasks = taskList.getTasks()
            if len(tasks) == 0:
                self._printOutput("--->No tasks!")
            else:
                self._printOutput("Execute at %s\n"%datetime.now())
            taskids = [i.getId() for i in tasks]
            for id in taskids:
                ### check if another thread have already removed the task
                conn.sync()
                if not id in taskList.listTask.keys():
                    continue
                task = taskList.getTaskById(id)
                ###
                if task.isRunning():
                    self._printOutput("\t--->Task <%s> already running"%task.getId())
                else:
                    try:
                        self._printOutput("\t--->Running task <%s>"%task.getId())

                        if task.getStartDate() == None or task.getStartDate() < nowutc():
                            self._printOutput("\t (SINGLE RUN)")
                            # the task is started
                            if task.getInterval() == None or task.getLastDate() == None:
                                # the task is run once or never runned
                                task.setRunning(True)
                                conn.commit()
                                abort=task.prerun()
                                if abort:
                                    self._printOutput("\t<---Task <%s> was aborted."%task.getId())
                                    task.setRunning(False)
                                    conn.commit()
                                    continue
                                for obj in task.getObjList():
                                    self._printOutput("\t\tRunning object <%s> (start date: %s)"%(obj.getId(),task.getStartDate()))
                                    #task.setLastDate(datetime.now())

                                    self._runObj(obj)

                                    self._printOutput("\t\tEnd object")
                                task.setLastDate(nowutc())
                                task.setRunning(False)
                                if task.getInterval() == None:
                                    # if run once, delete the task from list
                                    taskList.removeTask(task)
                                    self._printOutput("\t\tTask was removed")
                                else:
                                    self._printOutput("\t\tTask is periodic (getInterval: %s)" % task.getInterval())
                            else:
                                self._printOutput("\t (PERIODIC TASK)")
                                # the task is to be run multiple times
                                if task.getLastDate() + task.getInterval() < nowutc():
                                    task.setRunning(True)
                                    conn.commit()
                                    abort=task.prerun()
                                    if abort:
                                        self._printOutput("\t<---Task <%s> was aborted."%task.getId())
                                        task.setRunning(False)
                                        conn.commit()
                                        continue
                                    # it's time to launch the task!!!
                                    for obj in task.getObjList():
                                        self._printOutput("\tRunning object %s (last date: %s)"%(obj.getId(),task.getLastDate()))
                                        #task.setLastDate(datetime.now())

                                        self._runObj(obj)

                                        self._printOutput("\t\tEnd object")
                                    if task.getLastDate() and task.getEndDate():
                                        if task.getLastDate() + task.getInterval() > task.getEndDate():
                                            # the task is finish, delete it from list
                                            taskList.removeTask(task)
                                            self._printOutput("\t\tTask was removed")
                                    task.setLastDate(nowutc())
                                    task.setRunning(False)
                        self._printOutput("\t<---end task <%s>\n"%task.getId())
                        conn.commit()
                    except Exception, e:
                        conn.sync()
                        task.setRunning(False)
                        conn.commit()
                        ty, ex, tb = sys.exc_info()
                        tracebackList = traceback.format_list( traceback.extract_tb( tb ) )
                        self._printOutput("*****---->[ERROR]:%s\nTraceback:%s"%(e,"\n".join(tracebackList)))
                        self._sendErrorEmail(e)

            if minfo.getRoomBookingModuleActive():
                CrossLocationDB.commit()
                CrossLocationDB.disconnect()

            conn.endRequest()

            self._printOutput("***end execute***\n\n")
            self._closeLog()