Brocade-BSC
view release on metacpan or search on metacpan
lib/Brocade/BSC/Node/NC/Vrouter/VR5600.pm view on Meta::CPAN
=cut ===================================================================
sub get_firewall_instance_cfg {
my $self = shift;
my $instance = shift;
my $status = new Brocade::BSC::Status;
my $config = undef;
my $url = $self->{ctrl}->get_ext_mount_config_urlpath($self->{name});
$url .= "vyatta-security:security/vyatta-security-firewall:firewall/name/"
. $instance;
my $resp = $self->ctrl_req('GET', $url);
if ($resp->code == HTTP_OK) {
$config = $resp->content;
$status->code($BSC_OK);
}
else {
$status->http_err($resp);
}
return ($status, $config);
}
# Method ===============================================================
#
=item B<create_firewall_instance>
Create empty firewall instance on VR5600
# Returns : BSC::Status - success of operation
=cut ===================================================================
sub create_firewall_instance {
my $self = shift;
my $fwInstance = shift;
my $status = new Brocade::BSC::Status($BSC_OK);
my $urlpath = $self->{ctrl}->get_ext_mount_config_urlpath($self->{name});
my %headers = ('content-type'=>'application/yang.data+json');
my $payload = $fwInstance->get_payload();
my $resp = $self->ctrl_req('POST', $urlpath, $payload, \%headers);
$resp->is_success or $status->http_err($resp);
return $status;
}
# Method ===============================================================
#
# Parameters:
# Returns :
#
sub add_firewall_instance_rule {
die "XXX";
}
# Method ===============================================================
#
# Parameters:
# Returns :
#
sub update_firewall_instance_rule {
die "XXX";
}
# Method ===============================================================
#
=item B<delete_firewall_instance>
# Parameters: name of instance to delete
# Returns : BSC::Status - success of operation
=cut ===================================================================
sub delete_firewall_instance {
my $self = shift;
my $fwInstance = shift;
my $status = new Brocade::BSC::Status;
my $urlpath = $self->{ctrl}->get_ext_mount_config_urlpath($self->{name})
. $fwInstance->get_url_extension()
. "/name/";
my @rules = $fwInstance->get_rules();
foreach my $rule (@rules) {
my $rule_url = $urlpath . $rule->get_name();
my $resp = $self->ctrl_req('DELETE', $rule_url);
if ($resp->code != HTTP_OK) {
$status->http_err($resp);
last;
}
else {
$status->code($BSC_OK);
}
}
return $status;
}
# Method ===============================================================
#
=item B<set_dataplane_interface_firewall>
# Parameters: ifName (required) - dataplane interface to which to apply
# firewall rules
# : inFw - name of firewall instance for inbound traffic
# : outFw - name of firewall instance for outbound traffic
# Returns : BSC::Status - success of operation
=cut ===================================================================
sub set_dataplane_interface_firewall {
my ($self, %params) = @_;
my $status = new Brocade::BSC::Status($BSC_OK);
my %headers = ('content-type' => 'application/yang.data+json');
my $urlpath = $self->{ctrl}->get_ext_mount_config_urlpath($self->{name});
$params{ifName} or die "missing req'd parameter \$ifName";
my $fw = new Brocade::BSC::Node::NC::Vrouter::VR5600::DataplaneInterfaceFirewall($params{ifName});
$params{inFw} and $fw->add_in_item($params{inFw});
$params{outFw} and $fw->add_out_item($params{outFw});
my $payload = $fw->get_payload();
( run in 1.358 second using v1.01-cache-2.11-cpan-7fcb06a456a )