mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-19 10:46:58 +08:00
Merge pull request #7202 from yousong/bugfix/yousong-lbagent-deploy
Bugfix/yousong lbagent deploy
This commit is contained in:
@@ -114,6 +114,8 @@ func (lbagent *SLoadbalancerAgent) deploy(ctx context.Context, userCred mcclient
|
||||
}
|
||||
switch input.DeployMethod {
|
||||
case compute_apis.DeployMethodYum:
|
||||
fallthrough
|
||||
default:
|
||||
if v, ok := input.Host.GetVar("repo_base_url"); !ok || v == "" {
|
||||
return nil, httperrors.NewBadRequestError("use yum requires valid repo_base_url")
|
||||
}
|
||||
@@ -142,8 +144,6 @@ func (lbagent *SLoadbalancerAgent) deploy(ctx context.Context, userCred mcclient
|
||||
},
|
||||
)
|
||||
case compute_apis.DeployMethodCopy:
|
||||
fallthrough
|
||||
default:
|
||||
// glob for rpms
|
||||
basenames := []string{
|
||||
"packages/telegraf",
|
||||
@@ -275,6 +275,22 @@ func (lbagent *SLoadbalancerAgent) validateHost(ctx context.Context, userCred mc
|
||||
if utils.IsInStringArray(guest.Hypervisor, compute_apis.PUBLIC_CLOUD_HYPERVISORS) {
|
||||
return httperrors.NewBadRequestError("lbagent cannot be deployed on public guests")
|
||||
}
|
||||
if guest.Status != compute_apis.VM_RUNNING {
|
||||
return httperrors.NewBadRequestError("server is in %q state, want %q",
|
||||
guest.Status, compute_apis.VM_RUNNING)
|
||||
}
|
||||
|
||||
// Better make this explicit in the API
|
||||
if guest.SrcIpCheck.Bool() || guest.SrcMacCheck.Bool() {
|
||||
sess := auth.GetSession(ctx, userCred, "", "")
|
||||
params := jsonutils.NewDict()
|
||||
params.Set("src_ip_check", jsonutils.JSONFalse)
|
||||
params.Set("src_mac_check", jsonutils.JSONFalse)
|
||||
_, err := mcclient_modules.Servers.PerformAction(sess, guest.Id, "modify-src-check", params)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "turn off src check of guest %s(%s)", guest.Name, guest.Id)
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -150,7 +150,7 @@ type LoadbalancerAgentActionDeployOptions struct {
|
||||
ID string `json:"-"`
|
||||
|
||||
Host string `help:"name or id of the server in format '<[server:]id|host:id>|ipaddr var=val'" json:"-"`
|
||||
DeployMethod string `help:"use yum repo or use file copy" choices:"yum|copy" default:"copy"`
|
||||
DeployMethod string `help:"use yum repo or use file copy" choices:"yum|copy" default:"yum"`
|
||||
}
|
||||
|
||||
func (opts *LoadbalancerAgentActionDeployOptions) Params() (*jsonutils.JSONDict, error) {
|
||||
|
||||
Reference in New Issue
Block a user