虚机配置vip命令行配置

测试脚本:
import os
import re
import urllib
from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler


class TestHTTPHandler(BaseHTTPRequestHandler):
def do_GET(self):
templateStr = '''
<html>
<head>
<title>QR Link Generator</title>
</head>
<body>
%s
<br>
<br>
<form action="/qr" name=f method="GET"><input maxLength=1024 size=70
name=s value="" title="Text to QR Encode"><input type=submit
value="Show QR" name=qr>
</form>
</body>
</html> '''


pattern = re.compile(r'/qr\?s=([^\&]+)\&qr=Show\+QR')
match = pattern.match(self.path)
qrImg = ''

if match:
qrImg = '<img src="http://chart.apis.google.com/chart?chs=300x300&cht=qr&choe=UTF-8&chl=' + match.group(1) + '" /><br />' + urllib.unquote(match.group(1))

self.protocal_version = 'HTTP/1.1'
self.send_response(200)
self.send_header("Welcome", "Contect")
self.end_headers()
self.wfile.write(templateStr % qrImg)

def start_server(port):
http_server = HTTPServer(('', int(port)), TestHTTPHandler)
http_server.serve_forever()
start_server(8000)

openstack security group rule create --proto tcp --dst-port 8000 default

#neutron port-create --fixed-ip ip_address=vip network-id
neutron port-create --fixed-ip ip_address=10.192.79.199 991646f2-279a-4674-b591-3cde9148f943

#neutron port-show vm-port-id
neutron port-show d0f1f5be-6f64-4c30-aef2-6bdc6ba2cd1a

#neutron port-update --allowed-address-pair ip_address=vip vm-port-id
neutron port-update --allowed-address-pair ip_address=10.192.79.199 d0f1f5be-6f64-4c30-aef2-6bdc6ba2cd1a

扫描二维码关注公众号,回复: 5222682 查看本文章

ifconfig eth0:0 10.192.79.199 netmask 255.255.255.0 up

ping telnet 10.192.79.199
telnet 10.192.79.199 8000

telnet: connect to address xxx: No route to host
关闭虚机上的防火墙(这个与实ip还是虚ip没关系)

猜你喜欢

转载自www.cnblogs.com/liuhongru/p/10399827.html