check ip_range/vlan_id/gateway when cidr is same
1. ip_range/vlan_id/gateway must be same when cidr of networks is same when installing 2. remove repeat network when generate json before install os 3. change cidr of template networks to 1.0.0.0/8 to avoid being used by mistake when ssh discover host. Change-Id: Icbfe394a2ca968695d59013b09ad2c722d8da2e2
This commit is contained in:
parent
e170098f6f
commit
62d0f1b0b2
9
code/daisy/daisy/api/backends/osinstall/pxe/install.py
Normal file → Executable file
9
code/daisy/daisy/api/backends/osinstall/pxe/install.py
Normal file → Executable file
@ -371,9 +371,18 @@ def set_disk_start_of_cisco(host_detail):
|
||||
def _get_host_interfaces(host_info):
|
||||
interfaces = host_info['interfaces']
|
||||
for interface in interfaces:
|
||||
no_dup_networks = {}
|
||||
for assigned_network in interface['assigned_networks']:
|
||||
if assigned_network['network_type'] == 'DATAPLANE':
|
||||
assigned_network['ip'] = None
|
||||
break
|
||||
|
||||
# remove duplicates assigned networks
|
||||
if assigned_network.get('ip') not in no_dup_networks.keys() \
|
||||
or assigned_network.get('network_type') == 'MANAGEMENT':
|
||||
no_dup_networks[assigned_network['ip']] = assigned_network
|
||||
if no_dup_networks:
|
||||
interface['assigned_networks'] = no_dup_networks.values()
|
||||
return interfaces
|
||||
|
||||
|
||||
|
@ -218,6 +218,17 @@ def valid_cluster_networks(cluster_networks):
|
||||
raise exc.HTTPBadRequest(explanation=msg)
|
||||
|
||||
|
||||
def check_gateway_uniqueness(new_cluster_networks):
|
||||
used_gateways = set()
|
||||
for network in new_cluster_networks:
|
||||
if network.get('gateway'):
|
||||
used_gateways.add(network['gateway'])
|
||||
if len(used_gateways) > 1:
|
||||
msg = (_("Only one gateway is allowed."))
|
||||
LOG.error(msg)
|
||||
raise exc.HTTPBadRequest(explanation=msg)
|
||||
|
||||
|
||||
def remote_execute_script(ssh_host_info,
|
||||
files=[], commands=[]):
|
||||
try:
|
||||
|
24
code/daisy/daisy/api/v1/install.py
Normal file → Executable file
24
code/daisy/daisy/api/v1/install.py
Normal file → Executable file
@ -31,7 +31,7 @@ from daisy import notifier
|
||||
|
||||
from daisy.api import policy
|
||||
import daisy.api.v1
|
||||
|
||||
from daisy.api import common
|
||||
from daisy.common import exception
|
||||
from daisy.common import utils
|
||||
from daisy.common import wsgi
|
||||
@ -42,7 +42,7 @@ import daisy.api.backends.common as daisy_cmn
|
||||
from daisy.api.backends import driver
|
||||
from daisy.api.backends.osinstall import osdriver
|
||||
import ConfigParser
|
||||
|
||||
from oslo_utils import importutils
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
_ = i18n._
|
||||
@ -298,6 +298,25 @@ class Controller(controller.BaseController):
|
||||
params[PARAM] = req.params.get(PARAM)
|
||||
return params
|
||||
|
||||
def valid_used_networks(self, req, cluster_id):
|
||||
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, 'get_used_networks'):
|
||||
networks = backend_common.get_used_networks(req,
|
||||
cluster_id)
|
||||
if networks:
|
||||
common.valid_cluster_networks(networks)
|
||||
common.check_gateway_uniqueness(networks)
|
||||
|
||||
@utils.mutating
|
||||
def install_cluster(self, req, install_meta):
|
||||
"""
|
||||
@ -315,6 +334,7 @@ class Controller(controller.BaseController):
|
||||
cluster_id = install_meta['cluster_id']
|
||||
self._enforce(req, 'install_cluster')
|
||||
self._raise_404_if_cluster_deleted(req, cluster_id)
|
||||
self.valid_used_networks(req, cluster_id)
|
||||
|
||||
daisy_cmn.set_role_status_and_progress(
|
||||
req, cluster_id, 'install',
|
||||
|
24
code/daisy/daisy/api/v1/networks.py
Normal file → Executable file
24
code/daisy/daisy/api/v1/networks.py
Normal file → Executable file
@ -420,17 +420,6 @@ class Controller(controller.BaseController):
|
||||
(gateway, cidr)))
|
||||
raise HTTPBadRequest(explanation=msg)
|
||||
|
||||
if network_meta.get('network_type', None) != "DATAPLANE" and \
|
||||
network_meta.get('cluster_id') and network_meta.get('gateway'):
|
||||
networks = registry.get_networks_detail(req.context, cluster_id)
|
||||
gateways = [network['gateway'] for network in networks
|
||||
if network['name'] != network_meta['name'] and
|
||||
network['gateway'] and
|
||||
network['network_type'] != "DATAPLANE"]
|
||||
if gateways:
|
||||
msg = (_('More than one gateway found in cluster.'))
|
||||
LOG.error(msg)
|
||||
raise HTTPConflict(explanation=msg)
|
||||
network_meta = registry.add_network_metadata(req.context, network_meta)
|
||||
return {'network_meta': network_meta}
|
||||
|
||||
@ -722,19 +711,6 @@ class Controller(controller.BaseController):
|
||||
(gateway, cidr)))
|
||||
raise HTTPBadRequest(explanation=msg)
|
||||
|
||||
# allow one gateway in one cluster
|
||||
if network_meta.get('network_type', None) != "DATAPLANE" and \
|
||||
network_meta.get('cluster_id') and network_meta.get('gateway'):
|
||||
networks = registry.get_networks_detail(req.context, cluster_id)
|
||||
gateways = [network['gateway'] for network in networks
|
||||
if network['name'] != orig_network_meta['name'] and
|
||||
network['gateway'] and
|
||||
network['network_type'] != "DATAPLANE"]
|
||||
if gateways:
|
||||
msg = (_('More than one gateway found in cluster.'))
|
||||
LOG.error(msg)
|
||||
raise HTTPConflict(explanation=msg)
|
||||
|
||||
try:
|
||||
network_meta = registry.update_network_metadata(req.context,
|
||||
network_id,
|
||||
|
8
tools/setup/install/install_func.sh
Normal file → Executable file
8
tools/setup/install/install_func.sh
Normal file → Executable file
@ -475,13 +475,13 @@ function create_daisy_network
|
||||
{
|
||||
write_install_log "Daisy init and create the network"
|
||||
|
||||
daisy --os-endpoint="http://${public_ip}:$bind_port" network-add "PUBLICAPI" "For public api" "PUBLICAPI" --cidr "192.168.1.1/24" --type template --capability high >> $install_logfile 2>&1
|
||||
daisy --os-endpoint="http://${public_ip}:$bind_port" network-add "PUBLICAPI" "For public api" "PUBLICAPI" --cidr "1.0.0.0/8" --type template --capability high >> $install_logfile 2>&1
|
||||
[ "$?" -ne 0 ] && { write_install_log "create the network of publicAPI failed"; exit 1; }
|
||||
|
||||
daisy --os-endpoint="http://${public_ip}:$bind_port" network-add "MANAGEMENT" "For internal API and AMQP" "MANAGEMENT" --cidr "192.168.1.1/24" --type template --capability high >> $install_logfile 2>&1
|
||||
daisy --os-endpoint="http://${public_ip}:$bind_port" network-add "MANAGEMENT" "For internal API and AMQP" "MANAGEMENT" --cidr "1.0.0.0/8" --type template --capability high >> $install_logfile 2>&1
|
||||
[ "$?" -ne 0 ] && { write_install_log "create the network of MANAGEMENT failed"; exit 1; }
|
||||
|
||||
daisy --os-endpoint="http://${public_ip}:$bind_port" network-add "STORAGE" "Storage network plane" "STORAGE" --cidr "192.169.1.1/24" --type template --capability high >> $install_logfile 2>&1
|
||||
daisy --os-endpoint="http://${public_ip}:$bind_port" network-add "STORAGE" "Storage network plane" "STORAGE" --cidr "1.0.0.0/8" --type template --capability high >> $install_logfile 2>&1
|
||||
[ "$?" -ne 0 ] && { write_install_log "create the network of STORAGE failed"; exit 1; }
|
||||
|
||||
daisy --os-endpoint="http://${public_ip}:$bind_port" network-add "physnet1" "Dataplane network for vms" "DATAPLANE" --type template --ml2-type ovs --capability high >> $install_logfile 2>&1
|
||||
@ -490,7 +490,7 @@ function create_daisy_network
|
||||
daisy --os-endpoint="http://${public_ip}:$bind_port" network-add "DEPLOYMENT" "For deploy the infrastructure" "DEPLOYMENT" --cidr "99.99.1.1/24" --type template --capability high >> $install_logfile 2>&1
|
||||
[ "$?" -ne 0 ] && { write_install_log "create the network of DEPLOYMENT failed"; exit 1; }
|
||||
|
||||
daisy --os-endpoint="http://${public_ip}:$bind_port" network-add "EXTERNAL" "For external interactive" "EXTERNAL" --cidr "192.170.1.1/24" --type template --capability high >> $install_logfile 2>&1
|
||||
daisy --os-endpoint="http://${public_ip}:$bind_port" network-add "EXTERNAL" "For external interactive" "EXTERNAL" --cidr "1.0.0.0/8" --type template --capability high >> $install_logfile 2>&1
|
||||
[ "$?" -ne 0 ] && { write_install_log "create the network of EXTERNAL failed"; exit 1; }
|
||||
|
||||
daisy --os-endpoint="http://${public_ip}:$bind_port" network-add "DEPLOYMENT" "For build pxe server" "DEPLOYMENT" --cidr "99.99.1.1/24" --ip "99.99.1.5" --ip-ranges "start":"99.99.1.50","end":"99.99.1.150" --type system >> $install_logfile 2>&1
|
||||
|
Loading…
x
Reference in New Issue
Block a user