Skip to content

swadm link set-prop broke in structopt -> clap transition #178

@Nieuwejaar

Description

@Nieuwejaar

When swadm migrated from using structopt to clap for its CLI, we lost the ability to disable a link using set-prop:.

root@oxz_switch1:~# swadm link get rear0/0
Port/Link  Media   Speed  FEC  Autoneg  Enabled  State    MAC
rear0/0    Copper  100G   RS   true     true     Unknown  a8:40:25:05:07:03
root@oxz_switch1:~# swadm link set-prop rear0/0 enabled false
error: 0 values required for '[ENABLED]' but 1 was provided

Usage: swadm link set-prop <LINK> enable [ENABLED]

For more information, try '--help'.
root@oxz_switch1:~# swadm link get rear0/0
Port/Link  Media   Speed  FEC  Autoneg  Enabled  State    MAC
rear0/0    Copper  100G   RS   true     true     Unknown  a8:40:25:05:07:03

To disable a link, you now have to use swadm link <link> disable rather than set-prop:

root@oxz_switch1:~# swadm link get rear0/0
Port/Link  Media   Speed  FEC  Autoneg  Enabled  State    MAC
rear0/0    Copper  100G   RS   true     true     Unknown  a8:40:25:05:07:03
root@oxz_switch1:~# swadm link disable rear0/0
root@oxz_switch1:~# swadm link get rear0/0
Port/Link  Media   Speed  FEC  Autoneg  Enabled  State    MAC
rear0/0    Copper  100G   RS   true     false    Unknown  a8:40:25:05:07:03

I believe this is because the explicit parse was omitted:

     /// Set whether the link is enabled.
-    #[structopt(visible_alias = "ena")]
-    Enabled {
-        #[structopt(parse(try_from_str))]
-        enabled: bool,
-    },
+    #[clap(visible_alias = "ena")]
+    Enabled { enabled: bool },

This means that we can't disable autonegotiation, kr mode, nat-only mode, and ipv6 for links at all, since there is no special-case command for them.

Weirdly, we can no longer use set-prop to enable a link either:

root@oxz_switch1:~# swadm link get rear0/0
Port/Link  Media   Speed  FEC  Autoneg  Enabled  State    MAC
rear0/0    Copper  100G   RS   true     false    Unknown  a8:40:25:05:07:03
root@oxz_switch1:~# swadm link set-prop rear0/0 enabled
root@oxz_switch1:~# swadm link get rear0/0
Port/Link  Media   Speed  FEC  Autoneg  Enabled  State    MAC
rear0/0    Copper  100G   RS   true     false    Unknown  a8:40:25:05:07:03
root@oxz_switch1:~# swadm link enable rear0/0
root@oxz_switch1:~# swadm link get rear0/0
Port/Link  Media   Speed  FEC  Autoneg  Enabled  State    MAC
rear0/0    Copper  100G   RS   true     true     Unknown  a8:40:25:05:07:03

The command succeeds, but doesn't actually do anything.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions