Merge pull request #1002 in YUNIONIO/onecloud from ~QIUJIAN/onecloud:feature/qj-network-type-pxe-ipmi to release/2.6.0

* commit '6f8ce3b32d99a95ce867f079be19e3cdff1fd138':
  feature: 1. change SERVER_TYPE_* to NETWORK_TYpE_* 2. add NETWORK_TYPE_PXE and NETWORK_TYPE_IPMI specifically for baremetal PXE and IPMI network allocation
This commit is contained in:
邱剑
2019-01-30 22:20:08 +08:00
25 changed files with 108 additions and 78 deletions
+3 -3
View File
@@ -17,7 +17,7 @@ func init() {
Wire string `help:"search networks belongs to a wire" json:"-"`
Vpc string `help:"search networks belongs to a VPC"`
Region string `help:"search networks belongs to a CloudRegion" json:"cloudregion"`
ServerType string `help:"search networks belongs to a ServerType"`
ServerType string `help:"search networks belongs to a ServerType" choices:"guest|baremetal|container|pxe|ipmi"`
Private *bool `help:"show private cloud networks only" json:"is_private"`
Public *bool `help:"show public cloud networks only" json:"is_public"`
}
@@ -43,7 +43,7 @@ func init() {
ID string `help:"ID or Name of zone to update"`
Name string `help:"Name of zone"`
Desc string `metavar:"<DESCRIPTION>" help:"Description"`
ServerType string `help:"server type," choices:"baremetal|guest|container"`
ServerType string `help:"server type," choices:"baremetal|guest|container|pxe|ipmi"`
StartIp string `help:"Start ip"`
EndIp string `help:"end ip"`
NetMask int64 `help:"Netmask"`
@@ -185,7 +185,7 @@ func init() {
Gateway string `help:"Default gateway"`
VlanId int64 `help:"Vlan ID" default:"1"`
AllocPolicy string `help:"Address allocation policy" choices:"none|stepdown|stepup|random"`
ServerType string `help:"Server type" choices:"baremetal|guest|container"`
ServerType string `help:"Server type" choices:"baremetal|guest|container|pxe|ipmi"`
Desc string `help:"Description" metavar:"DESCRIPTION"`
}
R(&NetworkCreateOptions{}, "network-create", "Create a virtual network", func(s *mcclient.ClientSession, args *NetworkCreateOptions) error {
+9 -5
View File
@@ -697,6 +697,7 @@ func (b *SBaremetalInstance) InitAdminNetif(
cliMac net.HardwareAddr,
netConf *types.SNetworkConfig,
nicType string,
netType string,
) error {
// start prepare task
// sync status to PREPARE
@@ -717,9 +718,9 @@ func (b *SBaremetalInstance) InitAdminNetif(
if err != nil {
return err
}
return b.postAttachWire(cliMac, nicType)
return b.postAttachWire(cliMac, nicType, netType)
} else if nic.IpAddr == "" {
return b.postAttachWire(cliMac, nicType)
return b.postAttachWire(cliMac, nicType, netType)
}
return nil
}
@@ -751,7 +752,7 @@ func (b *SBaremetalInstance) attachWire(mac net.HardwareAddr, wireId string, nic
return modules.Hosts.PerformAction(session, b.GetId(), "add-netif", params)
}
func (b *SBaremetalInstance) postAttachWire(mac net.HardwareAddr, nicType string) error {
func (b *SBaremetalInstance) postAttachWire(mac net.HardwareAddr, nicType string, netType string) error {
ipAddr := ""
if nicType == types.NIC_TYPE_IPMI {
oldIPMIConf := b.GetRawIPMIConfig()
@@ -759,14 +760,14 @@ func (b *SBaremetalInstance) postAttachWire(mac net.HardwareAddr, nicType string
ipAddr = oldIPMIConf.IpAddr
}
}
desc, err := b.enableWire(mac, ipAddr, nicType)
desc, err := b.enableWire(mac, ipAddr, nicType, netType)
if err != nil {
return err
}
return b.SaveDesc(desc)
}
func (b *SBaremetalInstance) enableWire(mac net.HardwareAddr, ipAddr string, nicType string) (jsonutils.JSONObject, error) {
func (b *SBaremetalInstance) enableWire(mac net.HardwareAddr, ipAddr string, nicType string, netType string) (jsonutils.JSONObject, error) {
session := b.manager.GetClientSession()
params := jsonutils.NewDict()
params.Add(jsonutils.NewString(mac.String()), "mac")
@@ -779,6 +780,9 @@ func (b *SBaremetalInstance) enableWire(mac net.HardwareAddr, ipAddr string, nic
if nicType == types.NIC_TYPE_IPMI {
params.Add(jsonutils.NewString("stepup"), "alloc_dir") // alloc bottom up
}
if len(netType) > 0 {
params.Add(jsonutils.NewString(netType), "net_type")
}
log.Errorf("enable net if params: %s", params.String())
return modules.Hosts.PerformAction(session, b.GetId(), "enable-netif", params)
}
+3 -2
View File
@@ -11,6 +11,7 @@ import (
o "yunion.io/x/onecloud/pkg/baremetal/options"
"yunion.io/x/onecloud/pkg/cloudcommon/dhcp"
"yunion.io/x/onecloud/pkg/cloudcommon/types"
"yunion.io/x/onecloud/pkg/compute/models"
"yunion.io/x/onecloud/pkg/mcclient/modules"
)
@@ -163,7 +164,7 @@ func (h *DHCPHandler) fetchConfig() (*dhcp.ResponseConfig, error) {
h.baremetalInstance = bmInstance
ipmiNic := h.baremetalInstance.GetIPMINic(h.ClientMac)
if ipmiNic != nil && ipmiNic.Mac == h.ClientMac.String() {
err = h.baremetalInstance.InitAdminNetif(h.ClientMac, h.netConfig, types.NIC_TYPE_IPMI)
err = h.baremetalInstance.InitAdminNetif(h.ClientMac, h.netConfig, types.NIC_TYPE_IPMI, models.NETWORK_TYPE_IPMI)
if err != nil {
return nil, err
}
@@ -274,7 +275,7 @@ func (h *DHCPHandler) doInitBaremetalAdminNetif(desc jsonutils.JSONObject) error
if err != nil {
return err
}
err = h.baremetalInstance.InitAdminNetif(h.ClientMac, h.netConfig, types.NIC_TYPE_ADMIN)
err = h.baremetalInstance.InitAdminNetif(h.ClientMac, h.netConfig, types.NIC_TYPE_ADMIN, models.NETWORK_TYPE_PXE)
return err
}
+1 -1
View File
@@ -79,7 +79,7 @@ type IBaremetalInstance interface {
GetIPMINic(cliMac net.HardwareAddr) *types.SNic
GetPXEDHCPConfig(arch uint16) (*dhcp.ResponseConfig, error)
GetDHCPConfig(cliMac net.HardwareAddr) (*dhcp.ResponseConfig, error)
InitAdminNetif(cliMac net.HardwareAddr, netConf *types.SNetworkConfig, nicType string) error
InitAdminNetif(cliMac net.HardwareAddr, netConf *types.SNetworkConfig, nicType string, netType string) error
RegisterNetif(cliMac net.HardwareAddr, netConf *types.SNetworkConfig) error
GetTFTPResponse() string
}
+1 -1
View File
@@ -11,7 +11,7 @@ import (
type SSharableVirtualResourceBase struct {
SVirtualResourceBase
IsPublic bool `default:"false" nullable:"false" index:"true" create:"admin_optional" list:"user"`
IsPublic bool `default:"false" nullable:"false" index:"true" create:"admin_optional" list:"user" update:"admin"`
}
type SSharableVirtualResourceBaseManager struct {
+8 -4
View File
@@ -105,7 +105,7 @@ func (self *SBaremetalGuestDriver) GetNamedNetworkConfiguration(guest *models.SG
}
func (self *SBaremetalGuestDriver) GetRandomNetworkTypes() []string {
return []string{models.SERVER_TYPE_BAREMETAL}
return []string{models.NETWORK_TYPE_BAREMETAL, models.NETWORK_TYPE_GUEST}
}
func (self *SBaremetalGuestDriver) Attach2RandomNetwork(guest *models.SGuest, ctx context.Context, userCred mcclient.TokenCredential, host *models.SHost, netConfig *models.SNetworkConfig, pendingUsage quotas.IQuota) error {
@@ -113,6 +113,10 @@ func (self *SBaremetalGuestDriver) Attach2RandomNetwork(guest *models.SGuest, ct
netsAvaiable := make([]models.SNetwork, 0)
netifIndexs := make(map[string]*models.SNetInterface, 0)
netTypes := guest.GetDriver().GetRandomNetworkTypes()
if len(netConfig.NetType) > 0 {
netTypes = []string{netConfig.NetType}
}
var wirePattern *regexp.Regexp
if len(netConfig.Wire) > 0 {
wirePattern = regexp.MustCompile(netConfig.Wire)
@@ -130,9 +134,9 @@ func (self *SBaremetalGuestDriver) Attach2RandomNetwork(guest *models.SGuest, ct
}
var net *models.SNetwork
if netConfig.Private {
net, _ = wire.GetCandidatePrivateNetwork(userCred, netConfig.Exit, models.SERVER_TYPE_BAREMETAL)
net, _ = wire.GetCandidatePrivateNetwork(userCred, netConfig.Exit, netTypes)
} else {
net, _ = wire.GetCandidatePublicNetwork(netConfig.Exit, models.SERVER_TYPE_BAREMETAL)
net, _ = wire.GetCandidatePublicNetwork(netConfig.Exit, netTypes)
}
if net != nil {
netsAvaiable = append(netsAvaiable, *net)
@@ -142,7 +146,7 @@ func (self *SBaremetalGuestDriver) Attach2RandomNetwork(guest *models.SGuest, ct
if len(netsAvaiable) == 0 {
return fmt.Errorf("No appropriate host virtual network...")
}
net := models.ChooseCandidateNetworks(netsAvaiable, netConfig.Exit, models.SERVER_TYPE_BAREMETAL)
net := models.ChooseCandidateNetworks(netsAvaiable, netConfig.Exit, netTypes)
if net != nil {
netif := netifIndexs[net.Id]
return guest.Attach2Network(ctx, userCred, net, pendingUsage, "", netif.Mac, netConfig.Driver, netConfig.BwLimit, netConfig.Vip, netif.Index, false, models.IPAllocationStepup, false, "")
+1 -1
View File
@@ -173,5 +173,5 @@ func (self *SContainerDriver) RequestRebuildRootDisk(ctx context.Context, guest
}
func (self *SContainerDriver) GetRandomNetworkTypes() []string {
return []string{models.SERVER_TYPE_CONTAINER, models.SERVER_TYPE_GUEST}
return []string{models.NETWORK_TYPE_CONTAINER, models.NETWORK_TYPE_GUEST}
}
+7 -20
View File
@@ -38,7 +38,7 @@ func (self *SVirtualizedGuestDriver) GetNamedNetworkConfiguration(guest *models.
}
func (self *SVirtualizedGuestDriver) GetRandomNetworkTypes() []string {
return []string{models.SERVER_TYPE_GUEST}
return []string{models.NETWORK_TYPE_GUEST}
}
func (self *SVirtualizedGuestDriver) Attach2RandomNetwork(guest *models.SGuest, ctx context.Context, userCred mcclient.TokenCredential, host *models.SHost, netConfig *models.SNetworkConfig, pendingUsage quotas.IQuota) error {
@@ -49,6 +49,9 @@ func (self *SVirtualizedGuestDriver) Attach2RandomNetwork(guest *models.SGuest,
hostwires := host.GetHostwires()
netsAvaiable := make([]models.SNetwork, 0)
netTypes := guest.GetDriver().GetRandomNetworkTypes()
if len(netConfig.NetType) > 0 {
netTypes = []string{netConfig.NetType}
}
for i := 0; i < len(hostwires); i += 1 {
hostwire := hostwires[i]
wire := hostwire.GetWire()
@@ -67,19 +70,9 @@ func (self *SVirtualizedGuestDriver) Attach2RandomNetwork(guest *models.SGuest,
var net *models.SNetwork
if netConfig.Private {
for _, netType := range netTypes {
net, _ = wire.GetCandidatePrivateNetwork(userCred, netConfig.Exit, netType)
if net != nil {
break
}
}
net, _ = wire.GetCandidatePrivateNetwork(userCred, netConfig.Exit, netTypes)
} else {
for _, netType := range netTypes {
net, _ = wire.GetCandidatePublicNetwork(netConfig.Exit, netType)
if net != nil {
break
}
}
net, _ = wire.GetCandidatePublicNetwork(netConfig.Exit, netTypes)
}
if net != nil {
netsAvaiable = append(netsAvaiable, *net)
@@ -88,13 +81,7 @@ func (self *SVirtualizedGuestDriver) Attach2RandomNetwork(guest *models.SGuest,
if len(netsAvaiable) == 0 {
return fmt.Errorf("No appropriate host virtual network...")
}
var selNet *models.SNetwork
for _, netType := range netTypes {
selNet = models.ChooseCandidateNetworks(netsAvaiable, netConfig.Exit, netType)
if selNet != nil {
break
}
}
selNet := models.ChooseCandidateNetworks(netsAvaiable, netConfig.Exit, netTypes)
if selNet == nil {
return fmt.Errorf("Not enough address in virtual network")
}
+1 -1
View File
@@ -541,7 +541,7 @@ func (self *SHost) BorrowIpAddrsFromGuest(ctx context.Context, userCred mcclient
return fmt.Errorf(msg)
}
err = self.EnableNetif(ctx, userCred, netif, "", guestnics[i].IpAddr, "", false, false)
err = self.EnableNetif(ctx, userCred, netif, "", guestnics[i].IpAddr, "", "", false, false)
if err != nil {
log.Errorf("fail to enable netif %s %s", guestnics[i].IpAddr, err)
return err
+16 -6
View File
@@ -2884,7 +2884,7 @@ func (self *SHost) addNetif(ctx context.Context, userCred mcclient.TokenCredenti
}
}
if len(ipAddr) > 0 {
err = self.EnableNetif(ctx, userCred, netif, "", ipAddr, "", reserve, requireDesignatedIp)
err = self.EnableNetif(ctx, userCred, netif, "", ipAddr, "", "", reserve, requireDesignatedIp)
if err != nil {
return httperrors.NewBadRequestError(err.Error())
}
@@ -2911,16 +2911,17 @@ func (self *SHost) PerformEnableNetif(ctx context.Context, userCred mcclient.Tok
network, _ := data.GetString("network")
ipAddr, _ := data.GetString("ip_addr")
allocDir, _ := data.GetString("alloc_dir")
netType, _ := data.GetString("net_type")
reserve := jsonutils.QueryBoolean(data, "reserve", false)
requireDesignatedIp := jsonutils.QueryBoolean(data, "require_designated_ip", false)
err := self.EnableNetif(ctx, userCred, netif, network, ipAddr, allocDir, reserve, requireDesignatedIp)
err := self.EnableNetif(ctx, userCred, netif, network, ipAddr, allocDir, netType, reserve, requireDesignatedIp)
if err != nil {
return nil, httperrors.NewBadRequestError(err.Error())
}
return nil, nil
}
func (self *SHost) EnableNetif(ctx context.Context, userCred mcclient.TokenCredential, netif *SNetInterface, network, ipAddr, allocDir string, reserve, requireDesignatedIp bool) error {
func (self *SHost) EnableNetif(ctx context.Context, userCred mcclient.TokenCredential, netif *SNetInterface, network, ipAddr, allocDir string, netType string, reserve, requireDesignatedIp bool) error {
bn := netif.GetBaremetalNetwork()
if bn != nil {
return nil
@@ -2956,8 +2957,17 @@ func (self *SHost) EnableNetif(ctx context.Context, userCred mcclient.TokenCrede
return fmt.Errorf("Network %s not reacheable on mac %s", network, netif.Mac)
}
} else {
net, err = wire.GetCandidatePrivateNetwork(userCred, false, SERVER_TYPE_BAREMETAL)
if err != nil || net == nil {
var netTypes []string
if len(netType) > 0 && netType != NETWORK_TYPE_BAREMETAL {
netTypes = []string{netType, NETWORK_TYPE_BAREMETAL}
} else {
netTypes = []string{NETWORK_TYPE_BAREMETAL}
}
net, err = wire.GetCandidatePrivateNetwork(userCred, false, netTypes)
if err != nil {
return fmt.Errorf("fail to find network %s", err)
}
if net == nil {
return fmt.Errorf("No network found")
}
}
@@ -3454,7 +3464,7 @@ func (host *SHost) SyncHostExternalNics(ctx context.Context, userCred mcclient.T
for i := 0; i < len(enables); i += 1 {
netif := host.GetNetInterface(enables[i].GetMac())
err = host.EnableNetif(ctx, userCred, netif, "", enables[i].GetIpAddr(), "", false, true)
err = host.EnableNetif(ctx, userCred, netif, "", enables[i].GetIpAddr(), "", "", false, true)
if err != nil {
result.AddError(err)
} else {
+22 -8
View File
@@ -14,7 +14,6 @@ import (
"yunion.io/x/pkg/util/fileutils"
"yunion.io/x/pkg/util/netutils"
"yunion.io/x/pkg/util/regutils"
"yunion.io/x/pkg/util/sets"
"yunion.io/x/pkg/utils"
"yunion.io/x/sqlchemy"
@@ -33,9 +32,11 @@ const (
// # DEFAULT_BANDWIDTH = options.default_bandwidth
MAX_BANDWIDTH = 100000
SERVER_TYPE_GUEST = "guest"
SERVER_TYPE_BAREMETAL = "baremetal"
SERVER_TYPE_CONTAINER = "container"
NETWORK_TYPE_GUEST = "guest"
NETWORK_TYPE_BAREMETAL = "baremetal"
NETWORK_TYPE_CONTAINER = "container"
NETWORK_TYPE_PXE = "pxe"
NETWORK_TYPE_IPMI = "ipmi"
STATIC_ALLOC = "static"
@@ -54,6 +55,16 @@ const (
NETWORK_STATUS_DELETE_FAILED = "delete_failed"
)
var (
ALL_NETWORK_TYPES = []string{
NETWORK_TYPE_GUEST,
NETWORK_TYPE_BAREMETAL,
NETWORK_TYPE_CONTAINER,
NETWORK_TYPE_PXE,
NETWORK_TYPE_IPMI,
}
)
type IPAddlocationDirection string
const (
@@ -109,7 +120,7 @@ type SNetwork struct {
// IsChanged = Column(Boolean, nullable=False, default=False)
ServerType string `width:"16" charset:"ascii" nullable:"true" list:"user" update:"user" create:"optional"` // Column(VARCHAR(16, charset='ascii'), nullable=True)
ServerType string `width:"16" charset:"ascii" default:"guest" nullable:"true" list:"user" update:"user" create:"optional"` // Column(VARCHAR(16, charset='ascii'), nullable=True)
AllocPolicy string `width:"16" charset:"ascii" nullable:"true" get:"user" update:"user" create:"optional"` // Column(VARCHAR(16, charset='ascii'), nullable=True)
@@ -673,6 +684,7 @@ type SNetworkConfig struct {
Vip bool
Reserved bool
Ifname string
NetType string
}
func parseNetworkInfo(userCred mcclient.TokenCredential, info jsonutils.JSONObject) (*SNetworkConfig, error) {
@@ -722,6 +734,8 @@ func parseNetworkInfo(userCred mcclient.TokenCredential, info jsonutils.JSONObje
netConfig.BwLimit = bw
} else if p == "[vip]" {
netConfig.Vip = true
} else if utils.IsInStringArray(p, ALL_NETWORK_TYPES) {
netConfig.NetType = p
} else {
netObj, err := NetworkManager.FetchByIdOrName(userCred, p)
if err != nil {
@@ -1130,8 +1144,8 @@ func (manager *SNetworkManager) ValidateCreateData(ctx context.Context, userCred
serverTypeStr, _ := data.GetString("server_type")
if len(serverTypeStr) == 0 {
serverTypeStr = SERVER_TYPE_GUEST
} else if !sets.NewString(SERVER_TYPE_GUEST, SERVER_TYPE_BAREMETAL, SERVER_TYPE_CONTAINER).Has(serverTypeStr) {
serverTypeStr = NETWORK_TYPE_GUEST
} else if !utils.IsInStringArray(serverTypeStr, ALL_NETWORK_TYPES) {
return nil, httperrors.NewInputParameterError("Invalid server_type: %s", serverTypeStr)
}
data.Add(jsonutils.NewString(serverTypeStr), "server_type")
@@ -1257,7 +1271,7 @@ func isOverlapNetworks(nets []SNetwork, startIp netutils.IPV4Addr, endIp netutil
}
func (self *SNetwork) CustomizeCreate(ctx context.Context, userCred mcclient.TokenCredential, ownerProjId string, query jsonutils.JSONObject, data jsonutils.JSONObject) error {
if db.IsAdminAllowCreate(userCred, self.GetModelManager()) && ownerProjId == userCred.GetProjectId() {
if db.IsAdminAllowCreate(userCred, self.GetModelManager()) && ownerProjId == userCred.GetProjectId() && self.ServerType == NETWORK_TYPE_GUEST {
self.IsPublic = true
} else {
self.IsPublic = false
+16 -6
View File
@@ -412,20 +412,20 @@ func (self *SWire) getPrivateNetworks(userCred mcclient.TokenCredential) ([]SNet
return nets, nil
}
func (self *SWire) GetCandidatePrivateNetwork(userCred mcclient.TokenCredential, isExit bool, serverType string) (*SNetwork, error) {
func (self *SWire) GetCandidatePrivateNetwork(userCred mcclient.TokenCredential, isExit bool, serverTypes []string) (*SNetwork, error) {
nets, err := self.getPrivateNetworks(userCred)
if err != nil {
return nil, err
}
return ChooseCandidateNetworks(nets, isExit, serverType), nil
return ChooseCandidateNetworks(nets, isExit, serverTypes), nil
}
func (self *SWire) GetCandidatePublicNetwork(isExit bool, serverType string) (*SNetwork, error) {
func (self *SWire) GetCandidatePublicNetwork(isExit bool, serverTypes []string) (*SNetwork, error) {
nets, err := self.getPublicNetworks()
if err != nil {
return nil, err
}
return ChooseCandidateNetworks(nets, isExit, serverType), nil
return ChooseCandidateNetworks(nets, isExit, serverTypes), nil
}
func (self *SWire) GetCandidateNetworkForIp(userCred mcclient.TokenCredential, ipAddr string) (*SNetwork, error) {
@@ -476,7 +476,17 @@ func chooseNetworkByAddressCount(nets []*SNetwork) (*SNetwork, *SNetwork) {
return minSel, maxSel
}
func ChooseCandidateNetworks(nets []SNetwork, isExit bool, serverType string) *SNetwork {
func ChooseCandidateNetworks(nets []SNetwork, isExit bool, serverTypes []string) *SNetwork {
for _, s := range serverTypes {
net := chooseCandidateNetworksByNetworkType(nets, isExit, s)
if net != nil {
return net
}
}
return nil
}
func chooseCandidateNetworksByNetworkType(nets []SNetwork, isExit bool, serverType string) *SNetwork {
matchingNets := make([]*SNetwork, 0)
notMatchingNets := make([]*SNetwork, 0)
@@ -485,7 +495,7 @@ func ChooseCandidateNetworks(nets []SNetwork, isExit bool, serverType string) *S
if isExit != net.IsExitNetwork() {
continue
}
if serverType == net.ServerType || (len(net.ServerType) == 0 && serverType == SERVER_TYPE_GUEST) {
if serverType == net.ServerType || (len(net.ServerType) == 0 && serverType == NETWORK_TYPE_GUEST) {
matchingNets = append(matchingNets, &net)
} else {
notMatchingNets = append(notMatchingNets, &net)
+2 -2
View File
@@ -10,11 +10,11 @@ import (
"yunion.io/x/onecloud/pkg/appsrv"
"yunion.io/x/onecloud/pkg/cloudcommon/workmanager"
"yunion.io/x/onecloud/pkg/hostman/guestman"
"yunion.io/x/onecloud/pkg/hostman/hostutils"
"yunion.io/x/onecloud/pkg/hostman/storageman"
"yunion.io/x/onecloud/pkg/httperrors"
"yunion.io/x/onecloud/pkg/mcclient/auth"
"yunion.io/x/onecloud/pkg/hostman/guestman"
"yunion.io/x/onecloud/pkg/hostman/storageman"
)
var (
+2 -1
View File
@@ -8,12 +8,13 @@ import (
"yunion.io/x/jsonutils"
"yunion.io/x/log"
"yunion.io/x/onecloud/pkg/appsrv"
"yunion.io/x/onecloud/pkg/hostman/guestman"
"yunion.io/x/onecloud/pkg/hostman/hostutils"
"yunion.io/x/onecloud/pkg/hostman/storageman"
"yunion.io/x/onecloud/pkg/httperrors"
"yunion.io/x/onecloud/pkg/mcclient/auth"
"yunion.io/x/onecloud/pkg/hostman/guestman"
)
type strDict map[string]string
+5 -6
View File
@@ -955,7 +955,6 @@ func (s *SDriveMirrorTask) startMirror(res string) {
}
}
/**
* GuestOnlineResizeDiskTask
**/
@@ -963,9 +962,9 @@ func (s *SDriveMirrorTask) startMirror(res string) {
type SGuestOnlineResizeDiskTask struct {
*SKVMGuestInstance
ctx context.Context
diskId string
sizeMB int64
ctx context.Context
diskId string
sizeMB int64
}
func NewGuestOnlineResizeDiskTask(
@@ -975,7 +974,7 @@ func NewGuestOnlineResizeDiskTask(
SKVMGuestInstance: s,
ctx: ctx,
diskId: diskId,
sizeMB: sizeMB,
sizeMB: sizeMB,
}
}
@@ -1000,4 +999,4 @@ func (task *SGuestOnlineResizeDiskTask) OnResizeSucc(result string) {
params := jsonutils.NewDict()
params.Add(jsonutils.NewInt(task.sizeMB), "disk_size")
hostutils.TaskComplete(task.ctx, params)
}
}
+2 -2
View File
@@ -10,15 +10,15 @@ import (
"yunion.io/x/onecloud/pkg/cloudcommon"
"yunion.io/x/onecloud/pkg/cloudcommon/cronman"
"yunion.io/x/onecloud/pkg/cloudcommon/service"
"yunion.io/x/onecloud/pkg/hostman/diskhandlers"
"yunion.io/x/onecloud/pkg/hostman/downloader"
"yunion.io/x/onecloud/pkg/hostman/guesthandlers"
"yunion.io/x/onecloud/pkg/hostman/guestman"
"yunion.io/x/onecloud/pkg/hostman/hostinfo"
"yunion.io/x/onecloud/pkg/hostman/hostmetrics"
"yunion.io/x/onecloud/pkg/hostman/hostutils"
"yunion.io/x/onecloud/pkg/hostman/options"
"yunion.io/x/onecloud/pkg/hostman/storageman"
"yunion.io/x/onecloud/pkg/hostman/guesthandlers"
"yunion.io/x/onecloud/pkg/hostman/diskhandlers"
)
type SHostService struct {
+1 -1
View File
@@ -355,4 +355,4 @@ func (m *HmpMonitor) StartNbdServer(port int, exportAllDevice, writable bool, ca
func (m *HmpMonitor) ResizeDisk(driveName string, sizeMB int64, callback StringCallback) {
cmd := fmt.Sprintf("block_resize %s %d", driveName, sizeMB)
m.Query(cmd, callback)
}
}
+1 -1
View File
@@ -702,4 +702,4 @@ func (m *QmpMonitor) StartNbdServer(port int, exportAllDevice, writable bool, ca
func (m *QmpMonitor) ResizeDisk(driveName string, sizeMB int64, callback StringCallback) {
cmd := fmt.Sprintf("block_resize %s %d", driveName, sizeMB)
m.HumanMonitorCommand(cmd, callback)
}
}
+1 -1
View File
@@ -115,7 +115,7 @@ func (self *SVSwitch) GetGateway() string {
}
func (self *SVSwitch) GetServerType() string {
return models.SERVER_TYPE_GUEST
return models.NETWORK_TYPE_GUEST
}
func (self *SVSwitch) GetIsPublic() bool {
+1 -1
View File
@@ -100,7 +100,7 @@ func (self *SNetwork) GetGateway() string {
}
func (self *SNetwork) GetServerType() string {
return models.SERVER_TYPE_GUEST
return models.NETWORK_TYPE_GUEST
}
func (self *SNetwork) GetIsPublic() bool {
+1 -1
View File
@@ -92,7 +92,7 @@ func (self *SClassicNetwork) GetIsPublic() bool {
}
func (self *SClassicNetwork) GetServerType() string {
return models.SERVER_TYPE_GUEST
return models.NETWORK_TYPE_GUEST
}
func (self *SClassicNetwork) Refresh() error {
+1 -1
View File
@@ -98,7 +98,7 @@ func (self *SNetwork) GetIsPublic() bool {
}
func (self *SNetwork) GetServerType() string {
return models.SERVER_TYPE_GUEST
return models.NETWORK_TYPE_GUEST
}
func (self *SNetwork) Refresh() error {
+1 -1
View File
@@ -113,7 +113,7 @@ func (self *SNetwork) GetGateway() string {
}
func (self *SNetwork) GetServerType() string {
return models.SERVER_TYPE_GUEST
return models.NETWORK_TYPE_GUEST
}
func (self *SNetwork) GetIsPublic() bool {
+1 -1
View File
@@ -113,7 +113,7 @@ func (network *SNetwork) GetIsPublic() bool {
}
func (network *SNetwork) GetServerType() string {
return models.SERVER_TYPE_GUEST
return models.NETWORK_TYPE_GUEST
}
func (region *SRegion) GetNetwork(networkId string) (*SNetwork, error) {
+1 -1
View File
@@ -107,7 +107,7 @@ func (self *SNetwork) GetIsPublic() bool {
}
func (self *SNetwork) GetServerType() string {
return models.SERVER_TYPE_GUEST
return models.NETWORK_TYPE_GUEST
}
func (self *SNetwork) Refresh() error {