Add HIMN routing
This commit is contained in:
parent
ec3b8efb57
commit
3e0a44e7a3
|
@ -20,9 +20,7 @@ if [ -n "$vm_uuid" ]; then
|
|||
eth2_uuid=$(xe vif-create network-uuid="$net_uuid" vm-uuid="$vm_uuid" device="$device_number")
|
||||
echo "$vm_name : HIMN created"
|
||||
|
||||
_vm=$(xe vif-plug uuid="$eth2_uuid")
|
||||
echo "$vm_name : HIMN plugged"
|
||||
#You attempted an operation on a VM which requires PV drivers to be installed but the drivers were not detected.
|
||||
#_vm=$(xe vif-plug uuid="$eth2_uuid")
|
||||
fi
|
||||
other_config=$(xe network-param-get param-name="other-config" uuid="$net_uuid")
|
||||
if [[ "$other_config" == "*is_guest_installer_network*" ]]; then
|
||||
|
|
|
@ -7,6 +7,7 @@ import yaml
|
|||
from subprocess import call
|
||||
from shutil import rmtree
|
||||
from tempfile import mkstemp, mkdtemp
|
||||
import netifaces
|
||||
|
||||
LOG_FILE = '/tmp/compute_post_deployment.log'
|
||||
ASTUTE_PATH = '/etc/astute.yaml'
|
||||
|
@ -31,14 +32,44 @@ def get_access(astute_path, access_section):
|
|||
return access
|
||||
|
||||
def init_eth(dev_no):
|
||||
fname = '/etc/network/interfaces.d/ifcfg-eth%d' % (dev_no)
|
||||
eth = 'eth%s' % dev_no
|
||||
|
||||
if not eth in netifaces.interfaces():
|
||||
warning('%s not found' % eth)
|
||||
return
|
||||
|
||||
info('%s found' % eth)
|
||||
call('dhclient', eth)
|
||||
call('ifconfig', eth)
|
||||
fname = '/etc/network/interfaces.d/ifcfg-' + eth
|
||||
s = \
|
||||
"""auto eth2
|
||||
iface eth2 inet dhcp
|
||||
"""
|
||||
"""auto {eth}
|
||||
iface {eth} inet dhcp
|
||||
""".format(eth = eth)
|
||||
with open(fname, 'w') as f:
|
||||
f.write(s)
|
||||
info('%s created' % fname)
|
||||
call('ifdown', eth)
|
||||
call('ifup', eth)
|
||||
addr = netifaces.ifaddresses(eth).get(2)
|
||||
if addr is not None:
|
||||
ip = addr[0]['addr']
|
||||
info('%s : %s' % (eth, ip))
|
||||
return ip
|
||||
else:
|
||||
warning('%s not found' % access_section)
|
||||
|
||||
return
|
||||
|
||||
def set_routing():
|
||||
eth_nova = astute['network_scheme']['roles']['novanetwork/fixed']
|
||||
storage_ip = astute['network_scheme']['endpoints']['br-storage']['IP']
|
||||
mgmt_ip = astute['network_scheme']['endpoints']['br-mgmt']['IP']
|
||||
|
||||
nova_ip = netifaces.ifaddresses(eth_nova).get(2)
|
||||
|
||||
call('route', 'add', storage_ip, 'gw', nova_ip)
|
||||
call('route', 'add', mgmt_ip, 'gw', nova_ip)
|
||||
|
||||
def install_xenapi_sdk(xenapi_url):
|
||||
xenapi_zipball = mkstemp()[1]
|
||||
|
@ -62,23 +93,23 @@ def install_xenapi_sdk(xenapi_url):
|
|||
os.remove(xenapi_zipball)
|
||||
rmtree(xenapi_sources)
|
||||
|
||||
def create_novacompute_conf(access):
|
||||
def create_novacompute_conf(access, ip):
|
||||
template = \
|
||||
"""[DEFAULT]
|
||||
compute_driver=xenapi.XenAPIDriver
|
||||
[xenserver]
|
||||
connection_url=http://169.254.0.1
|
||||
connection_username={username}
|
||||
connection_password={password}
|
||||
connection_url=http://%s
|
||||
connection_username="%s"
|
||||
connection_password="%s"
|
||||
"""
|
||||
s = template.format(**access)
|
||||
s = template.format(ip, access['username'],access['password'])
|
||||
with open('/etc/nova/nova-compute.conf','w') as f:
|
||||
f.write(s)
|
||||
info('nova-compute.conf created')
|
||||
|
||||
if __name__ == '__main__':
|
||||
init_eth(2)
|
||||
install_xenapi_sdk(XENAPI_URL)
|
||||
access = get_access(ASTUTE_PATH, ACCESS_SECTION)
|
||||
if access is not None:
|
||||
create_novacompute_conf(access)
|
||||
ip = init_eth(2)
|
||||
if access is not None and ip is not None :
|
||||
create_novacompute_conf(access, ip)
|
||||
|
|
Loading…
Reference in New Issue