« lib/WWW/Hetzner/CLI/Cmd/Volume/Cmd/Resize.pm
↑ Summary
lib/WWW/Hetzner/CLI/Cmd/Volume/Cmd/Attach.pm »
| 1 | package WWW::Hetzner::CLI::Cmd::Network::Cmd::AddRoute; | ||||||||||
| 2 | # ABSTRACT: Add a route to a network | ||||||||||
| 3 | |||||||||||
| 4 | 1 | our $VERSION = '0.102'; | |||||||||
| 5 | |||||||||||
| 6 | 1 | ▶ | use Moo; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 1 | ▶ | use MooX::Cmd; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 1 | ▶ | use MooX::Options protect_argv => 0, usage_string => 'USAGE: hcloud.pl network add-route <id> --destination <cidr> --gateway <ip>'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 1 | with 'WWW::Hetzner::CLI::Role::WaitsForAction'; | |||||||||
| 10 | |||||||||||
| 11 | 1 | option destination => ( | |||||||||
| 12 | is => 'ro', | ||||||||||
| 13 | format => 's', | ||||||||||
| 14 | required => 1, | ||||||||||
| 15 | doc => 'Route destination (e.g. 10.100.0.0/16)', | ||||||||||
| 16 | ); | ||||||||||
| 17 | |||||||||||
| 18 | 1 | option gateway => ( | |||||||||
| 19 | is => 'ro', | ||||||||||
| 20 | format => 's', | ||||||||||
| 21 | required => 1, | ||||||||||
| 22 | doc => 'Gateway IP address', | ||||||||||
| 23 | ); | ||||||||||
| 24 | |||||||||||
| 25 | 1 | ▶ | sub execute { | ||||||||
|
Subroutine
execute: called CC=3 SCAR=11.1
Pod
undocumented
| |||||||||||
| 26 | 1 | my ($self, $args, $chain) = @_; | |||||||||
| 27 | 1 | ▶ | my $id = $args->[0] or die "Usage: hcloud.pl network add-route <id> --destination <cidr> --gateway <ip>\n"; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 28 | |||||||||||
| 29 | 1 | my $main = $chain->[0]; | |||||||||
| 30 | 1 | my $cloud = $main->cloud; | |||||||||
| 31 | |||||||||||
| 32 | 1 | print "Adding route ", $self->destination, " via ", $self->gateway, " to network $id...\n"; | |||||||||
| 33 | 1 | my $action = $cloud->networks->add_route($id, | |||||||||
| 34 | destination => $self->destination, | ||||||||||
| 35 | gateway => $self->gateway, | ||||||||||
| 36 | ); | ||||||||||
| 37 | 1 | $self->handle_action($action); | |||||||||
| 38 | 1 | ▶ | print $self->no_wait ? "Route add requested.\n" : "Route added.\n"; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 39 | } | ||||||||||
| 40 | |||||||||||
| 41 | 1 | 1; | |||||||||
| 42 | |||||||||||
| 43 | __END__ | ||||||||||