From 5166732ac48230368107f951dd92b6077e76ade6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cabprasa=E2=80=9D?= <123509565+abprasa@users.noreply.github.com> Date: Thu, 3 Oct 2024 09:45:36 +0000 Subject: [PATCH] created migration script for CX --- .../upgrade/to-14.1-convert-switch-types.pl | 82 +++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100755 addons/upgrade/to-14.1-convert-switch-types.pl diff --git a/addons/upgrade/to-14.1-convert-switch-types.pl b/addons/upgrade/to-14.1-convert-switch-types.pl new file mode 100755 index 00000000000..743d38814c4 --- /dev/null +++ b/addons/upgrade/to-14.1-convert-switch-types.pl @@ -0,0 +1,82 @@ +#!/usr/bin/perl + +=head1 NAME + +to-13.1-convert-switch-types.pl + +=head1 DESCRIPTION + +Convert some switch types and use Switch OS versions + +=cut + +use strict; +use warnings; +use lib qw(/usr/local/pf/lib); +use lib qw(/usr/local/pf/lib_perl/lib/perl5); +use pf::util qw(run_as_pf); +use pf::IniFiles; +use pf::file_paths qw( + $switches_config_file +); +use File::Copy; + +run_as_pf(); + +my $file = $switches_config_file; + +if (@ARGV) { + $file = $ARGV[0]; +} + +our %types = ( + 'Aruba::CX' => 'Aruba::ArubaOS_CX_10_x', +); + +my $cs = pf::IniFiles->new(-file => $file, -allowempty => 1); + +my $update = 0; +for my $section ($cs->Sections()) { + my $type = $cs->val($section, 'type'); + next if !defined $type || !exists $types{$type}; + my $new_type = $types{$type}; + $cs->setval($section, 'type', $new_type); + $update |= 1; +} + +if ($update) { + $cs->RewriteConfig(); + print "All done\n"; + exit 0; +} + + +print "Nothing to be done\n"; + +=head1 AUTHOR + +Inverse inc. + +=head1 COPYRIGHT + +Copyright (C) 2005-2024 Inverse inc. + +=head1 LICENSE + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +USA. + +=cut +