<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">
On Mar 29, 2014, at 2:02 PM, Gary Duan <<a href="mailto:garyduan@gmail.com">garyduan@gmail.com</a>> wrote:<br>
<div><br class="Apple-interchange-newline">
<blockquote type="cite">
<div dir="ltr">I guess you need bind the port you just create. </div>
</blockquote>
<div><br>
</div>
PCM: Can you elaborate on what is needed for the binding?</div>
<div><br>
</div>
<div>In the call to create the port in Neutron, the script passes in an additional dict item for binding (n bold):</div>
<div><br>
</div>
<div>
<div>p_spec = {'port': {'admin_state_up': True,</div>
<div>                   'name': port_name,</div>
<div>                   'network_id': nw_id,</div>
<div>                   'mac_address': mac_addr,</div>
<div><b>                   'binding:host_id': hostname,</b></div>
<div>                   'device_id': vm_uuid,</div>
<div>                   'device_owner': 'compute:None'}}</div>
<div><br>
</div>
<div><br>
</div>
<div>Is there more action that is needed?</div>
<div><br>
</div>
<div><br>
</div>
</div>
<div>
<blockquote type="cite">
<div dir="ltr">Also, the port need to be plugged into the VM, right? I don't see that in the code. Maybe you are doing it outside of OpenStack.</div>
</blockquote>
<div><br>
</div>
PCM: Not sure I understand how this all hooks up, as I’m still trying to figure out these scripts I acquired.  Essentially, the VM is started by KVM and scripts are associated with each of the interfaces. The scripts handle I/F up and make calls to Neutron
 (or Neutron/Nova) for hooking into Neutron. I guess it is hooked to the VM by the I/F up handling?</div>
<div><br>
</div>
<div>With the original setup, there were three scripts to hook up the three interfaces in the VM…</div>
<div><br>
</div>
<div>One uses br-ex and all Neutron calls. It connects the interface, I can ping on it and it shows up with an IP in Neutron port list (though port-show says it is down). The port is used by the VM to access the “public” network that devstack creates (e.g.
 172.24.4.13, with Neutron router at 1712.24.4.11).</div>
<div><br>
</div>
<div>Another uses br-int and all Neutron calls too, for a management port of the VM. It too pings fine, and is used by a Neutron agent to send REST messages to the VM (e.g. 192.168.200.2). We also can telnet to that I/F from the host.</div>
<div><br>
</div>
<div>The third, uses br-int and originally used Neutron to create the port and Nova to plug the VIF. It would connect to the “private” network that devstack had created and gives the VM access to that private network. Neutron’s port-show would indicate the
 port is active, had an IP (10.1.0.6), and pinging worked fine.</div>
<div><br>
</div>
<div>It looks like, since two weeks ago, Nova changed to use an object for the VIF, instead of a dict and this code no longer works for this third script. I *thought* maybe I could use the same “all neutron” code for this interface too. I took the original
 script and replaced the plugging part with the same logic that the br-ex script used for plugging the VIF. IT doesn’t show an error, but the interface is reporting as down and (obviously) pings are not working.</div>
<div><br>
</div>
<div>I’m not sure if I’m missing some step on this third script or if I have to use Nova for this interface (not sure why the original scripts use Nova on this one).</div>
<div><b>Anyone have any thoughts on why Nova may be needed in this case ore what I’m missing?</b></div>
<div><br>
</div>
<div>Here is the full original script for the br-ex interface (works) (the management interface is the same with br-int vs be-ex set as the br_name) :</div>
<div><br>
</div>
<div>
<div><font face="Courier New">#!/usr/bin/python</font></div>
<div><font face="Courier New"><br>
</font></div>
<div><font face="Courier New">import sys</font></div>
<div><font face="Courier New"><br>
</font></div>
<div><font face="Courier New">from oslo.config import cfg</font></div>
<div><font face="Courier New">import neutron.openstack.common.gettextutils as gtutil</font></div>
<div><font face="Courier New">gtutil.install('')</font></div>
<div><font face="Courier New">import neutron.agent.linux.interface as vif_driver</font></div>
<div><font face="Courier New">from neutronclient.neutron import client as qclient</font></div>
<div><font face="Courier New">import neutronclient.common.exceptions as qcexp</font></div>
<div><font face="Courier New">from neutron.agent.common import config</font></div>
<div><font face="Courier New"><br>
</font></div>
<div><font face="Courier New"># Arg 1: controller host</font></div>
<div><font face="Courier New"># Arg 2: name of admin user</font></div>
<div><font face="Courier New"># Arg 3: admin user password</font></div>
<div><font face="Courier New"># Arg 4: tenant name</font></div>
<div><font face="Courier New"># Arg 5: uuid of VM</font></div>
<div><font face="Courier New"># Arg 6: MAC address of tap interface</font></div>
<div><font face="Courier New"># Arg 7: name of tap interface</font></div>
<div><font face="Courier New"><br>
</font></div>
<div><font face="Courier New">host = sys.argv[1]</font></div>
<div><font face="Courier New">user = sys.argv[2]</font></div>
<div><font face="Courier New">pw = sys.argv[3]</font></div>
<div><font face="Courier New">tenant = sys.argv[4]</font></div>
<div><font face="Courier New">vm_uuid = sys.argv[5]</font></div>
<div><font face="Courier New">mac_addr = sys.argv[6]</font></div>
<div><font face="Courier New">interface = sys.argv[7]</font></div>
<div><font face="Courier New"><br>
</font></div>
<div><font face="Courier New">KEYSTONE_URL='<a href="http://'">http://'</a> + host + ':5000/v2.0'</font></div>
<div><font face="Courier New"><br>
</font></div>
<div><font face="Courier New">qc = qclient.Client('2.0', auth_url=KEYSTONE_URL, username=user,</font></div>
<div><font face="Courier New">tenant_name=tenant, password=pw)</font></div>
<div><font face="Courier New"><br>
</font></div>
<div><font face="Courier New">prefix, net_name = interface.split('__')</font></div>
<div><font face="Courier New">port_name = net_name + '_p'</font></div>
<div><font face="Courier New">try:</font></div>
<div><font face="Courier New">    nw_id = qc.list_networks(name=net_name)['networks'][0]['id']</font></div>
<div><font face="Courier New">except qcexp.NeutronClientException as e:</font></div>
<div><font face="Courier New">    print >> sys.stderr, e</font></div>
<div><font face="Courier New">    print >> sys.stderr, 'Number of arguments:', len(sys.argv), 'arguments.'</font></div>
<div><font face="Courier New">    print >> sys.stderr, 'Argument List:', str(sys.argv)</font></div>
<div><font face="Courier New">    exit(1)</font></div>
<div><font face="Courier New"><br>
</font></div>
<div><font face="Courier New">p_spec = {'port': {'admin_state_up': True,</font></div>
<div><font face="Courier New">                   'name': port_name,</font></div>
<div><font face="Courier New">                   'network_id': nw_id,</font></div>
<div><font face="Courier New">                   'mac_address': mac_addr,</font></div>
<div><font face="Courier New">                   'device_id': vm_uuid,</font></div>
<div><font face="Courier New">                   'device_owner': 'compute:None'}}</font></div>
<div><font face="Courier New"><br>
</font></div>
<div><font face="Courier New">try:</font></div>
<div><font face="Courier New">    port = qc.create_port(p_spec)</font></div>
<div><font face="Courier New">except qcexp.NeutronClientException as e:</font></div>
<div><font face="Courier New">    print >> sys.stderr, e</font></div>
<div><font face="Courier New">    exit(1)</font></div>
<div><font face="Courier New"><br>
</font></div>
<div><font face="Courier New">port_id = port['port']['id']</font></div>
<div><font face="Courier New"><b>br_name = 'br-ex'</b></font></div>
<div><font face="Courier New"><br>
</font></div>
<div><font face="Courier New">conf = cfg.CONF</font></div>
<div><font face="Courier New">config.register_root_helper(conf)</font></div>
<div><font face="Courier New">conf.register_opts(vif_driver.OPTS)</font></div>
<div><font face="Courier New"><br>
</font></div>
<div><font face="Courier New">driver = vif_driver.OVSInterfaceDriver(cfg.CONF)</font></div>
<div><font face="Courier New">driver.plug(nw_id, port_id, interface, mac_addr, br_name)</font></div>
<div><font face="Courier New"><br>
</font></div>
<div><font face="Courier New">print br_name, port_name, port_id, net_name, nw_id</font></div>
<div><br>
</div>
<div><br>
</div>
</div>
<div>Here is the full original script for the br-int interface (no longer works):</div>
<div><br>
</div>
<div>
<div><font face="Courier New">#!/usr/bin/python</font></div>
<div><font face="Courier New"><br>
</font></div>
<div><font face="Courier New">import socket</font></div>
<div><font face="Courier New">import sys</font></div>
<div><font face="Courier New"><br>
</font></div>
<div><font face="Courier New">import nova.openstack.common.gettextutils as gtutil</font></div>
<div><font face="Courier New">gtutil.install('')</font></div>
<div><font face="Courier New">import nova.virt.libvirt.vif as vif_driver</font></div>
<div><font face="Courier New">from nova.network import linux_net</font></div>
<div><font face="Courier New">from nova.network import model as network_model</font></div>
<div><font face="Courier New">from neutronclient.neutron import client as qclient</font></div>
<div><font face="Courier New">import neutronclient.common.exceptions as qcexp</font></div>
<div><font face="Courier New"><br>
</font></div>
<div><font face="Courier New"># LOG = logging.getLogger(__name__)</font></div>
<div><font face="Courier New"><br>
</font></div>
<div><font face="Courier New"># Arg 1: controller host</font></div>
<div><font face="Courier New"># Arg 2: name of admin user</font></div>
<div><font face="Courier New"># Arg 3: admin user password</font></div>
<div><font face="Courier New"># Arg 4: tenant name</font></div>
<div><font face="Courier New"># Arg 5: uuid of VM</font></div>
<div><font face="Courier New"># Arg 6: MAC address of tap interface</font></div>
<div><font face="Courier New"># Arg 7: hostname</font></div>
<div><font face="Courier New"># Arg 8: name of tap interface</font></div>
<div><font face="Courier New"><br>
</font></div>
<div><font face="Courier New">host = sys.argv[1]</font></div>
<div><font face="Courier New">user = sys.argv[2]</font></div>
<div><font face="Courier New">pw = sys.argv[3]</font></div>
<div><font face="Courier New">tenant = sys.argv[4]</font></div>
<div><font face="Courier New">vm_uuid = sys.argv[5]</font></div>
<div><font face="Courier New">mac_addr = sys.argv[6]</font></div>
<div><font face="Courier New">hostname = sys.argv[7]</font></div>
<div><font face="Courier New">interface = sys.argv[8]</font></div>
<div><font face="Courier New"><br>
</font></div>
<div><font face="Courier New">KEYSTONE_URL='<a href="http://'">http://'</a> + host + ':5000/v2.0'</font></div>
<div><font face="Courier New"><br>
</font></div>
<div><font face="Courier New">qc = qclient.Client('2.0', auth_url=KEYSTONE_URL, username=user,</font></div>
<div><font face="Courier New">tenant_name=tenant, password=pw)</font></div>
<div><font face="Courier New"><br>
</font></div>
<div><font face="Courier New">prefix, net_name = interface.split('__')</font></div>
<div><font face="Courier New">port_name = net_name + '_p'</font></div>
<div><font face="Courier New">try:</font></div>
<div><font face="Courier New">    nw_id = qc.list_networks(name=net_name)['networks'][0]['id']</font></div>
<div><font face="Courier New">except qcexp.NeutronClientException as e:</font></div>
<div><font face="Courier New">    print >> sys.stderr, e</font></div>
<div><font face="Courier New">    print >> sys.stderr, 'Number of arguments:', len(sys.argv), 'arguments.'</font></div>
<div><font face="Courier New">    print >> sys.stderr, 'Argument List:', str(sys.argv)</font></div>
<div><font face="Courier New">    exit(1)</font></div>
<div><font face="Courier New"><br>
</font></div>
<div><font face="Courier New">p_spec = {'port': {'admin_state_up': True,</font></div>
<div><font face="Courier New">                   'name': port_name,</font></div>
<div><font face="Courier New">                   'network_id': nw_id,</font></div>
<div><font face="Courier New">                   'mac_address': mac_addr,</font></div>
<div><font face="Courier New">                   'binding:host_id': hostname,</font></div>
<div><font face="Courier New">                   'device_id': vm_uuid,</font></div>
<div><font face="Courier New">                   'device_owner': 'compute:None'}}</font></div>
<div><font face="Courier New"><br>
</font></div>
<div><font face="Courier New">try:</font></div>
<div><font face="Courier New">    port = qc.create_port(p_spec)</font></div>
<div><font face="Courier New">except qcexp.NeutronClientException as e:</font></div>
<div><font face="Courier New">    print >> sys.stderr, e</font></div>
<div><font face="Courier New">    exit(1)</font></div>
<div><font face="Courier New"><br>
</font></div>
<div><font face="Courier New">port_id = port['port']['id']</font></div>
<div><font face="Courier New"><br>
</font></div>
<div><font face="Courier New"><b>instance = {'uuid': vm_uuid}</b></font></div>
<div><font face="Courier New"><b>network = {'bridge': 'br-int'}</b></font></div>
<div><font face="Courier New"><b>vif = {'id': port_id,</b></font></div>
<div><font face="Courier New"><b>       'address': mac_addr,</b></font></div>
<div><font face="Courier New"><b>       'network': network,</b></font></div>
<div><font face="Courier New"><b>       'type': network_model.VIF_TYPE_OVS}</b></font></div>
<div><font face="Courier New"><b><br>
</b></font></div>
<div><font face="Courier New"><b># For OVS</b></font></div>
<div><font face="Courier New"><b># driver = vif_driver.LibvirtHybridOVSBridgeDriver({})</b></font></div>
<div><font face="Courier New"><b># For ML2 plugin</b></font></div>
<div><font face="Courier New"><b>driver = vif_driver.LibvirtGenericVIFDriver({})</b></font></div>
<div><font face="Courier New"><b>driver.plug(instance, vif)</b></font></div>
<div><font face="Courier New"><b><br>
</b></font></div>
<div><font face="Courier New"><b>br_name = driver.get_br_name(port_id)</b></font></div>
<div><font face="Courier New"><br>
</font></div>
<div><font face="Courier New">print br_name, port_name, port_id, net_name, nw_id</font></div>
<div><br>
</div>
</div>
<div>
<div><br class="webkit-block-placeholder">
</div>
<div>The bold text was changed to set br_name to ‘br-int’ and use the same calling as in the br-ex example.</div>
<div><br>
</div>
<div>Thanks!</div>
<div><br>
</div>
<div><br>
</div>
<div>
<div>
<div>PCM (Paul Michali)</div>
<div><br>
</div>
<div>MAIL …..…. <a href="mailto:pcm@cisco.com">pcm@cisco.com</a></div>
<div>IRC ……..… pcm_ (<a href="http://irc.freenode.com">irc.freenode.com</a>)</div>
<div>TW ………... @pmichali</div>
<div>GPG Key … 4525ECC253E31A83</div>
<div>Fingerprint .. 307A 96BB 1A4C D2C7 931D 8D2D 4525 ECC2 53E3 1A83</div>
</div>
<div><br>
</div>
</div>
</div>
<div><br>
</div>
<div>
<blockquote type="cite">
<div dir="ltr">
<div><br>
</div>
<div>Thanks,</div>
<div>Gary</div>
</div>
<div class="gmail_extra"><br>
<br>
<div class="gmail_quote">On Fri, Mar 28, 2014 at 3:15 PM, Paul Michali (pcm) <span dir="ltr">
<<a href="mailto:pcm@cisco.com" target="_blank">pcm@cisco.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="word-wrap:break-word">Hi,
<div><br>
</div>
<div>I have a VM that I start up outside of OpenStack (as a short term solution, until we get it working inside a Nova VM), using KVM. It has scrips associated with the three interfaces that are created, to hook this VM into Neutron. One I/F is on br-ex (connected
 to the “public" network for DevStack), another to br-int (connected to a management network that is created), and a third is connected to br-int (connected to the “private” network for DevStack). It’s understood these are hacks to get things going and can
 be brittle.  With DevStack, I have a vanilla localrc, so using ML2, without any ML2 settings specified.</div>
<div><br>
</div>
<div>Now, the first two scripts use internal Neutron client calls to create the port, and then plug the VIF. The third, uses Neutron to create the port, and then Nova to plug the VIF. I don’t know why - I inherited the scripts.</div>
<div><br>
</div>
<div>On one system, where Nova is based on commit b3e2e05 (10 days ago), this all works just peachy. Interfaces are hooked in and I can ping to my hearts content. On another system, that I just reimaged today, using the latest and greatest OpenStack projects,
 the third script fails.</div>
<div><br>
</div>
<div>I talked to Nova folks, and the vic is now an object, instead of a plain dict, and therefore calls on the object fail (as the script just provides a dict). I started trying to convert the vif to an object, but in discussing with a co-worker, we thought
 that we could too use Neutron calls for all of the setup of this third interface.</div>
<div><br>
</div>
<div>Well, I tried, and the port is created, but unlike the other system, the port is DOWN, and I cannot ping to or from it (the other ports still work fine, with this newer OpenStack repo). One difference is that the port is showing  {"port_filter": true,
 "ovs_hybrid_plug": true} for binding:vif_details, in the neutron port-show output. On the older system this is empty (so must be new changes in Neutron?)</div>
<div><br>
</div>
<div><br>
</div>
<div>Here is the Neutron based code (trimmed) to do the create and plugging:</div>
<div><br>
</div>
<div>
<div>import neutron.agent.linux.interface as vif_driver</div>
<div>from neutronclient.neutron import client as qclient</div>
<div><br>
</div>
<div>qc = qclient.Client('2.0', auth_url=KEYSTONE_URL, username=user, tenant_name=tenant, password=pw)</div>
<div><br>
</div>
<div>prefix, net_name = interface.split('__')</div>
<div>port_name = net_name + '_p'</div>
<div>try:</div>
<div>    nw_id = qc.list_networks(name=net_name)['networks'][0]['id']</div>
<div>except qcexp.NeutronClientException as e:</div>
<div>    …</div>
<div><br>
</div>
<div>p_spec = {'port': {'admin_state_up': True,</div>
<div>                   'name': port_name,</div>
<div>                   'network_id': nw_id,</div>
<div>                   'mac_address': mac_addr,</div>
<div>                   'binding:host_id': hostname,</div>
<div>                   'device_id': vm_uuid,</div>
<div>                   'device_owner': 'compute:None'}}</div>
<div><br>
</div>
<div>try:</div>
<div>    port = qc.create_port(p_spec)</div>
<div>except qcexp.NeutronClientException as e:</div>
<div>    ...</div>
<div><br>
</div>
<div>port_id = port['port']['id']</div>
<div>br_name = 'br-int'</div>
<div><br>
</div>
<div>conf = cfg.CONF</div>
<div>config.register_root_helper(conf)</div>
<div>conf.register_opts(vif_driver.OPTS)</div>
<div><br>
</div>
<div>driver = vif_driver.OVSInterfaceDriver(cfg.CONF)</div>
<div>driver.plug(nw_id, port_id, interface, mac_addr, br_name)</div>
</div>
<div><br>
</div>
<div>Finally, here are the questions (hope you stuck with the long message)…</div>
<div><br>
</div>
<div><b>Any idea why the neutron version is not working?</b> I know there were a bunch of recent changes.</div>
<div><b>Is there a way for me to turn off the ova_hybrid_plug and port_filter flags? Should I?</b></div>
<div><b>Should I go back to using Nova and build a VIF object?</b></div>
<div><b>If so, any reason why the Neutron version would not work?</b></div>
<div><b>Is there a way to do a similar thing, but via using Northbound APIs (so it isn’t as brittle)?</b></div>
<div><br>
</div>
<div>Thanks in advance!</div>
<div><br>
</div>
<div>
<div>
<div>
<div>PCM (Paul Michali)</div>
<div><br>
</div>
<div>MAIL …..…. <a href="mailto:pcm@cisco.com" target="_blank">pcm@cisco.com</a></div>
<div>IRC ……..… pcm_ (<a href="http://irc.freenode.com/" target="_blank">irc.freenode.com</a>)</div>
<div>TW ………... @pmichali</div>
<div>GPG Key … 4525ECC253E31A83</div>
<div>Fingerprint .. 307A 96BB 1A4C D2C7 931D 8D2D 4525 ECC2 53E3 1A83</div>
</div>
<div><br>
</div>
<br>
</div>
<br>
</div>
</div>
<br>
_______________________________________________<br>
OpenStack-dev mailing list<br>
<a href="mailto:OpenStack-dev@lists.openstack.org">OpenStack-dev@lists.openstack.org</a><br>
<a href="http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev" target="_blank">http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev</a><br>
<br>
</blockquote>
</div>
<br>
</div>
_______________________________________________<br>
OpenStack-dev mailing list<br>
<a href="mailto:OpenStack-dev@lists.openstack.org">OpenStack-dev@lists.openstack.org</a><br>
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev<br>
</blockquote>
</div>
<br>
</body>
</html>