From 7cad0d54f39b6bfa87474f80e5136f21e1f8d954 Mon Sep 17 00:00:00 2001 From: Zexi Li Date: Thu, 16 Aug 2018 16:19:52 +0800 Subject: [PATCH] scheduler: network container server_type --- cmd/climc/shell/networks.go | 4 ++-- .../algorithm/predicates/guest/network_predicate.go | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/cmd/climc/shell/networks.go b/cmd/climc/shell/networks.go index fdf011d56f..52d6900a28 100644 --- a/cmd/climc/shell/networks.go +++ b/cmd/climc/shell/networks.go @@ -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:"" 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 { diff --git a/pkg/scheduler/algorithm/predicates/guest/network_predicate.go b/pkg/scheduler/algorithm/predicates/guest/network_predicate.go index 8f0c13aa50..e78ba0d99c 100644 --- a/pkg/scheduler/algorithm/predicates/guest/network_predicate.go +++ b/pkg/scheduler/algorithm/predicates/guest/network_predicate.go @@ -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 {