// Convert Openstack request to kubernetes pod request body
// Revisit this for dynamically generate the json request
// TODO: post the initial support, consider push down this logic to the create handler to support other media types than Json
Convert Openstack request to kubernetes pod request body
Revisit this for dynamically generate the json request
TODO: post the initial support, consider push down this logic to the create handler to support other media types than Json
// Convert Openstack request to kubernetes pod request body // Revisit this for dynamically generate the json request // TODO : post the initial support consider push down this logic to the create handler to support other media types than Json
func ConvertServerFromOpenstackRequest(body []byte) ([]byte, error) {
	obj := OpenstackServerRequest{}
	err := json.Unmarshal(body, &obj)
	if err != nil {
		klog.Errorf("error unmarshal request. error %v", err)
		return nil, err
	}
	flavor, err := GetFalvor(obj.Server.Flavor)
	if err != nil {
		return nil, err
	}
	image, err := GetImage(obj.Server.ImageRef)
	if err != nil {
		return nil, err
	}
	var ret []byte
	if IsBatchCreationRequest(obj) {
		replicas := obj.Min_count
		ret, err = constructReplicasetRequestBody(replicas, obj.Server, image.ImageRef, flavor.Vcpus, flavor.MemoryMb)
	} else {
		ret, err = constructVmPodRequestBody(obj.Server, image.ImageRef, flavor.Vcpus, flavor.MemoryMb)
	}
	if err != nil {
		klog.Errorf("failed to construct request body. error: %v", err)
		return nil, err
	}
	return ret, nil
}
func ConvertServerFromOpenstackRequest ( body [ ] byte ) ( [ ] byte , error ) { obj := OpenstackServerRequest { } err := json . Unmarshal ( body , & obj ) if err != nil { klog . Errorf ( " " , err ) return nil , err } flavor , err := GetFalvor ( obj . Server . Flavor ) if err != nil { return nil , err } image , err := GetImage ( obj . Server . ImageRef ) if err != nil { return nil , err } var ret [ ] byte if IsBatchCreationRequest ( obj ) { replicas := obj . Min_count ret , err = constructReplicasetRequestBody ( replicas , obj . Server , image . ImageRef , flavor . Vcpus , flavor . MemoryMb ) } else { ret , err = constructVmPodRequestBody ( obj . Server , image . ImageRef , flavor . Vcpus , flavor . MemoryMb ) } if err != nil { klog . Errorf ( " " , err ) return nil , err } return ret , nil }
Convert Openstack request to kubernetes pod request body
Revisit this for dynamically generate the json request
TODO: post the initial support, consider push down this logic to the create handler to support other media types than Json
Convert Openstack request to kubernetes pod request body Revisit this for dynamically generate the json request TODO : post the initial support consider push down this logic to the create handler to support other media types than Json