// CreateContainer create a new container
CreateContainer create a new container
// CreateContainer create a new container
func CreateContainer(w http.ResponseWriter, r *http.Request) *apiError {
	var opts APIOptions
	err := json.NewDecoder(r.Body).Decode(&opts)
	if err != nil {
		return &apiError{err, err.Error(), 400}
	}
	c, err := lxc.NewContainer(opts.Name, lxcpath)
	if err != nil {
		return &apiError{err, err.Error(), 500}
	}
	defer c.Release()
	if err := c.Create(opts.TemplateOpts); err != nil {
		return &apiError{err, err.Error(), 500}
	}
	if opts.Start == "yes" {
		if err := c.Start(); err != nil {
			return &apiError{err, err.Error(), 500}
		}
	}
	jsonResp := &HTTPClientResp{
		Status:  "success",
		Message: "container created"}
	js, _ := json.Marshal(jsonResp)
	w.Header().Set("Content-Type", "application/json")
	w.WriteHeader(http.StatusOK)
	w.Write([]byte(string(js)))
	return nil
}
func CreateContainer ( w http . ResponseWriter , r * http . Request ) * apiError { var opts APIOptions err := json . NewDecoder ( r . Body ) . Decode ( & opts ) if err != nil { return & apiError { err , err . Error ( ) , 400 } } c , err := lxc . NewContainer ( opts . Name , lxcpath ) if err != nil { return & apiError { err , err . Error ( ) , 500 } } defer c . Release ( ) if err := c . Create ( opts . TemplateOpts ) ; err != nil { return & apiError { err , err . Error ( ) , 500 } } if opts . Start == " " { if err := c . Start ( ) ; err != nil { return & apiError { err , err . Error ( ) , 500 } } } jsonResp := & HTTPClientResp { Status : " " , Message : " " } js , _ := json . Marshal ( jsonResp ) w . Header ( ) . Set ( " " , " " ) w . WriteHeader ( http . StatusOK ) w . Write ( [ ] byte ( string ( js ) ) ) return nil }
CreateContainer create a new container
CreateContainer create a new container