Merge pull request #63 in YUNIONIO/onecloud from ~LIZEXI/onecloud:feature/lzx-scheduler-container-net to release/2.0.0

* commit '7cad0d54f39b6bfa87474f80e5136f21e1f8d954':
  scheduler: network container server_type
This commit is contained in:
邱剑
2018-08-16 19:04:57 +08:00
2 changed files with 5 additions and 4 deletions
+2 -2
View File
@@ -45,7 +45,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"`
ServerType string `help:"server type," choices:"baremetal|guest|container"`
StartIp string `help:"Start ip"`
EndIp string `help:"end ip"`
NetMask int64 `help:"Netmask"`
@@ -178,7 +178,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"`
ServerType string `help:"Server type" choices:"baremetal|guest|container"`
Desc string `help:"Description" metavar:"DESCRIPTION"`
}
R(&NetworkCreateOptions{}, "network-create", "Create a virtual network", func(s *mcclient.ClientSession, args *NetworkCreateOptions) error {
@@ -10,6 +10,7 @@ import (
"yunion.io/x/onecloud/pkg/scheduler/core"
networks "yunion.io/x/onecloud/pkg/scheduler/db/models"
"yunion.io/x/pkg/utils"
"yunion.io/yunioncloud/pkg/util/sets"
)
// NetworkPredicate will filter the current network information with
@@ -51,9 +52,9 @@ func (p *NetworkPredicate) Execute(u *core.Unit, c core.Candidater) (bool, []cor
return len(d.HostID) > 0
}
// ServerType's value is 'guest' or ''(support all type) will return true.
// ServerType's value is 'guest', 'container' or ''(support all type) will return true.
isMatchServerType := func(network *networks.NetworkSchedResult) bool {
return network.ServerType == "guest" || network.ServerType == ""
return sets.NewString("guest", "", "container").Has(network.ServerType)
}
counterOfNetwork := func(u *core.Unit, n *networks.NetworkSchedResult, r int) core.Counter {