Exemplo n.º 1
0
    def stop_vnode(self, request, context):
        logger.info('stop vnode with config: ' + str(request))
        taskid = request.taskid
        username = request.username
        vnodeid = request.vnodeid
        brname = request.vnode.network.brname
        mount_list = request.vnode.mount
        lxcname = '%s-batch-%s-%s' % (username,taskid,str(vnodeid))

        logger.info("Stop the task with lxc:"+lxcname)
        container = lxc.Container(lxcname)
        if container.stop():
            logger.info("stop container %s success" % lxcname)
        else:
            logger.error("stop container %s failed" % lxcname)

        #umount oss
        self.umount_oss("/var/lib/lxc/%s/oss" % (lxcname), mount_list)

        logger.info("deleting container:%s" % lxcname)
        if self.imgmgr.deleteFS(lxcname):
            logger.info("delete container %s success" % lxcname)
        else:
            logger.error("delete container %s failed" % lxcname)

        #del ovs bridge
        if brname is not None:
            netcontrol.del_bridge(brname)

        #release gpu
        self.release_gpu_device(lxcname)

        return rpc_pb2.Reply(status=rpc_pb2.Reply.ACCEPTED,message="")
Exemplo n.º 2
0
    def stop_vnode(self, request, context):
        logger.info('stop vnode with config: ' + str(request))
        taskid = request.taskid
        username = request.username
        vnodeid = request.vnodeid
        brname = request.vnode.network.brname
        mount_list = request.vnode.mount
        lxcname = '%s-batch-%s-%s' % (username,taskid,str(vnodeid))

        logger.info("Stop the task with lxc:"+lxcname)
        container = lxc.Container(lxcname)
        if container.stop():
            logger.info("stop container %s success" % lxcname)
        else:
            logger.error("stop container %s failed" % lxcname)

        #umount oss
        self.umount_oss("/var/lib/lxc/%s/oss" % (lxcname), mount_list)

        logger.info("deleting container:%s" % lxcname)
        if self.imgmgr.deleteFS(lxcname):
            logger.info("delete container %s success" % lxcname)
        else:
            logger.error("delete container %s failed" % lxcname)

        #del ovs bridge
        if brname is not None:
            netcontrol.del_bridge(brname)

        #release gpu
        self.release_gpu_device(lxcname)

        return rpc_pb2.Reply(status=rpc_pb2.Reply.ACCEPTED,message="")
Exemplo n.º 3
0
 def del_usrgwbr(self, username, uid, nodemgr):
     if username not in self.usrgws.keys():
         return [False, "user does't have gateway or user doesn't exist."]
     ip = self.usrgws[username]
     logger.info("Delete user %s(%s) gateway on %s" %(username, str(uid), ip))
     if ip == self.masterip:
         netcontrol.del_gw('docklet-br-'+str(uid), username)
         netcontrol.del_bridge('docklet-br-'+str(uid))
     else:
         worker = nodemgr.ip_to_rpc(ip)
         worker.del_gw('docklet-br-'+str(uid), username)
         worker.del_bridge('docklet-br-'+str(uid))
     del self.usrgws[username]
     self.etcd.delkey("network/usrgws/"+username)
     return [True, 'delete user\' gateway success']
Exemplo n.º 4
0
 def remove_tasknet(self, task):
     taskid = task.id
     username = task.username
     brname = "docklet-batch-%s-%s" % (username, taskid)
     netcontrol.del_bridge(brname)
Exemplo n.º 5
0
 def remove_tasknet(self, task):
     taskid = task.id
     username = task.username
     brname = "docklet-batch-%s-%s"%(username, taskid)
     netcontrol.del_bridge(brname)