def QueryConference(conference, bookingId): booking = conference.getBookingById(bookingId) if booking == None: raise ServiceError("Invalid hermes id.") #mcuConference = McuApi.first(McuApi.SelectConferences(conferenceName = booking.getHermesName())) #if mcuConference == None: #raise ServiceError("Conference no longer exists in MCU.", conferenceName) roomName = None roomAddress = None conferenceRoom = conference.getRoom() if conferenceRoom: roomName = conferenceRoom.getName() try: DALManagerCERN.connect() room = RoomBase.getRooms(roomName = roomName) if room: roomAddress = room.customAtts["H323 IP"] finally: DALManagerCERN.disconnect() properties = { "mcu": McuApi.mcuAddress, "roomName": roomName, "roomAddress": roomAddress } return booking, properties
def QueryConference(conference, bookingId): booking = conference.getBookingById(bookingId) if booking == None: raise ServiceError("Invalid hermes id.") #mcuConference = McuApi.first(McuApi.SelectConferences(conferenceName = booking.getHermesName())) #if mcuConference == None: #raise ServiceError("Conference no longer exists in MCU.", conferenceName) roomName = None roomAddress = None conferenceRoom = conference.getRoom() if conferenceRoom: roomName = conferenceRoom.getName() try: DALManagerCERN.connect() room = RoomBase.getRooms(roomName=roomName) if room: roomAddress = room.customAtts["H323 IP"] finally: DALManagerCERN.disconnect() properties = { "mcu": McuApi.mcuAddress, "roomName": roomName, "roomAddress": roomAddress } return booking, properties
def initializeRoomBookingDB(location, force=False): """ Modifies Indico main database. - location list Creates necessary branches in room booking database. - rooms branch - bookings branch - several indexes """ indicoRoot = MaKaC.common.DBMgr.getInstance().getDBConnection().root() root = DALManagerCERN().getRoot() # 1. Location ----------------------------------------------------------- initialLocation = Location(location, FactoryCERN) if force or not indicoRoot.has_key("RoomBookingLocationList"): indicoRoot["RoomBookingLocationList"] = [initialLocation] if force or not indicoRoot.has_key("DefaultRoomBookingLocation"): indicoRoot["DefaultRoomBookingLocation"] = location # 2. Rooms & Bookings --------------------------------------------------- # Create rooms branch if force or not root.has_key("Rooms"): root["Rooms"] = IOBTree() # Create reservations branch if force or not root.has_key("Reservations"): root["Reservations"] = IOBTree() # Create blocking branch if force or not root.has_key("RoomBlocking"): root["RoomBlocking"] = OOBTree() root["RoomBlocking"]["Blockings"] = IOBTree() root["RoomBlocking"]["Indexes"] = OOBTree() root["RoomBlocking"]["Indexes"]["OwnerBlockings"] = OOBTree() root["RoomBlocking"]["Indexes"]["DayBlockings"] = CalendarDayIndex() root["RoomBlocking"]["Indexes"]["RoomBlockings"] = OOBTree() # Create indexes if force or not root.has_key("RoomReservationsIndex"): root["RoomReservationsIndex"] = OOBTree() if force or not root.has_key("UserReservationsIndex"): root["UserReservationsIndex"] = OOBTree() if force or not root.has_key("DayReservationsIndex"): root["DayReservationsIndex"] = OOBTree() if force or not root.has_key("RoomDayReservationsIndex"): root["RoomDayReservationsIndex"] = OOBTree() # Create possible equipment branch if force or not root.has_key("EquipmentList"): root["EquipmentList"] = {} # update Catalog with new rb indexes Catalog.updateDB() DALManagerCERN().commit()
def initializeRoomBookingDB(location, force=False): """ Modifies Indico main database. - location list Creates necessary branches in room booking database. - rooms branch - bookings branch - several indexes """ indicoRoot = MaKaC.common.DBMgr.getInstance().getDBConnection().root() root = DALManagerCERN().root # 1. Location ----------------------------------------------------------- initialLocation = Location(location, FactoryCERN) if force or not indicoRoot.has_key('RoomBookingLocationList'): indicoRoot['RoomBookingLocationList'] = [initialLocation] print "Locations branch created (Indico db)" if force or not indicoRoot.has_key('DefaultRoomBookingLocation'): indicoRoot['DefaultRoomBookingLocation'] = location print "Default location set to " + location # 2. Rooms & Bookings --------------------------------------------------- # Create rooms branch if force or not root.has_key('Rooms'): root['Rooms'] = IOBTree() print "Rooms branch created" # Create reservations branch if force or not root.has_key('Reservations'): root['Reservations'] = IOBTree() print "Reservations branch created" # Create indexes if force or not root.has_key('RoomReservationsIndex'): root['RoomReservationsIndex'] = OOBTree() print "Room => Reservations Index branch created" if force or not root.has_key('UserReservationsIndex'): root['UserReservationsIndex'] = OOBTree() print "User => Reservations Index branch created" if force or not root.has_key('DayReservationsIndex'): root['DayReservationsIndex'] = OOBTree() print "Day => Reservations Index branch created" # Create possible equipment branch if force or not root.has_key('EquipmentList'): root['EquipmentList'] = {} print "Equipment branch created" AvatarHolder().invalidateRoomManagerIdList() print "Cached list of room managers invalidated" DALManagerCERN().commit()
def _process( self ): minfo = info.HelperMaKaCInfo.getMaKaCInfoInstance() active = minfo.getRoomBookingModuleActive() if not active: # Initialize built-in plugin on activation from MaKaC.plugins.RoomBooking.CERN.initialize import initializeRoomBookingDB from MaKaC.plugins.RoomBooking.CERN.dalManagerCERN import DALManagerCERN DALManagerCERN.connect() initializeRoomBookingDB( "Universe", force = False ) # Safe if data present DALManagerCERN.disconnect() minfo.setRoomBookingModuleActive( not active ) self._redirect( urlHandlers.UHRoomBookingPluginAdmin.getURL() )
def _process(self): minfo = info.HelperMaKaCInfo.getMaKaCInfoInstance() active = minfo.getRoomBookingModuleActive() if not active: # Initialize built-in plugin on activation from MaKaC.plugins.RoomBooking.CERN.initialize import initializeRoomBookingDB from MaKaC.plugins.RoomBooking.CERN.dalManagerCERN import DALManagerCERN DALManagerCERN.connect() initializeRoomBookingDB("Universe", force=False) # Safe if data present DALManagerCERN.disconnect() minfo.setRoomBookingModuleActive(not active) self._redirect(urlHandlers.UHRoomBookingPluginAdmin.getURL())
def initializeRoomBookingDB( location, force = False ): """ Modifies Indico main database. - location list Creates necessary branches in room booking database. - rooms branch - bookings branch - several indexes """ indicoRoot = MaKaC.common.DBMgr.getInstance().getDBConnection().root() root = DALManagerCERN().root # 1. Location ----------------------------------------------------------- initialLocation = Location( location, FactoryCERN ) if force or not indicoRoot.has_key( 'RoomBookingLocationList' ): indicoRoot['RoomBookingLocationList'] = [ initialLocation ] print "Locations branch created (Indico db)" if force or not indicoRoot.has_key( 'DefaultRoomBookingLocation' ): indicoRoot['DefaultRoomBookingLocation'] = location print "Default location set to " + location # 2. Rooms & Bookings --------------------------------------------------- # Create rooms branch if force or not root.has_key( 'Rooms' ): root['Rooms'] = IOBTree() print "Rooms branch created" # Create reservations branch if force or not root.has_key( 'Reservations' ): root['Reservations'] = IOBTree() print "Reservations branch created" # Create indexes if force or not root.has_key( 'RoomReservationsIndex' ): root['RoomReservationsIndex'] = OOBTree() print "Room => Reservations Index branch created" if force or not root.has_key( 'UserReservationsIndex' ): root['UserReservationsIndex'] = OOBTree() print "User => Reservations Index branch created" if force or not root.has_key( 'DayReservationsIndex' ): root['DayReservationsIndex'] = OOBTree() print "Day => Reservations Index branch created" # Create possible equipment branch if force or not root.has_key( 'EquipmentList' ): root['EquipmentList'] = {} print "Equipment branch created" AvatarHolder().invalidateRoomManagerIdList() print "Cached list of room managers invalidated" DALManagerCERN().commit()
def deleteRoomBookingBranches(force=False): """ !!! REMOVES DATA !!! Deletes all branches related to room booking, from both main and room booking databases. """ if not force: raise Exception('nothing done') indicoRoot = MaKaC.common.DBMgr.getInstance().getDBConnection().root() root = DALManagerCERN().getRoot() minfo = info.HelperMaKaCInfo.getMaKaCInfoInstance() # 1. INDICO ----------------------------------------- minfo.setRoomBookingModuleActive(False) if indicoRoot.get('RoomBookingLocationList'): del indicoRoot['RoomBookingLocationList'] if indicoRoot.get('DefaultRoomBookingLocation'): del indicoRoot['DefaultRoomBookingLocation'] # 2. ROOM BOOKING ------------------------------------ if root.get('Rooms'): del root['Rooms'] if root.get('Reservations'): del root['Reservations'] if root.get('RoomBlocking'): del root['RoomBlocking'] # Create indexes if root.get('RoomReservationsIndex'): del root['RoomReservationsIndex'] if root.get('UserReservationsIndex'): del root['UserReservationsIndex'] # Create possible equipment branch if root.get('EquipmentList'): del root['EquipmentList'] DALManagerCERN().commit()
def deleteRoomBookingBranches(force=False): """ !!! REMOVES DATA !!! Deletes all branches related to room booking, from both main and room booking databases. """ if not force: raise Exception("nothing done") indicoRoot = MaKaC.common.DBMgr.getInstance().getDBConnection().root() root = DALManagerCERN().getRoot() minfo = info.HelperMaKaCInfo.getMaKaCInfoInstance() # 1. INDICO ----------------------------------------- minfo.setRoomBookingModuleActive(False) if indicoRoot.get("RoomBookingLocationList"): del indicoRoot["RoomBookingLocationList"] if indicoRoot.get("DefaultRoomBookingLocation"): del indicoRoot["DefaultRoomBookingLocation"] # 2. ROOM BOOKING ------------------------------------ if root.get("Rooms"): del root["Rooms"] if root.get("Reservations"): del root["Reservations"] if root.get("RoomBlocking"): del root["RoomBlocking"] # Create indexes if root.get("RoomReservationsIndex"): del root["RoomReservationsIndex"] if root.get("UserReservationsIndex"): del root["UserReservationsIndex"] # Create possible equipment branch if root.get("EquipmentList"): del root["EquipmentList"] DALManagerCERN().commit()
def start(self, obj): super(RoomBooking_Feature, self).start(obj) with obj._context('database'): # Tell indico to use the current database for roombooking stuff minfo = HelperMaKaCInfo.getMaKaCInfoInstance() cfg = Configuration.Config.getInstance() minfo.setRoomBookingDBConnectionParams(cfg.getDBConnectionParams()) obj._ph.getById('RoomBooking').setActive(True) DALManagerCERN.connect() initializeRoomBookingDB("Universe", force=False) DALManagerCERN.disconnect() # do not use the method for it as it tries to re-create jsvars and fails minfo._roomBookingModuleActive = True DALManagerCERN.connect() # Create dummy rooms in obj._roomN - owners are fake1 and fake2 (r1 has f1, r2 has f2, r3 has f1, ...) location = Location.getDefaultLocation() obj._rooms = [] for i in xrange(1, 8): room = location.newRoom() room.locationName = location.friendlyName room.name = 'DummyRoom%d' % i room.site = 'a' room.building = 1 room.floor = 'b' room.roomNr = 'c' room.latitude = '' room.longitude = '' room.isActive = True room.isReservable = True room.resvsNeedConfirmation = False room.responsibleId = 'fake-%d' % (((i - 1) % 2) + 1) room.whereIsKey = 'Nowhere' room.telephone = '123456789' room.capacity = 10 room.division = '' room.surfaceArea = 50 room.comments = '' room.setEquipment([]) room.setAvailableVC([]) room.insert() obj._rooms.append(room) setattr(obj, '_room%d' % i, room)
def start(self, obj): super(RoomBooking_Feature, self).start(obj) with obj._context('database'): # Tell indico to use the current database for roombooking stuff minfo = HelperMaKaCInfo.getMaKaCInfoInstance() cfg = Configuration.Config.getInstance() minfo.setRoomBookingDBConnectionParams(cfg.getDBConnectionParams()) obj._ph.getById('RoomBooking').setActive(True) DALManagerCERN.connect() initializeRoomBookingDB("Universe", force=False) DALManagerCERN.disconnect() # do not use the method for it as it tries to re-create jsvars and fails minfo._roomBookingModuleActive = True DALManagerCERN.connect() # Create dummy rooms in obj._roomN - owners are fake1 and fake2 (r1 has f1, r2 has f2, r3 has f1, ...) location = Location.getDefaultLocation() obj._rooms = [] for i in xrange(1, 8): room = location.newRoom() room.locationName = location.friendlyName room.name = 'DummyRoom%d' % i room.site = 'a' room.building = 1 room.floor = 'b' room.roomNr = 'c' room.latitude = '' room.longitude = '' room.isActive = True room.isReservable = True room.resvsNeedConfirmation = False room.responsibleId = 'fake-%d' % (((i - 1) % 2) + 1) room.whereIsKey = 'Nowhere' room.telephone = '123456789' room.capacity = 10 room.division = '' room.surfaceArea = 50 room.comments = '' room.setEquipment([]) room.setAvailableVC([]) room.insert() obj._rooms.append(room) setattr(obj, '_room%d' % i, room)
def deleteRoomBookingBranches( force = False ): """ !!! REMOVES DATA !!! Deletes all branches related to room booking, from both main and room booking databases. """ if not force: raise 'nothing done' indicoRoot = MaKaC.common.DBMgr.getInstance().getDBConnection().root() root = DALManagerCERN().root minfo = info.HelperMaKaCInfo.getMaKaCInfoInstance() # 1. INDICO ----------------------------------------- minfo.setRoomBookingModuleActive( False ) if indicoRoot.get( 'RoomBookingLocationList' ): del indicoRoot['RoomBookingLocationList'] if indicoRoot.get( 'DefaultRoomBookingLocation' ): del indicoRoot['DefaultRoomBookingLocation'] # 2. ROOM BOKING ------------------------------------ if root.get( 'Rooms' ): del root['Rooms'] if root.get( 'Reservations' ): del root['Reservations'] # Create indexes if root.get( 'RoomReservationsIndex' ): del root['RoomReservationsIndex'] if root.get( 'UserReservationsIndex' ): del root['UserReservationsIndex'] # Create possible equipment branch if root.get( 'EquipmentList' ): del root['EquipmentList'] DALManagerCERN().commit()
# -*- coding: utf-8 -*- ## ## ## This file is part of Indico. ## Copyright (C) 2002 - 2014 European Organization for Nuclear Research (CERN). ## ## Indico is free software; you can redistribute it and/or ## modify it under the terms of the GNU General Public License as ## published by the Free Software Foundation; either version 3 of the ## License, or (at your option) any later version. ## ## Indico is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with Indico;if not, see <http://www.gnu.org/licenses/>. from indico.core.db import DBMgr DBMgr.getInstance().startRequest() from MaKaC.plugins.RoomBooking.CERN.dalManagerCERN import DALManagerCERN DALManagerCERN.pack(days=1) DBMgr.getInstance().endRequest()
def start(self, obj): super(RoomBooking_Feature, self).start(obj) with obj._context('database'): # Tell indico to use the current database for roombooking stuff minfo = HelperMaKaCInfo.getMaKaCInfoInstance() cfg = Configuration.Config.getInstance() minfo.setRoomBookingDBConnectionParams(cfg.getDBConnectionParams()) obj._ph.getById('RoomBooking').setActive(True) DALManagerCERN.connect() initializeRoomBookingDB("Universe", force=False) DALManagerCERN.disconnect() # do not use the method for it as it tries to re-create jsvars and fails minfo._roomBookingModuleActive = True DALManagerCERN.connect() # Create dummy avatars in obj._avatarN ah = AvatarHolder() obj._avatars = [] for i in xrange(1, 5): avatar = Avatar() avatar.setName("fake-%d" % i) avatar.setSurName("fake") avatar.setOrganisation("fake") avatar.setLang("en_GB") avatar.setEmail("*****@*****.**" % i) avatar.setId("rb-fake-%d" % i) # setting up the login info li = LoginInfo("fake-%d" % i, "fake-%d" % i) ih = AuthenticatorMgr() userid = ih.createIdentity(li, avatar, "Local") ih.add(userid) # activate the account avatar.activateAccount() ah.add(avatar) obj._avatars.append(avatar) setattr(obj, '_avatar%d' % i, avatar) # Create dummy rooms in obj._roomN - owners are fake1 and fake2 (r1 has f1, r2 has f2, r3 has f1, ...) location = Location.getDefaultLocation() obj._rooms = [] for i in xrange(1, 8): room = location.newRoom() room.locationName = location.friendlyName room.name = 'DummyRoom%d' % i room.site = 'a' room.building = 1 room.floor = 'b' room.roomNr = 'c' room.latitude = '' room.longitude = '' room.isActive = True room.isReservable = True room.resvsNeedConfirmation = False room.responsibleId = 'rb-fake-%d' % (((i - 1) % 2) + 1) room.whereIsKey = 'Nowhere' room.telephone = '123456789' room.capacity = 10 room.division = '' room.surfaceArea = 50 room.comments = '' room.setEquipment([]) room.setAvailableVC([]) room.insert() obj._rooms.append(room) setattr(obj, '_room%d' % i, room)
def disconnectFromIndicoDB(): from MaKaC.plugins.RoomBooking.CERN.dalManagerCERN import DALManagerCERN from MaKaC.common.db import DBMgr DALManagerCERN.disconnect() DBMgr.getInstance().endRequest()
def disconnectFromIndicoDB(): from MaKaC.plugins.RoomBooking.CERN.dalManagerCERN import DALManagerCERN from MaKaC.common.db import DBMgr DALManagerCERN.disconnect() DBMgr.getInstance().endRequest()
def connect2IndicoDB(): from MaKaC.plugins.RoomBooking.CERN.dalManagerCERN import DALManagerCERN from MaKaC.common.db import DBMgr DBMgr.getInstance().startRequest() DALManagerCERN.connect()
def start(self, obj): super(RoomBooking_Feature, self).start(obj) with obj._context('database'): # Tell indico to use the current database for roombooking stuff minfo = HelperMaKaCInfo.getMaKaCInfoInstance() cfg = Configuration.Config.getInstance() minfo.setRoomBookingDBConnectionParams(cfg.getDBConnectionParams()) obj._ph.getById('RoomBooking').setActive(True) DALManagerCERN.connect() initializeRoomBookingDB("Universe", force=False) DALManagerCERN.disconnect() # do not use the method for it as it tries to re-create jsvars and fails minfo._roomBookingModuleActive = True DALManagerCERN.connect() # Create dummy avatars in obj._avatarN ah = AvatarHolder() obj._avatars = [] for i in xrange(1, 5): avatar = Avatar() avatar.setName("fake-%d" % i) avatar.setSurName("fake") avatar.setOrganisation("fake") avatar.setLang("en_GB") avatar.setEmail("*****@*****.**" % i) avatar.setId("rb-fake-%d" % i) # setting up the login info li = LoginInfo("fake-%d" % i, "fake-%d" % i) ih = AuthenticatorMgr() userid = ih.createIdentity(li, avatar, "Local") ih.add(userid) # activate the account avatar.activateAccount() ah.add(avatar) obj._avatars.append(avatar) setattr(obj, '_avatar%d' % i, avatar) # Create dummy rooms in obj._roomN - owners are fake1 and fake2 (r1 has f1, r2 has f2, r3 has f1, ...) location = Location.getDefaultLocation() obj._rooms = [] for i in xrange(1, 8): room = location.newRoom() room.locationName = location.friendlyName room.name = 'DummyRoom%d' % i room.site = 'a' room.building = 1 room.floor = 'b' room.roomNr = 'c' room.latitude = '' room.longitude = '' room.isActive = True room.isReservable = True room.resvsNeedConfirmation = False room.responsibleId = 'rb-fake-%d' % (((i - 1) % 2) + 1) room.whereIsKey = 'Nowhere' room.telephone = '123456789' room.capacity = 10 room.division = '' room.surfaceArea = 50 room.comments = '' room.setEquipment([]) room.setAvailableVC([]) room.insert() obj._rooms.append(room) setattr(obj, '_room%d' % i, room)
def initializeRoomBookingDB(location, force=False): """ Modifies Indico main database. - location list Creates necessary branches in room booking database. - rooms branch - bookings branch - several indexes """ indicoRoot = MaKaC.common.DBMgr.getInstance().getDBConnection().root() root = DALManagerCERN().getRoot() # 1. Location ----------------------------------------------------------- initialLocation = Location(location, FactoryCERN) if force or not indicoRoot.has_key('RoomBookingLocationList'): indicoRoot['RoomBookingLocationList'] = [initialLocation] if force or not indicoRoot.has_key('DefaultRoomBookingLocation'): indicoRoot['DefaultRoomBookingLocation'] = location # 2. Rooms & Bookings --------------------------------------------------- # Create rooms branch if force or not root.has_key('Rooms'): root['Rooms'] = IOBTree() # Create reservations branch if force or not root.has_key('Reservations'): root['Reservations'] = IOBTree() # Create blocking branch if force or not root.has_key('RoomBlocking'): root['RoomBlocking'] = OOBTree() root['RoomBlocking']['Blockings'] = IOBTree() root['RoomBlocking']['Indexes'] = OOBTree() root['RoomBlocking']['Indexes']['OwnerBlockings'] = OOBTree() root['RoomBlocking']['Indexes']['DayBlockings'] = CalendarDayIndex() root['RoomBlocking']['Indexes']['RoomBlockings'] = OOBTree() # Create indexes if force or not root.has_key('RoomReservationsIndex'): root['RoomReservationsIndex'] = OOBTree() if force or not root.has_key('UserReservationsIndex'): root['UserReservationsIndex'] = OOBTree() if force or not root.has_key('DayReservationsIndex'): root['DayReservationsIndex'] = OOBTree() if force or not root.has_key('RoomDayReservationsIndex'): root['RoomDayReservationsIndex'] = OOBTree() # Create possible equipment branch if force or not root.has_key('EquipmentList'): root['EquipmentList'] = {} # update Catalog with new rb indexes Catalog.updateDB() DALManagerCERN().commit()
def connect2IndicoDB(): from MaKaC.plugins.RoomBooking.CERN.dalManagerCERN import DALManagerCERN from MaKaC.common.db import DBMgr DBMgr.getInstance().startRequest() DALManagerCERN.connect()