CCI-MOC / hil

Hardware Isolation Layer, formerly Hardware as a Service
Apache License 2.0
24 stars 54 forks source link

Cli updates #1040

Closed RobinKaul closed 5 years ago

RobinKaul commented 5 years ago

I have opened a new request so ignore the last one. Here are my changes to the CLI output:

Here is my current output:

-bash-4.2$ hil node list all
+-----------+
| node list |
+-----------+
|   node1   |
|   node2   |
|   node3   |
|   node4   |
+-----------+
-bash-4.2$ 
-bash-4.2$ hil node show node1
MAIN TABLE
+-----------+-------------+
| ATTRIBUTE | INFORMATION |
+-----------+-------------+
|  project  |     proj    |
|    name   |    node1    |
+-----------+-------------+

NIC TABLE
+-----------+---------------------+
| ATTRIBUTE |     INFORMATION     |
+-----------+---------------------+
|   label   |         nic1        |
|  macaddr  |  aa:bb:cc:dd:ee:01  |
|   switch  |       switch1       |
|    port   |       te1/0/11      |
|  networks | network1(vlan/1510) |
|           |                     |
+-----------+---------------------+
+----------+-----------------------+
|  label   |          nic2         |
| macaddr  |   ab:cd:ef:gh:ij:34   |
|  switch  |        switch1        |
|   port   |        te1/0/12       |
| networks | fancy_name(vlan/1512) |
|          |  fibernet(vlan/1513)  |
|          |  network1(vlan/1510)  |
|          |                       |
+----------+-----------------------+
+----------+---------------------+
|  label   |         nic3        |
| macaddr  |  qw:er:ty:ui:op:56  |
|  switch  |       switch1       |
|   port   |       gi1/0/11      |
| networks | internet(vlan/1511) |
|          |                     |
+----------+---------------------+

METADATA TABLE
+----------------+-----------------+
| METADATA LABEL |  METADATA INFO  |
+----------------+-----------------+
|      SSD       |   Samsung_EVO   |
|      RAM       | Kingston_hyperx |
|   Processor    |     Intel_i5    |
|  Power_Supply  |   Corsair_650   |
+----------------+-----------------+
-bash-4.2$ 
-bash-4.2$ hil network list
+--------------+------------+--------------+
| network name | network id | project name |
+--------------+------------+--------------+
|  fancy_name  |    1512    |     proj     |
|   network1   |    1510    |     proj     |
|   internet   |    1511    |     proj     |
|   fibernet   |    1513    |     proj     |
+--------------+------------+--------------+
-bash-4.2$ 
-bash-4.2$ hil network show internet
+-----------------+-------------+
|    Attribute    |     Info    |
+-----------------+-------------+
|      owner      |     proj    |
|                 |             |
|       name      |   internet  |
|                 |             |
|      access     |     proj    |
|                 |             |
|     channels    | vlan/native |
|                 |  vlan/1511  |
|                 |             |
| connected-nodes | node1->nic3 |
|                 | node2->nic4 |
+-----------------+-------------+
-bash-4.2$ 
-bash-4.2$ hil switch list
+-------------+
| switch list |
+-------------+
|   switch1   |
|   switch2   |
+-------------+
-bash-4.2$ 

What are your opinions?

RobinKaul commented 5 years ago

Sorry I forgot to show you the json flags.

-bash-4.2$ hil node show node1 --json
{u'project': u'proj', u'nics': [{u'port': u'te1/0/11', u'switch': u'switch1', u'macaddr': u'aa:bb:cc:dd:ee:01', u'networks': {u'vlan/1510': u'network1'}, u'label': u'nic1'}, {u'port': u'te1/0/12', u'switch': u'switch1', u'macaddr': u'ab:cd:ef:gh:ij:34', u'networks': {u'vlan/1512': u'fancy_name', u'vlan/1513': u'fibernet', u'vlan/1510': u'network1'}, u'label': u'nic2'}, {u'port': u'gi1/0/11', u'switch': u'switch1', u'macaddr': u'qw:er:ty:ui:op:56', u'networks': {u'vlan/1511': u'internet'}, u'label': u'nic3'}], u'name': u'node1', u'metadata': {u'SSD': u'"Samsung_EVO"', u'RAM': u'"Kingston_hyperx"', u'Processor': u'"Intel_i5"', u'Power_Supply': u'"Corsair_650"'}}
-bash-4.2$ 
-bash-4.2$ hil network show internet --json
{u'access': [u'proj'], u'channels': [u'vlan/native', u'vlan/1511'], u'owner': u'proj', u'name': u'internet', u'connected-nodes': {u'node1': [u'nic3'], u'node2': [u'nic4']}}
-bash-4.2$ 
RobinKaul commented 5 years ago

I was able to add a title to the tables instead of having a lousy label text on top. But since I'm looping on the NIC table I wasn't able to remove the title from the individual NIC sections like shown in the previous output. So I just have an empty row between each section. How does this look?

-bash-4.2$ hil node show node1
+-------------------------+
|        MAIN TABLE       |
+-----------+-------------+
| ATTRIBUTE | INFORMATION |
+-----------+-------------+
|  project  |     proj    |
|    name   |    node1    |
+-----------+-------------+
+-----------------------------------+
|             NIC TABLE             |
+-----------+-----------------------+
| ATTRIBUTE |      INFORMATION      |
+-----------+-----------------------+
|   label   |          nic1         |
|  macaddr  |   aa:bb:cc:dd:ee:01   |
|   switch  |        switch1        |
|    port   |        te1/0/11       |
|  networks |  network1(vlan/1510)  |
|           |                       |
|   label   |          nic2         |
|  macaddr  |   ab:cd:ef:gh:ij:34   |
|   switch  |        switch1        |
|    port   |        te1/0/12       |
|  networks | fancy_name(vlan/1512) |
|           |  fibernet(vlan/1513)  |
|           |  network1(vlan/1510)  |
|           |                       |
|   label   |          nic3         |
|  macaddr  |   qw:er:ty:ui:op:56   |
|   switch  |        switch1        |
|    port   |        gi1/0/11       |
|  networks |  internet(vlan/1511)  |
|           |                       |
+-----------+-----------------------+
+----------------------------------+
|          METADATA TABLE          |
+----------------+-----------------+
| METADATA LABEL |  METADATA INFO  |
+----------------+-----------------+
|      SSD       |   Samsung_EVO   |
|      RAM       | Kingston_hyperx |
|   Processor    |     Intel_i5    |
|  Power_Supply  |   Corsair_650   |
+----------------+-----------------+
-bash-4.2$ 
naved001 commented 5 years ago

@radonm suggested that it would be better to have 1 table for node show because that means less scrolling. @apoorvemohan @mosayyebzadeh you guys are heavy users of the HIL CLI, any opinions on this?

RobinKaul commented 5 years ago

@zenhack Yes sorry actually someone else had also worked on the code with me before and I didn't pay attention to this while completing it. I will clean this up and also upload the switch output by tomorrow. Please let me know if you find something else too.

RobinKaul commented 5 years ago

@naved001 before I upload the code for the node table I wanted your input on this since I can't tag Rado for some reason as this was his suggestion. What are your thoughts @apoorvemohan @mosayyebzadeh ?

-bash-4.2$ hil node show node1
+--------------+-----------------------+
|  ATTRIBUTE   |      INFORMATION      |
+--------------+-----------------------+
|   Project    |          proj         |
|     Name     |         node1         |
|              |                       |
|    Label     |          nic1         |
|   Macaddr    |   aa:bb:cc:dd:ee:01   |
|    Switch    |        switch1        |
|     Port     |        te1/0/11       |
|   Networks   |  network1(vlan/1510)  |
|              |                       |
|    Label     |          nic2         |
|   Macaddr    |   ab:cd:ef:gh:ij:34   |
|    Switch    |        switch1        |
|     Port     |        te1/0/12       |
|   Networks   | fancy_name(vlan/1512) |
|              |  fibernet(vlan/1513)  |
|              |  network1(vlan/1510)  |
|              |                       |
|    Label     |          nic3         |
|   Macaddr    |   qw:er:ty:ui:op:56   |
|    Switch    |        switch1        |
|     Port     |        gi1/0/11       |
|   Networks   |  internet(vlan/1511)  |
|              |                       |
|     SSD      |      Samsung_EVO      |
|     RAM      |    Kingston_hyperx    |
|  Processor   |        Intel_i5       |
| Power_Supply |      Corsair_650      |
+--------------+-----------------------+
-bash-4.2$ hil node show node2
+-----------+---------------------+
| ATTRIBUTE |     INFORMATION     |
+-----------+---------------------+
|  Project  |         proj        |
|    Name   |        node2        |
|           |                     |
|   Label   |         nic4        |
|  Macaddr  |  as:df:gh:jk:lz:87  |
|   Switch  |       switch1       |
|    Port   |       gi1/0/12      |
|  Networks | internet(vlan/1511) |
|           |                     |
+-----------+---------------------+
-bash-4.2$ hil node show node3
+-----------+-------------------+
| ATTRIBUTE |    INFORMATION    |
+-----------+-------------------+
|  Project  |        proj       |
|    Name   |       node3       |
|           |                   |
|   Label   |        nic5       |
|  Macaddr  | zx:cv:bn:ma:sd:21 |
|   Switch  |        None       |
|    Port   |        None       |
|  Networks |        None       |
|           |                   |
+-----------+-------------------+
-bash-4.2$ hil node show node4
+-----------+-------------+
| ATTRIBUTE | INFORMATION |
+-----------+-------------+
|  Project  |     None    |
|    Name   |    node4    |
|           |             |
+-----------+-------------+
-bash-4.2$ 
RobinKaul commented 5 years ago

And I know I haven't uploaded the switch code yet but needed input on this too.

-bash-4.2$ hil switch show switch1
+--------------+-----------------------+
|  ATTRIBUTE   |      INFORMATION      |
+--------------+-----------------------+
|     name     |        switch1        |
| capabilities | nativeless-trunk-mode |
|    ports     |        te1/0/11       |
|              |        te1/0/12       |
|              |        gi1/0/11       |
|              |        gi1/0/12       |
|              |        gi1/0/13       |
+--------------+-----------------------+
-bash-4.2$ hil switch show switch2
+--------------+-----------------------+
|  ATTRIBUTE   |      INFORMATION      |
+--------------+-----------------------+
|     name     |        switch2        |
| capabilities | nativeless-trunk-mode |
|    ports     |          None         |
+--------------+-----------------------+
-bash-4.2$ 
radonm commented 5 years ago

One command should display one table (not multiple), so second option looks better to me

RobinKaul commented 5 years ago

Updates:

  1. Variable name changes for node and networks

  2. Output changes

  3. Raw output to json dumps

  4. Correction to node output for connected nodes including link aggregation

  5. Added switch output

  6. Added port output

naved001 commented 5 years ago
  1. Something weird is going on with your commit history.
  2. You should put the updates in the commit message instead of a message here.
  3. you might wanna set your git username on your work machine; right now it says "Cloud User".
  4. You should also put prettytables as an item to be installed in setup.py
naved001 commented 5 years ago

@RobinKaul Do you think you will have time to finish this, or can someone else take over?

RobinKaul commented 5 years ago

@naved001 It'll be better if someone can take over if you're in a pinch for time.

naved001 commented 5 years ago

closing this in favor of #1051