Fix failure to add static route in http client VM

Add hostname in etc/hosts to prevent sudo to fail
Add additional syslog in agent code
Add devuser login to troubleshoot VM

Change-Id: I59a28fe3eb0c354721989a3f3e1102e67949d545
Signed-off-by: ahothan <ahothan@cisco.com>
This commit is contained in:
ahothan 2018-06-13 06:44:10 -07:00
parent ed33269ba4
commit fc42153774
4 changed files with 25 additions and 1 deletions

View File

@ -2,6 +2,14 @@
# This script will build the kloudbuster VM image and the container image under the ./build directory
# canned user/password for direct login
export DIB_DEV_USER_USERNAME=kb
export DIB_DEV_USER_PASSWORD=kb
export DIB_DEV_USER_PWDLESS_SUDO=Y
# Set the data sources to have ConfigDrive only
export DIB_CLOUD_INIT_DATASOURCES="ConfigDrive"
# Check we are in a virtual environment
function check_in_venv {
IN_VENV=$(python -c 'import sys; print hasattr(sys, "real_prefix")')

View File

@ -5,6 +5,12 @@ KloudBuster
KloudBuster Image
Contains all the packages and files needed to run a universal KloudBuster VM
The same image can run using one of the following roles (Assigned from the user-data python program):
- Server VM for a given traffic type (e.g. http server or tcp/udp server)
- Client VM for a given traffic type (e.g. http client or tcp/udp client)
- Redis server (only 1 instance in the client cloud)
The default login on the VM is
- username: kb
- password: kb

View File

@ -51,6 +51,7 @@ sed -i 's/start-stop-daemon\ --start/ulimit\ \-n\ 102400\n\t\0/g' /etc/init.d/ng
# Auto start the KloudBuster Agent, with user-data
sed -i "s/^exit\s0/cd \/kb_test\n\0/g" /etc/rc.local
sed -i "s/^exit\s0/if wget http\:\/\/169.254.169.254\/latest\/user-data; then \:; fi\n\0/g" /etc/rc.local
sed -i 's/^exit\s0/echo `hostname -I` `hostname` >>\/etc\/hosts\n\0/g' /etc/rc.local
sed -i "s/^exit\s0/python kb_vm_agent.py \&\n\0/g" /etc/rc.local
# =================

View File

@ -22,6 +22,7 @@ import struct
import subprocess
from subprocess import Popen
import sys
import syslog
import threading
import time
import traceback
@ -40,7 +41,10 @@ __version__ = '7'
def exec_command(cmd, cwd=None):
p = subprocess.Popen(cmd, cwd=cwd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
(stdout, stderr) = p.communicate()
if p.returncode:
syslog.syslog("Command failed: " + cmd)
if stderr:
syslog.syslog(stderr)
return p.returncode
def refresh_clock(clocks, force_sync=False):
@ -599,11 +603,13 @@ if __name__ == "__main__":
cmd = ['python', 'setup.py', 'develop']
rc = exec_command(cmd, cwd=cwd)
if not rc:
syslog.syslog("Starting kloudbuster HTTP server")
cmd = ['/usr/local/bin/pecan', 'serve', 'config.py']
sys.exit(exec_command(cmd, cwd=cwd))
if user_data.get('role') == 'KB-PROXY':
agent = KBA_Proxy()
syslog.syslog("Starting kloudbuster proxy server")
sys.exit(agent.start_redis_server())
if user_data.get('role').endswith('Server'):
agent = KBA_Server(user_data)
@ -621,17 +627,20 @@ if __name__ == "__main__":
user_data.get('multicast_ports'),
user_data.get('multicast_listener_address_start'))
if agent.config_nginx_server():
syslog.syslog("Starting kloudbuster nginx server")
sys.exit(agent.start_nginx_server())
else:
sys.exit(1)
elif user_data.get('role').endswith('Client'):
if user_data['role'].startswith('HTTP'):
syslog.syslog("Starting kloudbuster HTTP client")
agent = KBA_HTTP_Client(user_data)
elif user_data['role'].startswith('Multicast'):
KB_Instance.add_multicast_route()
refresh_clock(user_data.get('ntp_clocks'), force_sync=True)
agent = KBA_Multicast_Client(user_data)
else:
syslog.syslog("Starting kloudbuster storage client")
agent = KBA_Storage_Client(user_data)
agent.setup_channels()
agent.hello_thread = threading.Thread(target=agent.send_hello)