示例#1
0
 def put(self, name):
   if lxc.exists(name):
     parser = reqparse.RequestParser()
     parser.add_argument('state', type=str, required=True)
     newState = parser.parse_args()['state']
     oldState = lxc.info(name)['state:']
     if newState == oldState:
       return Response(status=204)
     else:
       if newState == 'RUNNING':
         if oldState == 'STOPPED':
           lxc.start(name)
         elif oldState == 'FROZEN':
           lxc.start(name)
       elif newState == 'STOPPED':
         lxc.stop(name)
       elif newState == 'FROZEN':
         lxc.freeze(name)
       return lxc.info(name)
   else:
     abort(404)
示例#2
0
 def delete(self, name):
   if lxc.exists(name):
     lxc.destroy(name)
     return Response(status=204)
   else:
     abort(404)
示例#3
0
 def get(self, name):
   if lxc.exists(name):
     state = lxc.info(name)['state:']
     return state
   else:
     abort(404)
示例#4
0
 def get(self, name):
   if lxc.exists(name):
     container = lxc.info(name)
     return container
   else:
     abort(404)