From 7326b1fb0d8c9c51ab07bc8e8470e100e78d80ab Mon Sep 17 00:00:00 2001 From: wanyaoqi Date: Mon, 24 Feb 2020 13:02:50 +0800 Subject: [PATCH 1/4] fix host init set reserve memory --- pkg/hostman/hostinfo/hostinfo.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkg/hostman/hostinfo/hostinfo.go b/pkg/hostman/hostinfo/hostinfo.go index 6904c2dd04..7f41393d4b 100644 --- a/pkg/hostman/hostinfo/hostinfo.go +++ b/pkg/hostman/hostinfo/hostinfo.go @@ -856,6 +856,9 @@ func (h *SHostInfo) updateHostRecord(hostId string) { h.onFail(err) } content.Set("mem_size", jsonutils.NewInt(int64(memTotal))) + if len(hostId) == 0 { + content.Set("mem_reserved", jsonutils.NewInt(int64(h.getReservedMem()))) + } content.Set("storage_driver", jsonutils.NewString(api.DISK_DRIVER_LINUX)) content.Set("storage_type", jsonutils.NewString(h.sysinfo.StorageType)) content.Set("storage_size", jsonutils.NewInt(int64(storageman.GetManager().GetTotalCapacity()))) From 92129824c0681ab91106b351bb98263c2c062657 Mon Sep 17 00:00:00 2001 From: wanyaoqi Date: Mon, 24 Feb 2020 16:00:55 +0800 Subject: [PATCH 2/4] fix guest network get desc --- pkg/compute/models/guestnetworks.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pkg/compute/models/guestnetworks.go b/pkg/compute/models/guestnetworks.go index c2b68fc225..1f1a61c8bb 100644 --- a/pkg/compute/models/guestnetworks.go +++ b/pkg/compute/models/guestnetworks.go @@ -372,9 +372,11 @@ func (self *SGuestnetwork) getJsonDescAtHost(host *SHost) jsonutils.JSONObject { func (self *SGuestnetwork) getJsonDescHostwire(network *SNetwork, hostwire *SHostwire) *jsonutils.JSONDict { desc := self.getJsonDesc(network) - desc.Add(jsonutils.NewString(hostwire.Bridge), "bridge") - desc.Add(jsonutils.NewString(hostwire.WireId), "wire_id") - desc.Add(jsonutils.NewString(hostwire.Interface), "interface") + if hostwire != nil { + desc.Add(jsonutils.NewString(hostwire.Bridge), "bridge") + desc.Add(jsonutils.NewString(hostwire.WireId), "wire_id") + desc.Add(jsonutils.NewString(hostwire.Interface), "interface") + } return desc } From d4ba5ca52ea543eb00588b658ff212ef750edbcc Mon Sep 17 00:00:00 2001 From: wanyaoqi Date: Mon, 24 Feb 2020 16:36:44 +0800 Subject: [PATCH 3/4] fix host register get network filter: add server_type baremetal --- pkg/hostman/hostinfo/hostinfo.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/hostman/hostinfo/hostinfo.go b/pkg/hostman/hostinfo/hostinfo.go index 7f41393d4b..a6fba6ba74 100644 --- a/pkg/hostman/hostinfo/hostinfo.go +++ b/pkg/hostman/hostinfo/hostinfo.go @@ -705,6 +705,7 @@ func (h *SHostInfo) fetchAccessNetworkInfo() { params := jsonutils.NewDict() params.Set("ip", jsonutils.NewString(masterIp)) params.Set("is_on_premise", jsonutils.JSONTrue) + params.Set("server_type", jsonutils.NewString(api.NETWORK_TYPE_BAREMETAL)) params.Set("limit", jsonutils.NewInt(0)) res, err := modules.Networks.List(h.GetSession(), params) From c99265e743f9ddbd9d2c836c72d61ee681479879 Mon Sep 17 00:00:00 2001 From: wanyaoqi Date: Tue, 25 Feb 2020 10:44:53 +0800 Subject: [PATCH 4/4] makesure /etc/ceph created before connect --- pkg/hostman/hostinfo/hostinfo.go | 1 - pkg/hostman/storageman/storage_rbd.go | 4 ++++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/hostman/hostinfo/hostinfo.go b/pkg/hostman/hostinfo/hostinfo.go index a6fba6ba74..7f41393d4b 100644 --- a/pkg/hostman/hostinfo/hostinfo.go +++ b/pkg/hostman/hostinfo/hostinfo.go @@ -705,7 +705,6 @@ func (h *SHostInfo) fetchAccessNetworkInfo() { params := jsonutils.NewDict() params.Set("ip", jsonutils.NewString(masterIp)) params.Set("is_on_premise", jsonutils.JSONTrue) - params.Set("server_type", jsonutils.NewString(api.NETWORK_TYPE_BAREMETAL)) params.Set("limit", jsonutils.NewInt(0)) res, err := modules.Networks.List(h.GetSession(), params) diff --git a/pkg/hostman/storageman/storage_rbd.go b/pkg/hostman/storageman/storage_rbd.go index 1e9f9e596d..27dbe41dfa 100644 --- a/pkg/hostman/storageman/storage_rbd.go +++ b/pkg/hostman/storageman/storage_rbd.go @@ -59,6 +59,10 @@ type SRbdStorage struct { func NewRBDStorage(manager *SStorageManager, path string) *SRbdStorage { var ret = new(SRbdStorage) ret.SBaseStorage = *NewBaseStorage(manager, path) + err := procutils.NewRemoteCommandAsFarAsPossible("mkdir", "-p", "/etc/ceph").Run() + if err != nil { + log.Errorf("Failed to mkdir /etc/ceph: %s", err) + } return ret }