Skip to content

Commit

Permalink
[WIP] new console code
Browse files Browse the repository at this point in the history
  • Loading branch information
M0ses committed Feb 16, 2017
1 parent 9f6c6e5 commit 53275b6
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 89 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ install:
unrpm \
telnet_login_wrapper \
build-validate-params \
openstack-console \
$(DESTDIR)$(pkglibdir)
install -m755 emulator/emulator.sh $(DESTDIR)$(pkglibdir)/emulator/
install -m644 Build/*.pm $(DESTDIR)$(pkglibdir)/Build
Expand Down
15 changes: 14 additions & 1 deletion build-vm-openstack
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@ cloud_volume_detach_openstack() {
local VM_SERVER=${1:37:36}
local VM_VOL_ID=${1:0:36}

if [ -z "$VM_SERVER" -o -z "$VM_VOL_ID" ];then
# Cannot proceed anyway - guess volume never got attached
echo "__not_attached__"
return 0
fi

# needed at all?
$NOVACLIENT volume-detach "$VM_SERVER" "$VM_VOL_ID"

Expand Down Expand Up @@ -256,9 +262,16 @@ vm_startup_openstack() {
--poll "$VM_WORKER" || cleanup_and_exit 3\
`
WS_URL=`$NOVACLIENT get-serial-console $VM_WORKER|grep serial |perl -p -e 's#.*(ws://.*) \|#$1#'`

while [ -z "$WS_URL" -a $COUNTER -gt 0 ];do
WS_URL=`$NOVACLIENT get-serial-console $VM_WORKER|grep serial |perl -p -e 's#.*(ws://.*) \|#$1#'`
sleep 1
COUNTER=$(($COUNTER - 1))
done

VM_BUILD_ID=`_get_field "$OUTPUT" id`

if ! $BUILD_DIR/os-console/client "${WS_URL}";then
if ! $BUILD_DIR/openstack-console "${WS_URL}";then
$NOVACLIENT delete $VM_BUILD_ID
cleanup_and_exit 3
else
Expand Down
21 changes: 21 additions & 0 deletions openstack-console
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/python

import websocket
import sys

if len(sys.argv) != 2:
sys.exit("usage: openstack-console <url>")
ws = websocket.create_connection(sys.argv[1],
header={'Sec-WebSocket-Protocol: binary'})
buf = ''
while True:
data = ws.recv()
sys.stdout.write(data)
if not ws.connected:
sys.stdout.write("[connection closed]\n")
break
buf += data
buf = buf[-256:]
if re.searcg("[\r\n]\[\s*[0-9\.]*]\s+reboot: Power down", buf):
break
ws.close()
88 changes: 0 additions & 88 deletions os-console/client

This file was deleted.

0 comments on commit 53275b6

Please sign in to comment.