def updateMemberDescription(i): """ All the information is updated and the initial MDL for the user is created and stored. """ _printAction (i, "Generate and store member description for the local node") filename = 'local-tmp.mdl' from descriptionprocessor import getMemberDescriptionProcessor mdl = getMemberDescriptionProcessor().generateLocalMdl("0.0.0.0", 4) # should generate version number 1.0.0.0 getMemberDescriptionProcessor().applyMdl(mdl) _finishActionLine()
def installNewCommunity(i, localMemberId): """ We should have at least one community at the beginning. This community here every node is a member of. This way, any new node is able to connect to community authorities of certain communinties using this tc. """ _printAction (i, "Initialise community database with one initial entry",1) from communitymanager import getCommunityManager from communitymanager import Community ## from config import init_tcid ## community = Community(init_tcid, "G4DS Startup", "StartUp service", "", "", "2005-07-05") from config import default_tcdl, default_mdls from descriptionprocessor import getCommunityDescriptionProcessor, getMemberDescriptionProcessor # it's a bit of a funny construction - has to be done like this due to back referencing between communties and members # that's how it works: # 1. The MDLs are applied without relations # 2. The TCDL is applied without relations # 3. The MDLs are applied including relations # 4. The TCDL is applied including relations _printAction (i+1, "Initialise temporary entries for back referencing",1) for mdl in default_mdls: file = open(mdl, 'r') content = file.read() if getMemberDescriptionProcessor().processMdl(content)['id'] != localMemberId: member = getMemberDescriptionProcessor().applyMdl(content, includingRelations = 0) _printAction(i+2, "Adding temporare member '" + member.getId() + "' (authority) to system and community.") _finishActionLine() file.close() _printAction (i+1, "Members temporaly added.") _finishActionLine() file = open(default_tcdl, 'r') tcdl = file.read() community = getCommunityDescriptionProcessor().applyTcdl(tcdl, includingRelations = 0) file.close() _printAction (i+1, "Preparing new Community '" + community.getName() + "'",1) for mdl in default_mdls: file = open(mdl, 'r') content = file.read() if getMemberDescriptionProcessor().processMdl(content)['id'] != localMemberId: member = getMemberDescriptionProcessor().applyMdl(content) _printAction (i+2, "Adding member '" + member.getId() + "' (authority) to system and community.") _finishActionLine() file.close() _printAction(i+1, "Community prepared.") _finishActionLine() _printAction(i+1, "Apply community description and add members") community = getCommunityDescriptionProcessor().applyTcdl(tcdl, includingRelations = 1) try: community.addMember(localMemberId, 0, 1) except ValueError: pass # that's fine and only happens to the authorities of the communities since they have been added to the tc before ## community.addMember(localMemberId, 1, 1) _finishActionLine() _printAction (i+2, "Add local member to the community") _finishActionLine() _printAction (i+1, "Finshed new Community '" + community.getName() + "'") _finishActionLine() communityid = community.getId() _printAction(i, "Finished community database") _finishActionLine() return communityid