예제 #1
0
 def before_delete(self, cname, backup):
     for disktype in (JBoxVol.JBP_USERHOME, JBoxVol.JBP_PKGBUNDLE, JBoxVol.JBP_DATA, JBoxVol.JBP_CONFIG):
         disk = VolMgr.get_disk_from_container(self.dockid, disktype)
         if disk is not None:
             disk.release(backup=backup)
     if cname is not None:
         SessContainer.PINGS.pop(cname, None)
예제 #2
0
 def before_delete(self, cname, backup):
     for disktype in (JBoxVol.JBP_USERHOME, JBoxVol.JBP_PKGBUNDLE,
                      JBoxVol.JBP_DATA, JBoxVol.JBP_CONFIG):
         disk = VolMgr.get_disk_from_container(self.dockid, disktype)
         if disk is not None:
             disk.release(backup=backup)
     if cname is not None:
         SessContainer.PINGS.pop(cname, None)
예제 #3
0
    def create_user_script(cont):
        vol = VolMgr.get_disk_from_container(cont.dockid, JBoxVol.JBP_USERHOME)

        pub_key_file = os.path.join(vol.disk_path, ".ssh", "id_rsa.pub")
        with open(pub_key_file, 'r') as f:
            pub_key = f.read()

        auth_key_file = "/home/juser/.ssh/authorized_keys"
        template = '#! /usr/bin/env bash\n\njulia -e 0\nsudo -u juser sh -c "echo \\\"%s\\\" >> %s && chmod 600 %s"'
        return template % (pub_key, auth_key_file, auth_key_file)
예제 #4
0
    def _write_machinefile(self, cont, filename, machines):
        cluster_hosts = set(machines)
        if len(cluster_hosts) == 0:
            return

        # write out the machinefile on the docker's filesystem
        vol = VolMgr.get_disk_from_container(cont.dockid, JBoxVol.JBP_USERHOME)
        machinefile = os.path.join(vol.disk_path, ".juliabox", filename)

        existing_hosts = set()
        try:
            with open(machinefile, 'r') as f:
                existing_hosts = set([x.rstrip('\n') for x in f.readlines()])
        except:
            pass

        if cluster_hosts == existing_hosts:
            return

        self.log_debug("writing machinefile for %s to path: %s", cont.debug_str(), machinefile)
        with open(machinefile, 'w') as f:
            for host in cluster_hosts:
                f.write(host+'\n')
예제 #5
0
 def get_disk_space_used(self):
     disk = VolMgr.get_disk_from_container(self.dockid, JBoxVol.JBP_USERHOME)
     if disk is not None:
         return disk.get_disk_space_used()
     return 0
예제 #6
0
 def get_disk_allocated(self):
     disk = VolMgr.get_disk_from_container(self.dockid, JBoxVol.JBP_USERHOME)
     if disk is not None:
         return disk.get_disk_allocated_size()
     return 0
예제 #7
0
 def get_disk_space_used(self):
     disk = VolMgr.get_disk_from_container(self.dockid,
                                           JBoxVol.JBP_USERHOME)
     if disk is not None:
         return disk.get_disk_space_used()
     return 0
예제 #8
0
 def get_disk_allocated(self):
     disk = VolMgr.get_disk_from_container(self.dockid,
                                           JBoxVol.JBP_USERHOME)
     if disk is not None:
         return disk.get_disk_allocated_size()
     return 0