The interface can't be assigned Dataplane when the interface is bond and that is linux bond

Change-Id: I4288be4534c3141eb92e10a0e653628ce299a20b
This commit is contained in:
10190269 2016-12-08 17:03:19 +08:00
parent 301d642874
commit ea5a0f2471
6 changed files with 87 additions and 10 deletions

64
code/daisy/daisy/api/v1/hosts.py Normal file → Executable file
View File

@ -263,7 +263,8 @@ class Controller(controller.BaseController):
return all_networks
def _check_assigned_networks(self, req, cluster_id, assigned_networks):
def _check_asged_net(self, req, cluster_id, assigned_networks,
bond_type=None):
LOG.info("assigned_networks %s " % assigned_networks)
cluster_networks = self.get_cluster_networks_info(req, cluster_id)
list_of_assigned_networks = []
@ -301,6 +302,25 @@ class Controller(controller.BaseController):
raise HTTPBadRequest(explanation=msg,
request=req,
content_type="text/plain")
else:
if bond_type:
cluster_roles = daisy_cmn. \
get_cluster_roles_detail(req, cluster_id)
cluster_backends = set([role['deployment_backend']
for role in cluster_roles if
daisy_cmn.get_hosts_of_role(
req, role['id'])])
for backend in cluster_backends:
try:
backend_common = importutils.import_module(
'daisy.api.backends.%s.common' % backend)
except Exception:
pass
else:
if hasattr(backend_common,
'check_dataplane_bond_type'):
backend_common.check_dataplane_bond_type(
req, bond_type)
else:
msg = "can't find network named '%s' in cluster '%s'" % (
assigned_network['name'], cluster_id)
@ -426,11 +446,28 @@ class Controller(controller.BaseController):
interface['assigned_networks']):
have_assigned_network = True
if cluster_id:
assigned_networks_of_one_interface = self.\
_check_assigned_networks(req,
if interface.get('type', None) == "bond":
bond_type = interface.get("bond_type", None)
if bond_type:
assigned_networks_of_one_interface = self. \
_check_asged_net(req,
cluster_id,
interface[
'assigned_networks'])
'assigned_networks'],
bond_type)
else:
msg = "bond type must be given when interface " \
"type is bond"
LOG.error(msg)
raise HTTPBadRequest(explanation=msg,
request=req,
content_type="text/plain")
else:
assigned_networks_of_one_interface = self. \
_check_asged_net(req,
cluster_id,
interface[
'assigned_networks'])
else:
msg = "cluster must be given first when network " \
"plane is allocated"
@ -1585,11 +1622,22 @@ class Controller(controller.BaseController):
LOG.info(
"interface['assigned_networks']: %s" %
interface['assigned_networks'])
assigned_networks_of_one_interface = self.\
_check_assigned_networks(req,
if interface.get('type', None) == "bond":
bond_type = interface.get("bond_type", None)
if bond_type:
assigned_networks_of_one_interface = self. \
_check_asged_net(req,
cluster_id,
interface['assigned_'
'networks'])
interface[
'assigned_networks'],
bond_type)
else:
assigned_networks_of_one_interface = self. \
_check_asged_net(req,
cluster_id,
interface[
'assigned_networks'])
self._update_networks_phyname(
req, interface, cluster_id)
host_meta['cluster'] = cluster_id

View File

@ -0,0 +1,25 @@
# Copyright 2013 OpenStack Foundation
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from sqlalchemy import MetaData, Table, Column, String
bond_type = Column('bond_type', String(36))
def upgrade(migrate_engine):
meta = MetaData()
meta.bind = migrate_engine
host_interfaces = Table('host_interfaces', meta, autoload=True)
host_interfaces.create_column(bond_type)

View File

@ -280,6 +280,7 @@ class HostInterface(BASE, DaisyBase):
type = Column(String(32), nullable=False, default='ether')
slave1 = Column(String(32))
slave2 = Column(String(32))
bond_type = Column(String(36))
mode = Column(String(36))
is_deployment = Column(Boolean(), default=False)
state = Column(String(64))

View File

@ -129,7 +129,7 @@ def do_host_add(gc, args):
"type": "", "name": "", "mac": "", "ip": "",
"netmask": "", "assigned_networks": "",
"slaves": "", "is_deployment": "",
"vswitch_type": ""}
"vswitch_type": "", "bond_type": ""}
for kv_str in interface.split(","):
try:
k, v = kv_str.split("=", 1)
@ -273,7 +273,8 @@ def do_host_update(gc, args):
"type": "", "name": "", "mac": "", "ip": "",
"netmask": "", "mode": "",
"assigned_networks": "", "slaves": "",
"is_deployment": "", "vswitch_type": ""}
"is_deployment": "", "vswitch_type": "",
"bond_type": ""}
for kv_str in interfaces.split(","):
try:
k, v = kv_str.split("=", 1)

View File

@ -226,6 +226,7 @@ def update_interfaces(interfaces_old, bond_params):
"type": "bond",
"name": bond_params["name"],
"mode": bond_params["mode"],
"bond_type": bond_params["bond_type"],
"slaves": bond_params["net_ports"]
})
ether_interfaces.extend(bond_interfaces)

View File

@ -376,6 +376,7 @@
var bond_params = {
"net_ports": net_ports,
"name": name,
"bond_type": $('#select_bond_type').val(),
"mode": bond_mode
};
var url = "/dashboard/environment/deploy/" + $("#cluster_id").val() + '/bond_net_port';