From c3af5e65508fb325a4a8e350c9ed6d84d87e7cd8 Mon Sep 17 00:00:00 2001 From: Arvind Somy Date: Fri, 17 Jun 2011 15:12:01 -0400 Subject: Fix for lp:796834 - Fixes and enhancements to the ESX(i) guest_tool.py script. --- tools/esx/guest_tool.py | 49 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 2 deletions(-) (limited to 'tools') diff --git a/tools/esx/guest_tool.py b/tools/esx/guest_tool.py index 13b0f8d33..e126721d5 100644 --- a/tools/esx/guest_tool.py +++ b/tools/esx/guest_tool.py @@ -21,6 +21,7 @@ On Windows we require pyWin32 installed on Python. """ import array +import gettext import logging import os import platform @@ -30,6 +31,8 @@ import subprocess import sys import time +_ = gettext.gettext + PLATFORM_WIN = 'win32' PLATFORM_LINUX = 'linux2' ARCH_32_BIT = '32bit' @@ -314,6 +317,43 @@ def _set_rhel_networking(network_details=[]): dns_file.close() _execute(['/sbin/service', 'network', 'restart']) +def _set_ubuntu_networking(network_details=[]): + """ Set IPv4 network settings for Ubuntu """ + all_dns_servers = [] + for network_detail in network_details: + mac_address, ip_address, subnet_mask, gateway, broadcast,\ + dns_servers = network_detail + all_dns_servers.extend(dns_servers) + adapter_name, current_ip_address = \ + _get_linux_adapter_name_and_ip_address(mac_address) + + if adapter_name and not ip_address == current_ip_address: + interface_file_name = \ + '/etc/network/interfaces' + # Remove file + os.remove(interface_file_name) + # Touch file + _execute(['touch', interface_file_name]) + interface_file = open(interface_file_name, 'w') + interface_file.write('\nauto %s' % adapter_name) + interface_file.write('\niface %s inet static' % adapter_name) + interface_file.write('\nbroadcast %s' % broadcast) + interface_file.write('\ngateway %s' % gateway) + interface_file.write('\nnetmask %s' % subnet_mask) + interface_file.write('\naddress %s' % ip_address) + interface_file.close() + if all_dns_servers: + dns_file_name = "/etc/resolv.conf" + os.remove(dns_file_name) + _execute(['touch', dns_file_name]) + dns_file = open(dns_file_name, 'w') + dns_file.write("; generated by OpenStack guest tools") + unique_entries = _filter_duplicates(all_dns_servers) + for dns_server in unique_entries: + dns_file.write("\nnameserver %s" % dns_server) + dns_file.close() + print "\nRestarting networking....\n" + _execute(['/etc/init.d/networking', 'restart']) def _linux_set_networking(): """Set IP address for the Linux VM.""" @@ -330,8 +370,13 @@ def _linux_set_networking(): cmd = [vmware_tools_bin, '--cmd', 'machine.id.get'] network_details = _parse_network_details(_execute(cmd, check_exit_code=False)) - # TODO(sateesh): For other distros like ubuntu, suse, debian, BSD, etc. - _set_rhel_networking(network_details) + # TODO(sateesh): For other distros like suse, debian, BSD, etc. + if(platform.dist()[0] == 'Ubuntu') : + _set_ubuntu_networking(network_details) + elif (platform.dist()[0] == 'redhat') : + _set_rhel_networking(network_details) + else: + logging.warn(_("Distro '%s' not supported") % platform.dist()[0]) else: logging.warn(_("VMware Tools is not installed")) -- cgit From 03db1b862f38fa864316530c0a0b22ef74f25c81 Mon Sep 17 00:00:00 2001 From: "Arvind Somya asomya@cisco.com" <> Date: Fri, 24 Jun 2011 12:15:13 -0400 Subject: Fixing PEP8 compliance issues. --- tools/esx/guest_tool.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'tools') diff --git a/tools/esx/guest_tool.py b/tools/esx/guest_tool.py index e126721d5..3463be5dd 100644 --- a/tools/esx/guest_tool.py +++ b/tools/esx/guest_tool.py @@ -317,6 +317,7 @@ def _set_rhel_networking(network_details=[]): dns_file.close() _execute(['/sbin/service', 'network', 'restart']) + def _set_ubuntu_networking(network_details=[]): """ Set IPv4 network settings for Ubuntu """ all_dns_servers = [] @@ -355,6 +356,7 @@ def _set_ubuntu_networking(network_details=[]): print "\nRestarting networking....\n" _execute(['/etc/init.d/networking', 'restart']) + def _linux_set_networking(): """Set IP address for the Linux VM.""" vmware_tools_bin = None @@ -371,9 +373,9 @@ def _linux_set_networking(): network_details = _parse_network_details(_execute(cmd, check_exit_code=False)) # TODO(sateesh): For other distros like suse, debian, BSD, etc. - if(platform.dist()[0] == 'Ubuntu') : + if(platform.dist()[0] == 'Ubuntu'): _set_ubuntu_networking(network_details) - elif (platform.dist()[0] == 'redhat') : + elif (platform.dist()[0] == 'redhat'): _set_rhel_networking(network_details) else: logging.warn(_("Distro '%s' not supported") % platform.dist()[0]) -- cgit From 8ec448d2bcf4afce7d0486d9cf6b07e0e30bd6be Mon Sep 17 00:00:00 2001 From: "Arvind Somya asomya@cisco.com" <> Date: Fri, 24 Jun 2011 12:22:14 -0400 Subject: Fixed the default arguments to None instead of an empty list. --- tools/esx/guest_tool.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'tools') diff --git a/tools/esx/guest_tool.py b/tools/esx/guest_tool.py index 3463be5dd..60ecfcd20 100644 --- a/tools/esx/guest_tool.py +++ b/tools/esx/guest_tool.py @@ -278,7 +278,8 @@ def _filter_duplicates(all_entries): return final_list -def _set_rhel_networking(network_details=[]): +def _set_rhel_networking(network_details=None): + network_details = network_details or [] all_dns_servers = [] for network_detail in network_details: mac_address, ip_address, subnet_mask, gateway, broadcast,\ @@ -318,7 +319,8 @@ def _set_rhel_networking(network_details=[]): _execute(['/sbin/service', 'network', 'restart']) -def _set_ubuntu_networking(network_details=[]): +def _set_ubuntu_networking(network_details=None): + network_details = network_details or [] """ Set IPv4 network settings for Ubuntu """ all_dns_servers = [] for network_detail in network_details: -- cgit From 6d1ce4a46a9684ac718bfc19dc8a362fbc9a9641 Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Mon, 27 Jun 2011 09:02:22 -0700 Subject: remove extra stuff from clean vlans --- tools/clean-vlans | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'tools') diff --git a/tools/clean-vlans b/tools/clean-vlans index 820a9dbe5..a26ad86ad 100755 --- a/tools/clean-vlans +++ b/tools/clean-vlans @@ -17,9 +17,9 @@ # License for the specific language governing permissions and limitations # under the License. -export LC_ALL=C +export LC_ALL=C sudo ifconfig -a | grep br | grep -v bridge | cut -f1 -d" " | xargs -n1 -ifoo ifconfig foo down sudo ifconfig -a | grep br | grep -v bridge | cut -f1 -d" " | xargs -n1 -ifoo brctl delbr foo -sudo ifconfig -a | grep vlan | grep -v vlan124 | grep -v vlan5 | cut -f1 -d" " | xargs -n1 -ifoo ifconfig foo down -sudo ifconfig -a | grep vlan | grep -v vlan124 | grep -v vlan5 | cut -f1 -d" " | xargs -n1 -ifoo vconfig rem foo +sudo ifconfig -a | grep vlan | cut -f1 -d" " | xargs -n1 -ifoo ifconfig foo down +sudo ifconfig -a | grep vlan | cut -f1 -d" " | xargs -n1 -ifoo vconfig rem foo -- cgit From 7230c384d1373e8718bc7fd2fd86b1e805a0573e Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Mon, 27 Jun 2011 09:05:05 -0700 Subject: make nova-debug work with new style instances --- tools/nova-debug | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'tools') diff --git a/tools/nova-debug b/tools/nova-debug index 3ff68ca35..fd9cb054a 100755 --- a/tools/nova-debug +++ b/tools/nova-debug @@ -1,4 +1,3 @@ -#!/usr/bin/env bash # vim: tabstop=4 shiftwidth=4 softtabstop=4 # Copyright 2010 United States Government as represented by the @@ -30,13 +29,15 @@ cd $INSTANCES_PATH/$1 if [ $CMD != "umount" ] && [ $CMD != "launch" ]; then # destroy the instance virsh destroy $1 +virsh undefine $1 # mount the filesystem mkdir t -DEVICE=`losetup --show -f disk` +DEVICE=/dev/nbd0 echo $DEVICE -kpartx -a $DEVICE -mount /dev/mapper/${DEVICE:4}p1 t +qemu-nbd -c $DEVICE disk +sleep 3 +mount $DEVICE t fi if [ $CMD != "mount" ] && [ $CMD != "umount" ]; then @@ -66,11 +67,13 @@ sed -i "s/.*<\/serial>/ Date: Mon, 27 Jun 2011 09:17:37 -0700 Subject: missed the bin line --- tools/nova-debug | 1 + 1 file changed, 1 insertion(+) (limited to 'tools') diff --git a/tools/nova-debug b/tools/nova-debug index fd9cb054a..0a78af16a 100755 --- a/tools/nova-debug +++ b/tools/nova-debug @@ -1,3 +1,4 @@ +#!/usr/bin/env bash # vim: tabstop=4 shiftwidth=4 softtabstop=4 # Copyright 2010 United States Government as represented by the -- cgit From 43713a2e45862219c538ede60363053d36bb0f1b Mon Sep 17 00:00:00 2001 From: Arvind Somy Date: Mon, 27 Jun 2011 14:41:07 -0400 Subject: - Modified NOTE in vm_util.py - Changed gettext line to nova default in guest_tool.py --- tools/esx/guest_tool.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tools') diff --git a/tools/esx/guest_tool.py b/tools/esx/guest_tool.py index 60ecfcd20..97b5302ba 100644 --- a/tools/esx/guest_tool.py +++ b/tools/esx/guest_tool.py @@ -31,7 +31,7 @@ import subprocess import sys import time -_ = gettext.gettext +gettext.install('nova', unicode=1) PLATFORM_WIN = 'win32' PLATFORM_LINUX = 'linux2' -- cgit From 6af4a9ded53efe4ca5c3aad1f3a621cc73513fb0 Mon Sep 17 00:00:00 2001 From: Chris Behrens Date: Wed, 29 Jun 2011 08:30:21 -0700 Subject: updated pip-requires for novaclient --- tools/pip-requires | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tools') diff --git a/tools/pip-requires b/tools/pip-requires index 6e686b7e7..dec93c351 100644 --- a/tools/pip-requires +++ b/tools/pip-requires @@ -9,7 +9,7 @@ boto==1.9b carrot==0.10.5 eventlet lockfile==0.8 -python-novaclient==2.5.3 +python-novaclient==2.5.7 python-daemon==1.5.5 python-gflags==1.3 redis==2.0.0 -- cgit