Hammer remove dhcp/tftp proxy from subnet

There doesn’t seem to be a way to remove a smart proxy from a subnet with hammer - hopefully I’m missing something and this is easy.

I’m running:
hammer (2.2.0)

  • hammer_cli_foreman (2.2.0)
  • hammer_cli_foreman_templates (0.2.0)

Foreman 1.23.2

I’ve tried a number of commands, all with the same result:

❯ hammer subnet update --id 55 --dhcp nil
Could not update the subnet:
  Error: smart_proxy not found.
❯ hammer subnet update --id 55 --dhcp ''
Could not update the subnet:
  Error: smart_proxy not found.
❯ hammer subnet update --id 55 --dhcp-id ''
Could not update the subnet:
  Error: Option '--dhcp-id': Numeric value is required..
  See: 'hammer subnet update --help'.
❯ hammer subnet update --id 55 --dhcp-id 0
Could not update the subnet:
  PG::ForeignKeyViolation: ERROR:  insert or update on table "subnets" violates foreign key constraint "subnets_dhcp_id_fk"
  DETAIL:  Key (dhcp_id)=(0) is not present in table "smart_proxies".
  : UPDATE "subnets" SET "dhcp_id" = $1, "updated_at" = $2 WHERE "subnets"."id" = $3
❯ hammer subnet update --id 55 --dhcp-id -1
Could not update the subnet:
  PG::ForeignKeyViolation: ERROR:  insert or update on table "subnets" violates foreign key constraint "subnets_dhcp_id_fk"
  DETAIL:  Key (dhcp_id)=(-1) is not present in table "smart_proxies".
  : UPDATE "subnets" SET "dhcp_id" = $1, "updated_at" = $2 WHERE "subnets"."id" = $3

Hello and welcome to the community!
I refer to @ofedoren’s post from some time ago:

hammer subnet update --id 1 --dhcp-id NIL

Perhaps NIL is worth trying.

API v2, update parameters

1 Like

Ahhh NIL in caps - yes that works, thank you !

1 Like

Excellent!