Merge pull request 'update vmInfo' (#202) from master-wq into master
Former-commit-id: cf388c3e00931a8871a3691e9d330fcc54cbef48
This commit is contained in:
commit
c3a6190fa1
|
@ -170,6 +170,8 @@ type VmInfo struct {
|
|||
DeleteOnTermination bool `json:"delete_on_termination,omitempty"`
|
||||
Status string `json:"Status,omitempty"`
|
||||
StartTime string `json:"startTime,omitempty"`
|
||||
platform string `json:"platform,omitempty"`
|
||||
VmName string `json:"vm_name,omitempty"`
|
||||
}
|
||||
|
||||
type ResourceStats struct {
|
||||
|
|
|
@ -224,14 +224,8 @@ type (
|
|||
ImageRef int64 `json:"imageRef,optional"`
|
||||
FlavorRef int64 `json:"flavorRef,optional"`
|
||||
Uuid int64 `json:"uuid,optional"`
|
||||
//Replicas int64 `json:"replicas,string"`
|
||||
Replicas int32 `json:"replicas,string"`
|
||||
VmName string `json:"vm_name,optional"`
|
||||
// Replicas int64 `json:"replicas,optional"`
|
||||
// MatchLabels map[string]string `json:"matchLabels,optional"`
|
||||
// ClusterType string `json:"clusterType,optional"`
|
||||
// //Virtual Machine Section
|
||||
//CreateMulServer []CreateMulDomainServer `json:"createMulServer,optional"`
|
||||
//VmOption *VmOption `json:"vmOption,optional"`
|
||||
}
|
||||
TaskVm {
|
||||
Image string `json:"image"`
|
||||
|
|
|
@ -52,11 +52,11 @@ func (l *CommitVmTaskLogic) CommitVmTask(req *types.CommitVmTaskReq) (resp *type
|
|||
}()
|
||||
//TODO adapter
|
||||
adapterId, _ := strconv.ParseUint(req.AdapterIds[0], 10, 64)
|
||||
var clusters []*models.VmModel
|
||||
err2 := l.svcCtx.DbEngin.Raw("SELECT * FROM `t_cluster` where adapter_id in ? and id in ?", req.AdapterIds, req.ClusterIds).Scan(&clusters).Error
|
||||
/*var clusters []*models.VmModel
|
||||
err2 := l.svcCtx.DbEngin.Raw("SELECT * FROM `t_cluster` where adapter_id in ? and id in ?", adapterId, req.ClusterIds).Scan(&clusters).Error
|
||||
if err2 != nil {
|
||||
logx.Errorf("CommitGeneralTask() => sql execution error: %v", err)
|
||||
}
|
||||
}*/
|
||||
taskVm := models.TaskVm{}
|
||||
//TODO 执行策略返回集群跟 Replica
|
||||
opt := &option.VmOption{}
|
||||
|
@ -115,9 +115,10 @@ func (l *CommitVmTaskLogic) CommitVmTask(req *types.CommitVmTaskReq) (resp *type
|
|||
logx.Error(err)
|
||||
return nil, txVm.Error
|
||||
}
|
||||
if err2 != nil {
|
||||
logx.Errorf("CommitGeneralTask() => sql execution error: %v", err)
|
||||
}
|
||||
/* if err2 != nil {
|
||||
logx.Errorf("CommitGeneralTask() => sql execution error: %v", err)
|
||||
//return errors.Errorf("the cluster does not match the drive resources. Check the data"), nil
|
||||
}*/
|
||||
taskVm.Name = req.VmName
|
||||
taskVm.Status = "Saved"
|
||||
taskVm.StartTime = time.Now().String()
|
||||
|
|
|
@ -12,7 +12,7 @@ type VmOption struct {
|
|||
ClusterToStaticWeight map[string]int32
|
||||
CommitTime time.Time
|
||||
NsID string
|
||||
Replicas int64
|
||||
Replicas int32
|
||||
MatchLabels map[string]string
|
||||
StaticWeightMap map[string]int32
|
||||
CreateMulServer []CreateMulDomainServer
|
||||
|
|
|
@ -53,10 +53,6 @@ func (vm *VmScheduler) PickOptimalStrategy() (strategy.Strategy, error) {
|
|||
return nil, err
|
||||
}*/
|
||||
|
||||
/* if len(resources) == 0 {
|
||||
return nil, errors.New("no cluster has resources")
|
||||
}*/
|
||||
//
|
||||
//if len(resources) == 1 {
|
||||
// var cluster strategy.AssignedCluster
|
||||
// cluster.ClusterId = resources[0].ClusterId
|
||||
|
@ -75,19 +71,18 @@ func (vm *VmScheduler) PickOptimalStrategy() (strategy.Strategy, error) {
|
|||
return strategy, nil
|
||||
case strategy.RESOURCES_PRICING:
|
||||
strategy := strategy.NewPricingStrategy(¶m.ResourcePricingParams{Params: params, Replicas: 1})
|
||||
return strategy, nil
|
||||
case strategy.DYNAMIC_RESOURCES:
|
||||
strategy := strategy.NewDynamicResourcesStrategy(params.Resources, vm.option, 1)
|
||||
return strategy, nil*/
|
||||
/* case strategy.DYNAMIC_RESOURCES:
|
||||
strategy := strategy.NewDynamicResourcesStrategy(params.Resources, vm.option, 1)
|
||||
return strategy, nil*/
|
||||
case strategy.STATIC_WEIGHT:
|
||||
//todo resources should match cluster StaticWeightMap
|
||||
strategy := strategy.NewStaticWeightStrategy(vm.option.StaticWeightMap, 1)
|
||||
return strategy, nil
|
||||
case strategy.RANDOM:
|
||||
strategy := strategy.NewRandomStrategy(vm.option.ClusterIds, vm.option.Replicas)
|
||||
return strategy, nil
|
||||
}
|
||||
|
||||
/*strategy := strategy.NewPricingStrategy(¶m.ResourcePricingParams{})
|
||||
return strategy, nil*/
|
||||
|
||||
return nil, errors.New("no strategy has been chosen")
|
||||
}
|
||||
|
||||
|
|
|
@ -202,6 +202,7 @@ type CommitVmTaskReq struct {
|
|||
ImageRef int64 `json:"imageRef,optional"`
|
||||
FlavorRef int64 `json:"flavorRef,optional"`
|
||||
Uuid int64 `json:"uuid,optional"`
|
||||
Replicas int32 `json:"replicas,string"`
|
||||
VmName string `json:"vm_name,optional"`
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue