<div dir="ltr"><div><div class="gmail_extra"><div class="gmail_quote">On Thu, Jun 15, 2017 at 10:51 AM, Thawngzapum Lian <span dir="ltr"><<a href="mailto:tlian@salesforce.com" target="_blank">tlian@salesforce.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><font color="#000000" face="Consolas, Lucida Console, monospace"><span style="font-size:12.8px">How to "Add alias or VLAN" to a bond interface? </span></font></div><div><font color="#000000" face="Consolas, Lucida Console, monospace"><span style="font-size:12.8px">It is quite simple using web interface. But having a hard time to do it via CLI.</span></font><br></div><div><font color="#000000" face="Consolas, Lucida Console, monospace"><span style="font-size:12.8px"><br></span></font></div><div><font color="#000000" face="Consolas, Lucida Console, monospace"><span style="font-size:12.8px">I was looking into</span></font></div><div><font color="#000000" face="Consolas, Lucida Console, monospace"><span style="font-size:12.8px">  maas $PROFILE interface update ***</span></font></div><div><font color="#000000" face="Consolas, Lucida Console, monospace"><span style="font-size:12.8px">  </span></font><span style="color:rgb(0,0,0);font-family:Consolas,"Lucida Console",monospace;font-size:12.8px">maas $PROFILE interface link-subnet ***</span></div><div><br></div><div>NO success. </div><div><br></div><div>Can anyone please give a pointer? </div></div></blockquote><div><br></div>Hi Thawngzapum,<div><br></div><div>   I think I can provide some tips.</div><div><br></div><div>   When working with the JSON output from the MAAS CLI, I often use the 'jq' tool to help me make sense of what's important. For example, you could fetch the list of interface links for a particular machine in a similar way that the UI presents them by doing the following (where $SYSTEM_ID is the system_id of your machine):</div><br>$ maas $PROFILE interfaces read $SYSTEM_ID \<div>    | jq '.[] | {id:.id, name:.name, mac:.mac_address, vid:.vlan.vid, fabric:.vlan.fabric, links:.links[] |{id: .id, ip:.ip_address, mode:.mode, subnet:.subnet.cidr}}' --compact-output<div>{"id":138,"name":"eno1","mac":"0c:c4:7a:00:00:fa","vid":100,"fabric":"fabric-0","links":{"id":1966,"ip":null,"mode":"auto","subnet":"<a href="http://192.168.100.0/24">192.168.100.0/24</a>"}}<br><div><br></div><div>    If you have a setup like this, you can add an alias with for a static IP address by doing something like:</div><div><br></div><div>$ maas $PROFILE interface link-subnet $SYSTEM_ID eno1 mode=static subnet=<a href="http://172.16.100.0/24">172.16.100.0/24</a> ip_address=192.168.100.55 \</div><div>    | jq '{id:.id, name:.name, mac:.mac_address, vid:.vlan.vid, fabric:.vlan.fabric, links:.links[] |{id: .id, ip:.ip_address, mode:.mode, subnet:.subnet.cidr}}' --compact-output<br></div><div>{"id":138,"name":"eno1","mac":"0c:c4:7a:00:00:fa","vid":100,"fabric":"fabric-0","links":{"id":1966,"ip":null,"mode":"auto","subnet":"<a href="http://192.168.100.0/24">192.168.100.0/24</a>"}}<br></div><div>{"id":138,"name":"eno1","mac":"0c:c4:7a:00:00:fa","vid":100,"fabric":"fabric-0","links":{"id":1967,"ip":"192.168.100.55","mode":"auto","subnet":"<a href="http://192.168.100.0/24">192.168.100.0/24</a>"}}<br></div><div><br></div><div>   Note that the new static IP address here will be *in addition* to the existing automatic IP address on the subnet.</div></div><div><br></div><div>   Creating a VLAN using the API is a little less friendly. You'll need the unique "id" fields for both the VLAN and the interface. For example, this would create a VLAN:</div><div><br></div><div>$ maas $PROFILE interfaces create-vlan $SYSTEM_ID parent=$INTERFACE_ID vlan=$VLAN_ID<br></div><div class="gmail_extra">...</div><div class="gmail_extra"><br></div><div class="gmail_extra">   In the above example, the $INTERFACE_ID would be 138. Keep in mind that the $VLAN_ID in this example is not the "vid" field; it's the "id" field. (It would be nice if MAAS accepted the VID here, since we already know the fabric, if we know the fabric that the parent interface is in.) You could get a compact listing of fabrics and their VLANs by doing something like the following:</div><div class="gmail_extra"><br></div><div class="gmail_extra">$ maas $PROFILE fabrics read \</div><div class="gmail_extra">    | jq '.[] | {id:.id, fabric_name:.name, vlans:.vlans[] | {id:.id, name:.name, vid:.vid}}' --compact-output</div><div class="gmail_extra"><br></div><div class="gmail_extra">   Hope this helps.</div><div class="gmail_extra"><br></div><div class="gmail_extra">Regards,</div><div class="gmail_extra">Mike</div></div><div> </div></div></div></div></div>