def filter_by_target(cls, target):
     if issubclass(target.downcast_class, ManagedMgs):
         result = ObjectCache.get(ManagedFilesystem,
                                  lambda mfs: mfs.mgs_id == target.id)
         return result
     elif issubclass(target.downcast_class, FilesystemMember):
         return ObjectCache.get(
             ManagedFilesystem,
             lambda mfs: mfs.id == target.downcast().filesystem_id)
     else:
         raise NotImplementedError(target.__class__)
 def get_steps(self):
     search = lambda cm: (cm.host == self.host and cm.state == 'mounted')
     mounted = ObjectCache.get(LustreClientMount, search)
     args = dict(host=self.host,
                 filesystems=[(m.filesystem.mount_path(), m.mountpoint)
                              for m in mounted])
     return [(UnmountLustreFilesystemsStep, args)]
Ejemplo n.º 3
0
 def dehydrate_client_mounts(self, bundle):
     from chroma_core.lib.cache import ObjectCache
     from chroma_core.models import LustreClientMount
     search = lambda cm: cm.host == bundle.obj
     mounts = ObjectCache.get(LustreClientMount, search)
     return [{'filesystem_name': mount.filesystem.name,
              'mountpoint': mount.mountpoint,
              'state': mount.state} for mount in mounts]
Ejemplo n.º 4
0
    def get_steps(self):
        from chroma_core.models import ServerProfile

        profiles = [(p.name, list(p.serverprofilevalidation_set.values())) for p in ObjectCache.get(ServerProfile)]

        return [
            (
                TestHostConnectionStep,
                {"address": self.address, "credentials_key": self.credentials_key, "profiles": profiles},
            )
        ]
    def get_deps(self):
        search = lambda ct: ct.host == self.copytool.host
        copytools = ObjectCache.get(Copytool, search)

        # Only force an unmount if this is the only copytool associated
        # with the host.
        if len(copytools) == 1:
            search = lambda cm: cm.id == self.copytool.client_mount_id
            client_mount = ObjectCache.get_one(LustreClientMount, search)
            return DependOn(client_mount, "unmounted")
        else:
            return DependAll()
    def can_run(cls, host):
        if not host.is_worker:
            return False

        search = lambda cm: (cm.host == host and cm.state == 'mounted')
        mounted = ObjectCache.get(LustreClientMount, search)
        return (host.state not in ['removed', 'undeployed', 'unconfigured']
                and len(mounted) > 0
                and not AlertState.filter_by_item(host).filter(
                    active=True,
                    alert_type__in=[
                        HostOfflineAlert.__name__, HostContactAlert.__name__
                    ]).exists())
Ejemplo n.º 7
0
    def get_steps(self):
        search = lambda cm: (cm.host == self.host and cm.state == "mounted")
        mounted = ObjectCache.get(LustreClientMount, search)
        args = {
            "host":
            self.host,
            "filesystems": [(
                ObjectCache.get_one(
                    ManagedFilesystem,
                    lambda mf, mtd=m: mf.name == mtd.filesystem).mount_path(),
                m.mountpoints,
            ) for m in mounted],
        }

        return [(UnmountLustreFilesystemsStep, args)]
 def filter_by_fs(fs):
     return ObjectCache.get(StratagemConfiguration, lambda sc, fs=fs: sc.filesystem.id == fs.id)