diff --git a/pkg/hostman/host_services.go b/pkg/hostman/host_services.go index 32f6db280a..fe23bc98c0 100644 --- a/pkg/hostman/host_services.go +++ b/pkg/hostman/host_services.go @@ -26,7 +26,6 @@ import ( "yunion.io/x/onecloud/pkg/hostman/downloader" "yunion.io/x/onecloud/pkg/hostman/guestfs/fsdriver" "yunion.io/x/onecloud/pkg/hostman/guestman" - "yunion.io/x/onecloud/pkg/hostman/guestman/desc" "yunion.io/x/onecloud/pkg/hostman/guestman/guesthandlers" "yunion.io/x/onecloud/pkg/hostman/hostdeployer/deployclient" "yunion.io/x/onecloud/pkg/hostman/hosthandler" @@ -35,7 +34,6 @@ import ( "yunion.io/x/onecloud/pkg/hostman/hostmetrics" "yunion.io/x/onecloud/pkg/hostman/hostutils" "yunion.io/x/onecloud/pkg/hostman/kubehandlers" - "yunion.io/x/onecloud/pkg/hostman/metadata" "yunion.io/x/onecloud/pkg/hostman/options" "yunion.io/x/onecloud/pkg/hostman/storageman" "yunion.io/x/onecloud/pkg/hostman/storageman/diskhandlers" @@ -125,19 +123,6 @@ func (host *SHostService) RunService() { host.initHandlers(app) - // Init Metadata handler - go metadata.Start( - app_common.InitApp(&options.HostOptions.BaseOptions, false), - &metadata.Service{ - Address: options.HostOptions.Address, - Port: options.HostOptions.Port + 1000, - DescGetter: metadata.DescGetterFunc(func(ip string) *desc.SGuestDesc { - guestDesc, _ := guestman.GetGuestManager().GetGuestNicDesc("", ip, "", "", false) - return guestDesc - }), - }, - ) - { cronManager.AddJobEveryFewDays( "CleanRecycleDiskFiles", 1, 3, 0, 0, storageman.CleanRecycleDiskfiles, false) diff --git a/pkg/hostman/metadata/metadatahandler.go b/pkg/hostman/metadata/metadatahandler.go index 69ec5e6c62..32ee08fb6d 100644 --- a/pkg/hostman/metadata/metadatahandler.go +++ b/pkg/hostman/metadata/metadatahandler.go @@ -135,7 +135,10 @@ func (s *Service) metaData(ctx context.Context, w http.ResponseWriter, r *http.R "ami-launch-index", "block-device-mapping/", "hostname", "instance-id", "instance-type", - "local-hostname", "local-ipv4", "mac", + "local-hostname", + "local-ipv4", + "local-ipv6", + "mac", "public-hostname", "public-ipv4", "network_config/", "local-sub-ipv4s", @@ -173,9 +176,12 @@ func (s *Service) metaData(ctx context.Context, w http.ResponseWriter, r *http.R return } } - case "hostname", "public-hostname", "local-hostname": + case "hostname": hostutils.Response(ctx, w, guestDesc.Name) return + case "public-hostname", "local-hostname": + hostutils.Response(ctx, w, guestDesc.Hostname) + return case "instance-id": hostutils.Response(ctx, w, guestDesc.Uuid) return @@ -202,6 +208,16 @@ func (s *Service) metaData(ctx context.Context, w http.ResponseWriter, r *http.R } hostutils.Response(ctx, w, strings.Join(ips, "\n")) return + case "local-ipv6": + ips := make([]string, 0) + guestNics := guestDesc.Nics + for _, nic := range guestNics { + if len(nic.Ip6) > 0 { + ips = append(ips, nic.Ip6) + } + } + hostutils.Response(ctx, w, strings.Join(ips, "\n")) + return case "local-sub-ipv4s": ips := make([]string, 0) guestNics := guestDesc.Nics