var system=require("../../system")
var settings=require("../../../config/settings");
const CtlBase = require("../ctl.base");
const uuidv4 = require('uuid/v4');
class ContainerCtl extends CtlBase{
   constructor(){
     super(CtlBase.getServiceName(ContainerCtl));
     //this.appS=system.getObject("service.appSve");
   }

   async initNewInstance(queryobj,qobj){
     var u=uuidv4();
     var aid=u.replace(/\-/g,"");
     var rd={name:"",appid:aid}
     return system.getResult2(rd,null);
   }
   async createData(queryobj,pobj,req){
     console.log("createData****************");
     //TODO:创建容器脚本==，成功后赋值status
     var containerItem={
       name:pobj.name+"-容器",
       mirrorinfo_id:pobj.id
       // machine_id:==机器档案id
       // status:==0停用，1启动
     };
    var result= await  this.service.create(containerItem);
    return system.getResult2(result,null);
   }
   async createWork(queryobj,pobj,req){
     console.log("createWork****************");
     if(pobj.status==1){
       pobj.status='0';
     }else{
       pobj.status='1';
     }
     pobj.version+=1;
     await this.service.update(pobj);
     //TODO:创建容器启动或停用脚本==，成功后赋值status，status状态为：0停用，1启动

     var result={

     }
     return system.getResult2(result,null);
   }
}
module.exports=ContainerCtl;
