예제 #1
0
    def sync_owner_transact(self, vm):
        owner = self.context.__owner__
        parent = self.context.__parent__
        uuid = self.context.__name__

        # PUSH if owner is set and is modified, PULL only when OMS owner is not set
        if owner is not None:
            if vm.get('owner') != owner:
                log.msg('Attempting to push owner (%s) of %s to agent' % (owner, self.context),
                        system='sync')
                submitter = IVirtualizationContainerSubmitter(parent)
                d = submitter.submit(ISetOwner, uuid, owner)
                d.addCallback(lambda r: log.msg('Owner pushing for %s successful' % self.context,
                                                system='sync'))
                d.addErrback(log.err, system='sync')
        elif vm.get('owner'):
            compute = TmpObj(self.context)
            newowner = getUtility(IAuthentication).getPrincipal(vm['owner'])
            if newowner is not None:
                log.msg('Modifying ownership of "%s" from %s to %s.'
                        % (compute, owner, newowner), system='sync')
                compute.__owner__ = newowner
                with SuppressEvents(self.context):
                    compute.apply()
            else:
                log.msg('User not found: "%s" while restoring owner for %s. '
                        'Leaving as-is' % (vm['owner'], compute), system='sync')
예제 #2
0
    def sync_owner_transact(self, vm):
        owner = self.context.__owner__
        parent = self.context.__parent__
        uuid = self.context.__name__

        # PUSH if owner is set and is modified, PULL only when OMS owner is not set
        if owner is not None:
            if vm.get('owner') != owner:
                log.msg('Attempting to push owner (%s) of %s to agent' %
                        (owner, self.context),
                        system='sync')
                submitter = IVirtualizationContainerSubmitter(parent)
                d = submitter.submit(ISetOwner, uuid, owner)
                d.addCallback(lambda r: log.msg(
                    'Owner pushing for %s successful' % self.context,
                    system='sync'))
                d.addErrback(log.err, system='sync')
        elif vm.get('owner'):
            compute = TmpObj(self.context)
            newowner = getUtility(IAuthentication).getPrincipal(vm['owner'])
            if newowner is not None:
                log.msg('Modifying ownership of "%s" from %s to %s.' %
                        (compute, owner, newowner),
                        system='sync')
                compute.__owner__ = newowner
                with SuppressEvents(self.context):
                    compute.apply()
            else:
                log.msg('User not found: "%s" while restoring owner for %s. '
                        'Leaving as-is' % (vm['owner'], compute),
                        system='sync')
예제 #3
0
    def sync_owner_transact(self, vm):
        owner = self.context.__owner__
        parent = self.context.__parent__
        uuid = self.context.__name__

        if vm.get('owner'):
            if owner != vm['owner']:
                compute = TmpObj(self.context)
                newowner = getUtility(IAuthentication).getPrincipal(vm['owner'])
                if newowner is not None:
                    compute.__owner__ = newowner
                    compute.apply()
                else:
                    log.msg('User not found: "%s" while restoring owner for %s. '
                            'Leaving as-is' % (vm['owner'], compute), system='sync')
        elif owner is not None:
            log.msg('Attempting to push owner (%s) of %s to agent' % (owner, self.context), system='sync')
            submitter = IVirtualizationContainerSubmitter(parent)
            d = submitter.submit(ISetOwner, uuid, owner)
            d.addCallback(lambda r: log.msg('Owner pushing for %s successful' % self.context, system='sync'))
            d.addErrback(log.err, system='sync')
예제 #4
0
 def pull_owner():
     compute = TmpObj(self.context)
     newowner = getUtility(IAuthentication).getPrincipal(vm['owner'])
     compute.__owner__ = newowner
     compute.apply()