Beispiel #1
0
 def delete_group(self, id):
     ctx = self.currentContext
     if self.isprofile(id):
         grp = DyngroupDatabase().get_group(ctx, id, True)
         profile_UUID = grp.getUUID()
         ComputerProfileManager().delProfile(profile_UUID)
     return xmlrpcCleanup(DyngroupDatabase().delete_group(ctx, id))
Beispiel #2
0
 def get_group(self, id, ro=False, root_context=False):
     grp = DyngroupDatabase().get_group(self.getContext(), id)
     if grp.type == 2:
         _group_user = DyngroupDatabase()._get_group_user(grp.parent_id)
         ctx = self.getContext(user=_group_user)
     else:
         ctx = root_context and self.getContext() or self.currentContext
     grp = DyngroupDatabase().get_group(ctx, id, ro)
     if grp:
         return xmlrpcCleanup(grp.toH())
     return xmlrpcCleanup(False)
Beispiel #3
0
def checkPool():
    ret = True
    try :
        pool = DyngroupDatabase().db.pool
        if pool._max_overflow > -1 and pool._overflow >= pool._max_overflow :
            logging.getLogger().error('dyngroup plugin: CHECK: NOK: timeout then overflow (%d vs. %d) detected in SQL pool : check your network connectivity !' % (pool._overflow, pool._max_overflow))
            pool.dispose()
            pool = pool.recreate()
            ret = False
    except Exception, e:
        logging.getLogger().warn('dyngroup plugin: CHECK: NOK: got the following error : %s' % (e))
        ret = False
Beispiel #4
0
    def update_machine_cache(self):
        ctx = self.currentContext
        dyndatabase = DyngroupDatabase()

        cache = dyndatabase.getAllMachinesUuid()
        machines = ComputerManager().getRestrictedComputersList(ctx, 0, -1, {'uuids':cache.keys()}, False, False, True)

        need_update = {}
        for m in machines:
            if m['hostname'] != cache[m['uuid']]:
                need_update[m['uuid']] = m['hostname']

        dyndatabase.updateNewNames(need_update)
        return len(need_update)
Beispiel #5
0
class DyngroupComputers(ComputerI):
    # don't know how to do something else than delComputer.
    def __init__(self, conffile = None):
        self.logger = logging.getLogger()
        self.dyngroup = DyngroupDatabase()

    def getComputer(self, ctx, filt = None):
        return {}

    def getMachineMac(self, ctx, filt): # TODO : need to sort!
        return None

    def getMachineIp(self, ctx, filt): # TODO : need to sort!
        return None

    def getComputersNetwork(self, ctx, filt):
        return None

    def getComputersList(self, ctx, filt = None):
        return []

    def getRestrictedComputersListLen(self, ctx, filt = {}):
        #Mutable dict filt used as default argument to a method or function
        return 0

    def getRestrictedComputersList(self, ctx, min = 0, max = -1, filt = {}, advanced = True, justId = False, toH = False):
        #Mutable dict filt used as default argument to a method or function
        return []

    def getComputerCount(self, ctx, filt = None):
        return 0

    def canAddComputer(self):
        return False

    def canAssociateComputer2Location(self):
        return False
        
    def addComputer(self, ctx, params):
        return -1
    
    def neededParamsAddComputer(self):
        return []

    def canDelComputer(self):
        return True

    def delComputer(self, ctx, uuid, backup):
        return self.dyngroup.delMachine(uuid)

    def getComputersListHeaders(self, ctx):
        return []
Beispiel #6
0
 def share_with(self, id):
     ctx = self.currentContext
     return xmlrpcCleanup(DyngroupDatabase().share_with(ctx, id))
Beispiel #7
0
 def del_share(self, id, shares):
     ctx = self.currentContext
     return xmlrpcCleanup(DyngroupDatabase().del_share(ctx, id, shares))
Beispiel #8
0
 def set_profile_imaging_server(self, gid, imaging_uuid):
     if not self.isprofile(gid):
         return False
     dyndatabase = DyngroupDatabase()
     ret = dyndatabase.setProfileImagingServer(gid, imaging_uuid)
     return xmlrpcCleanup(ret)
Beispiel #9
0
 def countallprofiles(self, params):  #NEW
     ctx = self.currentContext
     count = DyngroupDatabase().countallgroups(ctx, params, 1)
     return count
Beispiel #10
0
def _get_convergence_deploy_group_id_and_user(cmd_id):
    return DyngroupDatabase()._get_convergence_deploy_group_id_and_user(cmd_id)
Beispiel #11
0
 def group_name_exists(self, name, gid=None):
     #TODO possible risks of collision betwen share/group/profiles...
     ctx = self.currentContext
     return DyngroupDatabase().groupNameExists(ctx, name, gid)
Beispiel #12
0
 def setbool_group(self, id, bool):
     ctx = self.currentContext
     return xmlrpcCleanup(DyngroupDatabase().setbool_group(ctx, id, bool))
Beispiel #13
0
 def set_profile_entity(self, gid, entity_uuid):
     if not self.isprofile(gid):
         return False
     dyndatabase = DyngroupDatabase()
     ret = dyndatabase.setProfileEntity(gid, entity_uuid)
     return xmlrpcCleanup(ret)
Beispiel #14
0
 def setvisibility_group(self, id, visibility):
     ctx = self.currentContext
     return xmlrpcCleanup(DyngroupDatabase().setvisibility_group(
         ctx, id, visibility))
Beispiel #15
0
 def setrequest_group(self, id, request):
     ctx = self.currentContext
     return xmlrpcCleanup(DyngroupDatabase().setrequest_group(
         ctx, id, request))
Beispiel #16
0
 def setname_group(self, id, name):
     ctx = self.currentContext
     return xmlrpcCleanup(DyngroupDatabase().setname_group(ctx, id, name))
Beispiel #17
0
 def create_profile(self, name, visibility):  #NEW
     ctx = self.currentContext
     return xmlrpcCleanup(DyngroupDatabase().create_group(
         ctx, name, visibility, 1))
Beispiel #18
0
 def get_group(self, id, ro=False):
     ctx = self.currentContext
     grp = DyngroupDatabase().get_group(ctx, id, ro)
     if grp:
         return xmlrpcCleanup(grp.toH())
     return xmlrpcCleanup(False)
Beispiel #19
0
 def can_edit(self, id):
     ctx = self.currentContext
     return xmlrpcCleanup(DyngroupDatabase().can_edit(ctx, id))
Beispiel #20
0
 def getallgroups(self, params):
     ctx = self.currentContext
     groups = DyngroupDatabase().getallgroups(ctx, params)
     return xmlrpcCleanup(map(lambda g: g.toH(), groups))
Beispiel #21
0
 def set_profile_imaging_server(self, gid, imaging_uuid):
     if not self.isprofile(gid):
         return False
     dyndatabase = DyngroupDatabase()
     ret = dyndatabase.setProfileImagingServer(gid, imaging_uuid)
     return xmlrpcCleanup(ret)
Beispiel #22
0
 def getmachineprofile(self, id):  #NEW
     ctx = self.currentContext
     profile = DyngroupDatabase().getMachineProfile(ctx, id)
     return xmlrpcCleanup(profile)
Beispiel #23
0
def _get_convergence_phases(cmd_id, deploy_group_id):
    return DyngroupDatabase()._get_convergence_phases(cmd_id, deploy_group_id)
Beispiel #24
0
 def countallgroups(self, params):
     ctx = self.currentContext
     count = DyngroupDatabase().countallgroups(ctx, params)
     return count
Beispiel #25
0
 def requestresult_group(self, id, start, end, filter):
     ctx = self.currentContext
     return xmlrpcCleanup(DyngroupDatabase().requestresult_group(
         ctx, id, start, end, filter, queryManager))
Beispiel #26
0
 def profile_name_exists(self, name, gid=None):
     ctx = self.currentContext
     return DyngroupDatabase().groupNameExists(ctx, name, gid, True)
Beispiel #27
0
 def __init__(self, conffile = None):
     self.logger = logging.getLogger()
     self.dyngroup = DyngroupDatabase()
Beispiel #28
0
 def countresult_group(self, id, filter):
     ctx = self.currentContext
     return xmlrpcCleanup(DyngroupDatabase().countresult_group(
         ctx, id, filter))
Beispiel #29
0
 def get_group(self, id, ro=False, root_context=False):
     ctx = root_context and self.getContext() or self.currentContext
     grp = DyngroupDatabase().get_group(ctx, id, ro)
     if grp:
         return xmlrpcCleanup(grp.toH())
     return xmlrpcCleanup(False)
Beispiel #30
0
 def todyn_group(self, id):
     ctx = self.currentContext
     return xmlrpcCleanup(DyngroupDatabase().todyn_group(ctx, id))
Beispiel #31
0
 def isrequest_group(self, id):
     ctx = self.currentContext
     return xmlrpcCleanup(DyngroupDatabase().isrequest_group(ctx, id))
Beispiel #32
0
 def isprofile(self, id):  #NEW
     ctx = self.currentContext
     return xmlrpcCleanup(DyngroupDatabase().isprofile(ctx, id))
Beispiel #33
0
 def set_profile_entity(self, gid, entity_uuid):
     if not self.isprofile(gid):
         return False
     dyndatabase = DyngroupDatabase()
     ret = dyndatabase.setProfileEntity(gid, entity_uuid)
     return xmlrpcCleanup(ret)
Beispiel #34
0
 def arePartOfAProfile(self, uuids):
     ctx = self.currentContext
     return DyngroupDatabase().arePartOfAProfile(ctx, uuids)