// Convert the action request to Arktos action request body
Convert the action request to Arktos action request body
// Convert the action request to Arktos action request body
func ConvertActionFromOpenstackRequest(body []byte) ([]byte, error) {
	op := getActionOperation(body)
	klog.V(6).Infof("Convert %s Action", op)
	switch op {
	case REBOOT:
		obj := ArktosReboot{"v1", "CustomAction", op, ArktosRebootParams{10}}
		return json.Marshal(obj)
	case SNAPSHOT:
		o := OpenstackCreateImageRequest{}
		err := json.Unmarshal(body, &o)
		if err != nil {
			return nil, fmt.Errorf("invalid snapshot request. error %v", err)
		}
		obj := ArktosSnapshot{"v1", "CustomAction", op, ArktosSnapshotParams{o.Snapshot.Name}}
		return json.Marshal(obj)
	case RESTORE:
		o := OpenstackRebuildRequest{}
		err := json.Unmarshal(body, &o)
		if err != nil {
			return nil, fmt.Errorf("invalid restore request. error %v", err)
		}
		obj := ArktosRestore{"v1", "CustomAction", op, ArktosRestoreParams{o.Restore.ImageRef}}
		return json.Marshal(obj)
	default:
		return nil, ERROR_UNKNOWN_ACTION
	}
}
func ConvertActionFromOpenstackRequest ( body [ ] byte ) ( [ ] byte , error ) { op := getActionOperation ( body ) klog . V ( 6 ) . Infof ( " " , op ) switch op { case REBOOT : obj := ArktosReboot { " " , " " , op , ArktosRebootParams { 10 } } return json . Marshal ( obj ) case SNAPSHOT : o := OpenstackCreateImageRequest { } err := json . Unmarshal ( body , & o ) if err != nil { return nil , fmt . Errorf ( " " , err ) } obj := ArktosSnapshot { " " , " " , op , ArktosSnapshotParams { o . Snapshot . Name } } return json . Marshal ( obj ) case RESTORE : o := OpenstackRebuildRequest { } err := json . Unmarshal ( body , & o ) if err != nil { return nil , fmt . Errorf ( " " , err ) } obj := ArktosRestore { " " , " " , op , ArktosRestoreParams { o . Restore . ImageRef } } return json . Marshal ( obj ) default : return nil , ERROR_UNKNOWN_ACTION } }
Convert the action request to Arktos action request body
Convert the action request to Arktos action request body