Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue #150: Modified the behaviour of few "tink hardware cli" #207

Merged
merged 2 commits into from
Jul 10, 2020

Conversation

parauliya
Copy link
Contributor

@parauliya parauliya commented Jul 6, 2020

Description

Following are the change in this commit

  1. tink hardware mac <mac address> will provide only relevent information instead of complete hardware json
  2. tink hardware ip <ip address> will provide only relevent information instead of complete hardware json
  3. There will be a flag in both of the above clis (--details) or (-d) which can be provided to get the complete hardware data
  4. tink hardware all cli has been renamed to tink hardware list
  5. The above cli will only list the relevent information (which is 'hardware-id', 'mac address', 'ip address' and 'hostname for now) instead of providing the complete json of all the hardware present in the database.

Why is this needed

Fixes: #150

How Has This Been Tested?

I have tested this locally by pushing the hardware data for two different hardware using tink hardware push command and then try to run the clis mentioned in the above description.
Following are the output of the commands.
1. tink hardware list

+--------------------------------------+-------------------+-------------+-----------+
| ID                                   | MAC ADDRESS       | IP ADDRESS  | HOSTNAME  |
+--------------------------------------+-------------------+-------------+-----------+
| f9f56dff-098a-4c5f-a51c-19ad35de85d2 | 98:03:9b:89:d7:da | 192.168.1.4 | localhost |
| f9f56dff-098a-4c5f-a51c-19ad35de85d1 | 98:03:9b:89:d7:ba | 192.168.1.5 | worker_1 |
+--------------------------------------+-------------------+-------------+-----------+

With the help of above command you will get the list of hardware present in the database. Now you can run following commands:

  1. a. tink hardware mac 98:03:9b:89:d7:da
+-------------+--------------------------------------+
| FIELD NAME  | VALUE                                |
+-------------+--------------------------------------+
| ID          | f9f56dff-098a-4c5f-a51c-19ad35de85d2 |
| MAC Address | 98:03:9b:89:d7:da                    |
| IP Address  | 192.168.1.4                          |
| Hostname    | localhost                            |
+-------------+--------------------------------------+

b.  tink hardware mac 98:03:9b:89:d7:da  -d ( provide -d flag )

{"metadata":{"instance":{},"facility":{"facility_code":"onprem"}},"network":{"interfaces":[{"dhcp":{"mac":"98:03:9b:89:d7:da","hostname":"localhost","arch":"x86_64","ip":{"address":"192.168.1.4","netmask":"255.255.255.248","gateway":"192.168.1.1"}},"netboot":{"allow_pxe":true,"allow_workflow":true}}]},"id":"f9f56dff-098a-4c5f-a51c-19ad35de85d2"}

  1. Same thing will be applicable for tink hardware ip command:
    a. tink hardware ip 192.168.1.4
+-------------+--------------------------------------+
| FIELD NAME  | VALUE                                |
+-------------+--------------------------------------+
| ID          | f9f56dff-098a-4c5f-a51c-19ad35de85d2 |
| MAC Address | 98:03:9b:89:d7:da                    |
| IP Address  | 192.168.1.4                          |
| Hostname    | localhost                            |
+-------------+--------------------------------------+

b. tink hardware ip 192.168.1.4 -d ( provide -d flag )

{"metadata":{"instance":{},"facility":{"facility_code":"onprem"}},"network":{"interfaces":[{"dhcp":{"mac":"98:03:9b:89:d7:da","hostname":"localhost","arch":"x86_64","ip":{"address":"192.168.1.4","netmask":"255.255.255.248","gateway":"192.168.1.1"}},"netboot":{"allow_pxe":true,"allow_workflow":true}}]},"id":"f9f56dff-098a-4c5f-a51c-19ad35de85d2"}

  1. And at last the output of tink hardware --help is look like as follows:
tink hardware client

Usage:
  tink hardware [command]

Examples:
tink hardware [command]

Available Commands:
  delete      delete hardware by id
  id          get hardware by id
  ip          get hardware by any associated ip
  list        list all known hardware
  mac         get hardware by any associated mac
  push        push new hardware to tink
  watch       register to watch an id for any changes

Flags:
  -h, --help   help for hardware

Global Flags:
  -f, --facility string   used to build grpc and http urls

Use "tink hardware [command] --help" for more information about a command.

How are existing users impacted? What migration steps/scripts do we need?

There will be a change for existing user for tink hardware as mentioned in the description. There is no need of migration steps or scripts.

@parauliya parauliya added the kind/feature Categorizes issue or PR as related to a new feature. label Jul 6, 2020
@parauliya parauliya self-assigned this Jul 6, 2020
@parauliya parauliya added this to In Progress in Issues List via automation Jul 6, 2020
@parauliya parauliya force-pushed the fix_150 branch 2 times, most recently from 5bec853 to 08e6e2d Compare July 6, 2020 12:14
@parauliya parauliya force-pushed the fix_150 branch 2 times, most recently from 5fb911b to 4102699 Compare July 7, 2020 07:49
DailyAlice added a commit to tinkerbell/tinkerbell.org that referenced this pull request Jul 7, 2020
Removed `all`, and added new responses for `mac` and `ip` to match tinkerbell/tink#207.
@parauliya parauliya force-pushed the fix_150 branch 2 times, most recently from 2a76c92 to 3fd09ec Compare July 8, 2020 07:49
@parauliya parauliya requested a review from Cbkhare July 9, 2020 06:08
@parauliya parauliya force-pushed the fix_150 branch 2 times, most recently from 224ee22 to 1c3960f Compare July 9, 2020 09:07
cmd/tink-cli/cmd/hardware/all.go Outdated Show resolved Hide resolved
cmd/tink-cli/cmd/hardware/ip.go Show resolved Hide resolved
cmd/tink-cli/cmd/hardware/ip.go Outdated Show resolved Hide resolved
…e cli"

Following are the change in this commit
1. `tink hardware mac <mac address>` will provide only relevent information instead of complete hardware json
2. `tink hardware ip <ip address>` will provide only relevent information instead of complete hardware json
3. There will be a flag in both of the above clis (--details) which can be provided to get the complete hardware data
4. `tink hardware all` cli has been renamed to `tink hardware list`
5. The above cli will only list the relevent information (which is 'hardware-id', 'mac address', 'ip address' and 'hostname for now) instead of providing the complete json of all the hardware present in the database.
@gauravgahlot gauravgahlot added the ready-to-merge Signal to Mergify to merge the PR. label Jul 10, 2020
@gauravgahlot gauravgahlot requested review from kqdeng and removed request for nathangoulding and Cbkhare July 10, 2020 04:56
@gauravgahlot gauravgahlot removed the request for review from kqdeng July 10, 2020 04:59
@mergify mergify bot merged commit a68bec0 into tinkerbell:master Jul 10, 2020
Issues List automation moved this from In Progress to Just shipped Jul 10, 2020
@gauravgahlot gauravgahlot deleted the fix_150 branch July 10, 2020 05:01
@mmlb mmlb removed the ready-to-merge Signal to Mergify to merge the PR. label Jan 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature Categorizes issue or PR as related to a new feature.
Projects
No open projects
Issues List
  
Just shipped
Development

Successfully merging this pull request may close these issues.

Modify few tink hardware cli
4 participants