mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-19 10:46:58 +08:00
fix: recode host.getWiresOfId
This commit is contained in:
@@ -8,12 +8,13 @@ import (
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/log"
|
||||
"yunion.io/x/pkg/utils"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/db/taskman"
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
"yunion.io/x/onecloud/pkg/compute/models"
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/util/billing"
|
||||
"yunion.io/x/pkg/utils"
|
||||
)
|
||||
|
||||
type SAwsGuestDriver struct {
|
||||
|
||||
@@ -7,12 +7,13 @@ import (
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/log"
|
||||
"yunion.io/x/pkg/utils"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/db/taskman"
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
"yunion.io/x/onecloud/pkg/compute/models"
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/util/billing"
|
||||
"yunion.io/x/pkg/utils"
|
||||
)
|
||||
|
||||
type SHuaweiGuestDriver struct {
|
||||
|
||||
@@ -7,6 +7,8 @@ import (
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/log"
|
||||
"yunion.io/x/pkg/util/compare"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/db/lockman"
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/db/taskman"
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
@@ -15,7 +17,6 @@ import (
|
||||
"yunion.io/x/onecloud/pkg/httperrors"
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/util/billing"
|
||||
"yunion.io/x/pkg/util/compare"
|
||||
)
|
||||
|
||||
type SOpenStackGuestDriver struct {
|
||||
|
||||
@@ -247,12 +247,23 @@ func (self *SGuestnetwork) GetTeamGuestnetwork() (*SGuestnetwork, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
|
||||
func (self *SGuestnetwork) getJsonDescAtHost(host *SHost) jsonutils.JSONObject {
|
||||
desc := jsonutils.NewDict()
|
||||
|
||||
func (self *SGuestnetwork) getJsonDescAtBaremetal(host *SHost) jsonutils.JSONObject {
|
||||
network := self.GetNetwork()
|
||||
hostwire := host.getHostwireOfIdAndMac(network.WireId, self.MacAddr)
|
||||
return self.getGeneralJsonDesc(host, network, hostwire)
|
||||
}
|
||||
|
||||
func (self *SGuestnetwork) getJsonDescAtHost(host *SHost) jsonutils.JSONObject {
|
||||
network := self.GetNetwork()
|
||||
hostwires := host.getHostwiresOfId(network.WireId)
|
||||
if len(hostwires) > 1 {
|
||||
log.Warningf("host attach to wire multiple times: %d", len(hostwires))
|
||||
}
|
||||
return self.getGeneralJsonDesc(host, network, &hostwires[0])
|
||||
}
|
||||
|
||||
func (self *SGuestnetwork) getGeneralJsonDesc(host *SHost, network *SNetwork, hostwire *SHostwire) jsonutils.JSONObject {
|
||||
desc := jsonutils.NewDict()
|
||||
|
||||
desc.Add(jsonutils.NewString(network.Name), "net")
|
||||
desc.Add(jsonutils.NewString(self.NetworkId), "net_id")
|
||||
|
||||
@@ -1101,9 +1101,7 @@ func (self *SHost) getHostwireOfIdAndMac(wireId string, mac string) *SHostwire {
|
||||
hostwire.SetModelManager(HostwireManager)
|
||||
|
||||
q := self.GetWiresQuery().Equals("wire_id", wireId)
|
||||
if q.Count() > 1 {
|
||||
q = q.Equals("mac_addr", mac)
|
||||
}
|
||||
q = q.Equals("mac_addr", mac)
|
||||
err := q.First(&hostwire)
|
||||
if err != nil {
|
||||
log.Errorf("getHostwireOfIdAndMac fail %s", err)
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
"yunion.io/x/log"
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/db"
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"github.com/yunionio/pkg/util/regutils"
|
||||
"yunion.io/x/pkg/util/regutils"
|
||||
)
|
||||
|
||||
type SNetInterface struct {
|
||||
@@ -173,7 +173,7 @@ func (self *SNetInterface) getServerJsonDesc() *jsonutils.JSONDict {
|
||||
desc := jsonutils.Marshal(self).(*jsonutils.JSONDict)
|
||||
gn := self.getServernetwork()
|
||||
if gn != nil {
|
||||
desc.Update(gn.getJsonDescAtHost(self.GetBaremetal()))
|
||||
desc.Update(gn.getJsonDescAtBaremetal(self.GetBaremetal()))
|
||||
}
|
||||
return desc
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -17,7 +18,6 @@ import (
|
||||
"yunion.io/x/pkg/utils"
|
||||
"yunion.io/x/sqlchemy"
|
||||
|
||||
"strconv"
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/db"
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/db/lockman"
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/db/taskman"
|
||||
@@ -1474,8 +1474,8 @@ func (manager *SNetworkManager) ListItemFilter(ctx context.Context, q *sqlchemy.
|
||||
vpcs := VpcManager.Query().SubQuery()
|
||||
sq := wires.Query(wires.Field("id")).
|
||||
Join(vpcs, sqlchemy.AND(
|
||||
sqlchemy.Equals(vpcs.Field("cloudregion_id"), region.GetId()),
|
||||
sqlchemy.Equals(wires.Field("vpc_id"), vpcs.Field("id"))))
|
||||
sqlchemy.Equals(vpcs.Field("cloudregion_id"), region.GetId()),
|
||||
sqlchemy.Equals(wires.Field("vpc_id"), vpcs.Field("id"))))
|
||||
q = q.Filter(sqlchemy.In(q.Field("wire_id"), sq.SubQuery()))
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ type ComputeOptions struct {
|
||||
DefaultSecurityRules string `help:"Default security rules" default:"allow any"`
|
||||
DefaultAdminSecurityRules string `help:"Default admin security rules" default:""`
|
||||
|
||||
DefaultDiskSizeMB int `default:"10240" help:"Default disk size in MB if not specified, default to 30GiB" json:"default_disk_size"`
|
||||
DefaultDiskSizeMB int `default:"10240" help:"Default disk size in MB if not specified, default to 10GiB" json:"default_disk_size"`
|
||||
|
||||
pending_delete.SPendingDeleteOptions
|
||||
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
package storagedrivers // import "yunion.io/x/onecloud/pkg/compute/storagedrivers"
|
||||
@@ -36,7 +36,7 @@ func ParseMac(macStr string) (SMacAddr, error) {
|
||||
func (mac SMacAddr) Add(step int) SMacAddr {
|
||||
mac2 := SMacAddr{}
|
||||
leftOver := step
|
||||
for i := 5; i >= 2; i -= 1 { // skip first 2 vendor bytes
|
||||
for i := 5; i >= 0; i -= 1 { // skip first 2 vendor bytes
|
||||
newByte := int(mac[i]) + leftOver
|
||||
res := 0
|
||||
if newByte < 0 {
|
||||
|
||||
Reference in New Issue
Block a user