« lib/WWW/Hetzner/CLI/Cmd/LoadBalancer/Cmd/AddService.pm
↑ Summary
lib/WWW/Hetzner/Robot/API/RDNS.pm »
| 1 | package WWW::Hetzner::CLI::Cmd::Network::Cmd::AddSubnet; | ||||||||||
| 2 | # ABSTRACT: Add a subnet 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-subnet <id> --ip-range <cidr> --type <type> --network-zone <zone>'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 1 | with 'WWW::Hetzner::CLI::Role::WaitsForAction'; | |||||||||
| 10 | |||||||||||
| 11 | 1 | option 'ip_range' => ( | |||||||||
| 12 | is => 'ro', | ||||||||||
| 13 | format => 's', | ||||||||||
| 14 | required => 1, | ||||||||||
| 15 | long_doc => 'ip-range', | ||||||||||
| 16 | doc => 'Subnet IP range (e.g. 10.0.1.0/24)', | ||||||||||
| 17 | ); | ||||||||||
| 18 | |||||||||||
| 19 | 1 | option type => ( | |||||||||
| 20 | is => 'ro', | ||||||||||
| 21 | format => 's', | ||||||||||
| 22 | required => 1, | ||||||||||
| 23 | doc => 'Subnet type: cloud, server, vswitch', | ||||||||||
| 24 | ); | ||||||||||
| 25 | |||||||||||
| 26 | 1 | option 'network_zone' => ( | |||||||||
| 27 | is => 'ro', | ||||||||||
| 28 | format => 's', | ||||||||||
| 29 | required => 1, | ||||||||||
| 30 | long_doc => 'network-zone', | ||||||||||
| 31 | doc => 'Network zone (e.g. eu-central)', | ||||||||||
| 32 | ); | ||||||||||
| 33 | |||||||||||
| 34 | 1 | ▶ | sub execute { | ||||||||
|
Subroutine
execute: called CC=3 SCAR=11.1
Pod
undocumented
| |||||||||||
| 35 | 1 | my ($self, $args, $chain) = @_; | |||||||||
| 36 | 1 | ▶ | my $id = $args->[0] or die "Usage: hcloud.pl network add-subnet <id> --ip-range <cidr> --type <type> --network-zone <zone>\n"; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 37 | |||||||||||
| 38 | 1 | my $main = $chain->[0]; | |||||||||
| 39 | 1 | my $cloud = $main->cloud; | |||||||||
| 40 | |||||||||||
| 41 | 1 | print "Adding subnet ", $self->ip_range, " to network $id...\n"; | |||||||||
| 42 | 1 | my $action = $cloud->networks->add_subnet($id, | |||||||||
| 43 | ip_range => $self->ip_range, | ||||||||||
| 44 | type => $self->type, | ||||||||||
| 45 | network_zone => $self->network_zone, | ||||||||||
| 46 | ); | ||||||||||
| 47 | 1 | $self->handle_action($action); | |||||||||
| 48 | 1 | ▶ | print $self->no_wait ? "Subnet add requested.\n" : "Subnet added.\n"; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 49 | } | ||||||||||
| 50 | |||||||||||
| 51 | 1 | 1; | |||||||||
| 52 | |||||||||||
| 53 | __END__ | ||||||||||