<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">On 01/10/2014 09:30 PM, Aline Manera
      wrote:<br>
    </div>
    <blockquote cite="mid:52CFF5EE.4020902@linux.vnet.ibm.com"
      type="cite">
      <meta content="text/html; charset=ISO-8859-1"
        http-equiv="Content-Type">
      <div class="moz-cite-prefix">On 12/30/2013 01:13 AM, Sheldon
        wrote:<br>
      </div>
      <blockquote cite="mid:52C0E4F0.3040108@linux.vnet.ibm.com"
        type="cite">
        <meta http-equiv="content-type" content="text/html;
          charset=ISO-8859-1">
        now we have support network&nbsp;
        get/create/delete/activate/deactivate<br>
        <br>
        Now we need to support the <a moz-do-not-send="true"
href="https://github.com/kimchi-project/kimchi/wiki/customize-VM#organization-of-sub-resources-and-rest-api-exposition">attach/detach/</a>
        a Network to a guest. <br>
        And get the info of Network attached to a guest.<br>
        <br>
        <br>
        libvirt supports several types of network interfaces:<br>
        'bridge','network','user','ethernet','direct','hostdev','mcast',
        'server', 'client'<br>
        <br>
        but there is not a unique "name" attribute for "interface"
        element.(<a moz-do-not-send="true"
          href="http://libvirt.org/formatdomain.html#elementsNICS">more
          libvirt network interfaces info</a>)<br>
        <br>
        That is not good to define our REST API.<br>
        <br>
        But for "network" type resource, there is a "network" attribute
        of "source" resource. <br>
        And the value of "network" attribute&nbsp; is the name of network
        that we defined by /networks POST method.<br>
        <br>
        the "network" type + "network" attribute is unique.<br>
        <br>
        We can define the Network Interfaces like this to support
        "network" type Interfaces:<br>
        GET /vms/*name*/Interfaces?type=network&amp;network="default"<br>
        But this is not RESTFUL.<br>
        <br>
        <br>
        Maybe We can also name a Network Interface by the Interface mac.
        <br>
        The mac is unique.<br>
        GET /vms/*name*/Interfaces/mac<br>
        <br>
        <br>
      </blockquote>
      <br>
      I think using the mac address is enough for us.<br>
      <br>
      I'd also suggest to use 'ifaces' instead of 'Interfaces'<br>
      <br>
      # list the iface info<br>
      GET /vms/&lt;name&gt;/ifaces/&lt;mac&gt;<br>
      <br>
      # attach new iface<br>
      POST /vms/&lt;name&gt;/ifaces/&lt;mac&gt; {network:
      &lt;network-id&gt;}<br>
    </blockquote>
    POST /vms/&lt;name&gt;/ifaces/ {network: &lt;network-id&gt;} ?<br>
    <blockquote cite="mid:52CFF5EE.4020902@linux.vnet.ibm.com"
      type="cite"> <br>
      # dettach a iface<br>
      DELETE /vms/&lt;name&gt;/ifaces/&lt;mac&gt;<br>
      <br>
      <blockquote cite="mid:52C0E4F0.3040108@linux.vnet.ibm.com"
        type="cite"> The best way for user is get the NICS name in
        guest. such as eth0, eth1....<br>
        GET /vms/*name*/Interfaces/eth0 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <br>
        GET /vms/*name*/Interfaces/eth1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>
        <br>
        But there is a problem, we need get the nic name and mac from
        guest. <br>
        and Make a map in kimchi DB. <br>
        also the nic name may change, we need&nbsp; make the map consistence
        with guest nic name. <br>
        <br>
      </blockquote>
      <br>
      I think it is not needed.<br>
      Only the mac address should be enough.<br>
      Just for reference: I also looked at virt-manager and it doesn't
      display information <br>
      about nic name, only mac and network name and type.<br>
      <br>
      <br>
      <blockquote cite="mid:52C0E4F0.3040108@linux.vnet.ibm.com"
        type="cite"> <br>
        <pre class="moz-signature" cols="72">-- 
Sheldon Feng(&#20911;&#23569;&#21512;)<a moz-do-not-send="true" class="moz-txt-link-rfc2396E" href="mailto:shaohef@linux.vnet.ibm.com">&lt;shaohef@linux.vnet.ibm.com&gt;</a>
IBM Linux Technology Center</pre>
      </blockquote>
      <br>
    </blockquote>
    <br>
    <br>
    <pre class="moz-signature" cols="72">-- 
Thanks and best regards!

Sheldon Feng(&#20911;&#23569;&#21512;)<a class="moz-txt-link-rfc2396E" href="mailto:shaohef@linux.vnet.ibm.com">&lt;shaohef@linux.vnet.ibm.com&gt;</a>
IBM Linux Technology Center</pre>
  </body>
</html>