Ejemplo n.º 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))
Ejemplo n.º 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)
Ejemplo n.º 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
Ejemplo n.º 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)
Ejemplo n.º 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 []
Ejemplo n.º 6
0
 def share_with(self, id):
     ctx = self.currentContext
     return xmlrpcCleanup(DyngroupDatabase().share_with(ctx, id))
Ejemplo n.º 7
0
 def del_share(self, id, shares):
     ctx = self.currentContext
     return xmlrpcCleanup(DyngroupDatabase().del_share(ctx, id, shares))
Ejemplo n.º 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)
Ejemplo n.º 9
0
 def countallprofiles(self, params):  #NEW
     ctx = self.currentContext
     count = DyngroupDatabase().countallgroups(ctx, params, 1)
     return count
Ejemplo n.º 10
0
def _get_convergence_deploy_group_id_and_user(cmd_id):
    return DyngroupDatabase()._get_convergence_deploy_group_id_and_user(cmd_id)
Ejemplo n.º 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)
Ejemplo n.º 12
0
 def setbool_group(self, id, bool):
     ctx = self.currentContext
     return xmlrpcCleanup(DyngroupDatabase().setbool_group(ctx, id, bool))
Ejemplo n.º 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)
Ejemplo n.º 14
0
 def setvisibility_group(self, id, visibility):
     ctx = self.currentContext
     return xmlrpcCleanup(DyngroupDatabase().setvisibility_group(
         ctx, id, visibility))
Ejemplo n.º 15
0
 def setrequest_group(self, id, request):
     ctx = self.currentContext
     return xmlrpcCleanup(DyngroupDatabase().setrequest_group(
         ctx, id, request))
Ejemplo n.º 16
0
 def setname_group(self, id, name):
     ctx = self.currentContext
     return xmlrpcCleanup(DyngroupDatabase().setname_group(ctx, id, name))
Ejemplo n.º 17
0
 def create_profile(self, name, visibility):  #NEW
     ctx = self.currentContext
     return xmlrpcCleanup(DyngroupDatabase().create_group(
         ctx, name, visibility, 1))
Ejemplo n.º 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)
Ejemplo n.º 19
0
 def can_edit(self, id):
     ctx = self.currentContext
     return xmlrpcCleanup(DyngroupDatabase().can_edit(ctx, id))
Ejemplo n.º 20
0
 def getallgroups(self, params):
     ctx = self.currentContext
     groups = DyngroupDatabase().getallgroups(ctx, params)
     return xmlrpcCleanup(map(lambda g: g.toH(), groups))
Ejemplo n.º 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)
Ejemplo n.º 22
0
 def getmachineprofile(self, id):  #NEW
     ctx = self.currentContext
     profile = DyngroupDatabase().getMachineProfile(ctx, id)
     return xmlrpcCleanup(profile)
Ejemplo n.º 23
0
def _get_convergence_phases(cmd_id, deploy_group_id):
    return DyngroupDatabase()._get_convergence_phases(cmd_id, deploy_group_id)
Ejemplo n.º 24
0
 def countallgroups(self, params):
     ctx = self.currentContext
     count = DyngroupDatabase().countallgroups(ctx, params)
     return count
Ejemplo n.º 25
0
 def requestresult_group(self, id, start, end, filter):
     ctx = self.currentContext
     return xmlrpcCleanup(DyngroupDatabase().requestresult_group(
         ctx, id, start, end, filter, queryManager))
Ejemplo n.º 26
0
 def profile_name_exists(self, name, gid=None):
     ctx = self.currentContext
     return DyngroupDatabase().groupNameExists(ctx, name, gid, True)
Ejemplo n.º 27
0
 def __init__(self, conffile = None):
     self.logger = logging.getLogger()
     self.dyngroup = DyngroupDatabase()
Ejemplo n.º 28
0
 def countresult_group(self, id, filter):
     ctx = self.currentContext
     return xmlrpcCleanup(DyngroupDatabase().countresult_group(
         ctx, id, filter))
Ejemplo n.º 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)
Ejemplo n.º 30
0
 def todyn_group(self, id):
     ctx = self.currentContext
     return xmlrpcCleanup(DyngroupDatabase().todyn_group(ctx, id))
Ejemplo n.º 31
0
 def isrequest_group(self, id):
     ctx = self.currentContext
     return xmlrpcCleanup(DyngroupDatabase().isrequest_group(ctx, id))
Ejemplo n.º 32
0
 def isprofile(self, id):  #NEW
     ctx = self.currentContext
     return xmlrpcCleanup(DyngroupDatabase().isprofile(ctx, id))
Ejemplo n.º 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)
Ejemplo n.º 34
0
 def arePartOfAProfile(self, uuids):
     ctx = self.currentContext
     return DyngroupDatabase().arePartOfAProfile(ctx, uuids)