mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
fix: host add public ip field (#20114)
Co-authored-by: Qiu Jian <qiujian@yunionyun.com>
This commit is contained in:
@@ -193,6 +193,10 @@ func init() {
|
||||
Sn string `help:"serial number"`
|
||||
|
||||
Hostname string `help:"update host name"`
|
||||
|
||||
PublicIp string `help:"public_ip"`
|
||||
|
||||
NoPublicIp bool `help:"clear public ip"`
|
||||
}
|
||||
R(&HostUpdateOptions{}, "host-update", "Update information of a host", func(s *mcclient.ClientSession, args *HostUpdateOptions) error {
|
||||
params := jsonutils.NewDict()
|
||||
@@ -242,6 +246,11 @@ func init() {
|
||||
}
|
||||
params.Add(jsonutils.NewBool(enableNumaAllocate), "enable_numa_allocate")
|
||||
}
|
||||
if len(args.PublicIp) > 0 {
|
||||
params.Add(jsonutils.NewString(args.PublicIp), "public_ip")
|
||||
} else if args.NoPublicIp {
|
||||
params.Add(jsonutils.NewString(""), "public_ip")
|
||||
}
|
||||
if params.Size() == 0 {
|
||||
return fmt.Errorf("Not data to update")
|
||||
}
|
||||
|
||||
@@ -296,6 +296,11 @@ type HostResourceInfo struct {
|
||||
|
||||
// 宿主机类型
|
||||
HostType string `json:"host_type"`
|
||||
|
||||
// 宿主机管理IP
|
||||
HostAccessIp string `json:"host_access_ip"`
|
||||
// 宿主机公网IP(如果有)
|
||||
HostEIP string `json:"host_eip"`
|
||||
}
|
||||
|
||||
type HostFilterListInput struct {
|
||||
@@ -355,6 +360,9 @@ type HostAccessAttributes struct {
|
||||
AccessNet string `json:"access_net"`
|
||||
// 物理机管理口二次网络
|
||||
AccessWire string `json:"access_wire"`
|
||||
|
||||
// 公网IP
|
||||
PublicIp *string `json:"public_ip"`
|
||||
}
|
||||
|
||||
type HostSizeAttributes struct {
|
||||
|
||||
@@ -188,6 +188,9 @@ type SGuest struct {
|
||||
PowerStates string `width:"36" charset:"ascii" nullable:"false" default:"unknown" list:"user" create:"optional"`
|
||||
// Used for guest rescue
|
||||
RescueMode bool `nullable:"false" default:"false" list:"user" create:"optional"`
|
||||
|
||||
// 上次开机时间
|
||||
LastStartAt time.Time `json:"last_start_at" list:"user"`
|
||||
}
|
||||
|
||||
func (manager *SGuestManager) GetPropertyStatistics(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject) (*apis.StatusStatistic, error) {
|
||||
@@ -6839,3 +6842,11 @@ func (guest *SGuest) getDisksCandidateHostIds() ([]string, error) {
|
||||
}
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func (guest *SGuest) SaveLastStartAt() error {
|
||||
_, err := db.Update(guest, func() error {
|
||||
guest.LastStartAt = time.Now().UTC()
|
||||
return nil
|
||||
})
|
||||
return errors.Wrap(err, "SaveLastStartAt")
|
||||
}
|
||||
|
||||
@@ -108,6 +108,8 @@ func (manager *SHostResourceBaseManager) FetchCustomizeColumns(
|
||||
rows[i].HostEnabled = host.Enabled.Bool()
|
||||
rows[i].HostServiceStatus = host.HostStatus
|
||||
rows[i].HostType = host.HostType
|
||||
rows[i].HostAccessIp = host.AccessIp
|
||||
rows[i].HostEIP = host.PublicIp
|
||||
rows[i].ManagerId = host.ManagerId
|
||||
rows[i].ZoneId = host.ZoneId
|
||||
}
|
||||
|
||||
@@ -209,6 +209,9 @@ type SHost struct {
|
||||
|
||||
// UEFI详情
|
||||
UefiInfo jsonutils.JSONObject `nullable:"true" get:"domain" update:"domain" create:"domain_optional"`
|
||||
|
||||
// 公网Ip地址
|
||||
PublicIp string `width:"16" charset:"ascii" nullable:"true" list:"domain" update:"domain"`
|
||||
}
|
||||
|
||||
func (manager *SHostManager) GetContextManagers() [][]db.IModelManager {
|
||||
|
||||
@@ -61,6 +61,8 @@ func (task *GuestStartTask) OnStartComplete(ctx context.Context, obj db.IStandal
|
||||
// save start mem and cpu
|
||||
guest.SetMetadata(ctx, api.VM_METADATA_START_VCPU_COUNT, guest.VcpuCount, task.UserCred)
|
||||
guest.SetMetadata(ctx, api.VM_METADATA_START_VMEM_MB, guest.VmemSize, task.UserCred)
|
||||
// save start time
|
||||
guest.SaveLastStartAt()
|
||||
// sync Vpc Topology
|
||||
isVpc, err := guest.IsOneCloudVpcNetwork()
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user