return (scalar(@elements) > 1);
}
-sub status {
- my ($class, $plugin_config, $zone, $vnetid, $vnet, $status) = @_;
+sub generate_status_message {
+ my ($class, $vnetid, $status, $ifaces) = @_;
my $err_msg = [];
- # ifaces to check
- my $ifaces = [ $vnetid ];
+ return ["vnet is not generated. Please check you reload network task log."] if !$status->{$vnetid}->{status};
foreach my $iface (@{$ifaces}) {
if (!$status->{$iface}->{status}) {
push @$err_msg, "error $iface";
}
}
+
+ return $err_msg;
+}
+
+sub status {
+ my ($class, $plugin_config, $zone, $vnetid, $vnet, $status) = @_;
+
+ my $err_msg = $class->generate_status_message($vnetid, $status);
return $err_msg;
+
}
push @$ifaces, $svlan_iface;
}
- foreach my $iface (@{$ifaces}) {
- if (!$status->{$iface}->{status}) {
- push @$err_msg, "missing $iface";
- } elsif ($status->{$iface}->{status} ne 'pass') {
- push @$err_msg, "error $iface";
- }
- }
+ $err_msg = $class->generate_status_message($vnetid, $status, $ifaces);
return $err_msg;
}
return $config;
}
-sub status {
- my ($class, $plugin_config, $zone, $vnetid, $vnet, $status) = @_;
-
- # ifaces to check
- my $ifaces = [ $vnetid ];
- my $err_msg = [];
- foreach my $iface (@{$ifaces}) {
- if (!$status->{$iface}->{status}) {
- push @$err_msg, "missing $iface";
- } elsif ($status->{$iface}->{status} ne 'pass') {
- push @$err_msg, "error iface $iface";
- }
- }
- return $err_msg;
-}
-
-
sub vnet_update_hook {
my ($class, $vnet_cfg, $vnetid, $zone_cfg) = @_;
push @$ifaces, $vnet_uplinkpeer;
}
- foreach my $iface (@{$ifaces}) {
- if (!$status->{$iface}->{status}) {
- push @$err_msg, "missing $iface";
- } elsif ($status->{$iface}->{status} ne 'pass') {
- push @$err_msg, "error iface $iface";
- }
- }
+ $err_msg = $class->generate_status_message($vnetid, $status, $ifaces);
return $err_msg;
}