Skip to content

Commit

Permalink
Added perl scripts for all GET APIs for VM server credentials and res…
Browse files Browse the repository at this point in the history
…ource limits.
  • Loading branch information
aayushagrawal11 committed Jul 10, 2019
1 parent 76a663e commit f3a4799
Show file tree
Hide file tree
Showing 8 changed files with 916 additions and 0 deletions.
32 changes: 32 additions & 0 deletions snippets/perl/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,35 @@ no a subscription associated with this asset.

- Example: perl post_nb_asset_cleanup.pl -nbmaster <master_server> -username <username> -password <pass> -filter "workloadType eq 'VMware'" -cleanuptime 2018-06-29T15:58:45.678Z


#### Scripts for NetBackup 8.2 or higher

VM Servers Details:

- Use the following command to obtain the list of all VM servers details from your NetBackup Master server:
- `perl get_vm_servers.pl -nbmaster <master_server> -username <username> -password <password> [-domainname <domain_name>] [-domaintype <domain_type>] [--verbose]`

VM Server Details:

- Use the following command to obtain the VM server details from your NetBackup Master server:
- `perl get_vm_server.pl -nbmaster <master_server> -username <username> -password <password> -servername <servername> [-domainname <domain_name>] [-domaintype <domain_type>] [--verbose]`

NetBackup All Resource Limits:

- Use the following command to obtain the list of all NetBackup resource limits from your NetBackup Master server:
- `perl get_all_resource_limits.pl -nbmaster <master_server> -username <username> -password <password> [-domainname <domain_name>] [-domaintype <domain_type>] [--verbose]`

NetBackup Resource Limits:

- Use the following command to obtain the NetBackup resource limits from your NetBackup Master server:
- `perl get_resource_limits.pl -nbmaster <master_server> -username <username> -password <password> -workloadtype <workloadtype> [-domainname <domain_name>] [-domaintype <domain_type>] [--verbose]`

NetBackup All Resource Limits Templates:

- Use the following command to obtain the list of all NetBackup resource limits templates from your NetBackup Master server:
- `perl get_all_resource_limits_templates.pl -nbmaster <master_server> -username <username> -password <password> [-domainname <domain_name>] [-domaintype <domain_type>] [--verbose]`

NetBackup Resource Limits Template:

- Use the following command to obtain the NetBackup resource limits template from your NetBackup Master server:
- `perl get_resource_limits_template.pl -nbmaster <master_server> -username <username> -password <password> -workloadtype <workloadtype> [-domainname <domain_name>] [-domaintype <domain_type>] [--verbose]`
62 changes: 62 additions & 0 deletions snippets/perl/get_all_resource_limits.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#Load module netbackup.pm from current directory
use lib '.';

use netbackup;
use strict;
use warnings;
use Getopt::Long qw(GetOptions);

sub printUsage {
print "\nUsage : perl get_all_resource_limits.pl -nbmaster <master_server> -username <username> -password <password> [-domainname <domain_name>] [-domaintype <domain_type>] [--verbose]\n\n";
die;
}

my $fqdn_hostname;
my $username;
my $password;
my $domainname;
my $domaintype;
my $verbose;

GetOptions(
'nbmaster=s' => \$fqdn_hostname,
'username=s' => \$username,
'password=s' => \$password,
'domainname=s' => \$domainname,
'domaintype=s' => \$domaintype,
'verbose' => \$verbose
) or printUsage();

if (!$fqdn_hostname || !$username || !$password) {
printUsage();
}

if($verbose){
print "\nRecieved the following parameters : \n";
print " FQDN Hostname : $fqdn_hostname\n";
print " Username : $username\n";
print " Password : $password\n";
if ($domainname) {
print " Domain Name : $domainname\n";
}
if ($domaintype) {
print " Domain Type : $domaintype\n";
}
}

print "\n";
my $myToken;
if ($domainname && $domaintype) {
$myToken = netbackup::login($fqdn_hostname, $username, $password, $domainname, $domaintype);
}
else{
$myToken = netbackup::login($fqdn_hostname, $username, $password);
}

my $jsonstring = netbackup::getAllResourceLimits($fqdn_hostname, $myToken);

print "\nNetBackup resource limits for all supported workload types:\n";
netbackup::displayAllResourceLimits($jsonstring);

netbackup::logout($fqdn_hostname, $myToken);
print "\n";
62 changes: 62 additions & 0 deletions snippets/perl/get_all_resource_limits_templates.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#Load module netbackup.pm from current directory
use lib '.';

use netbackup;
use strict;
use warnings;
use Getopt::Long qw(GetOptions);

sub printUsage {
print "\nUsage : perl get_all_resource_limits_templates.pl -nbmaster <master_server> -username <username> -password <password> [-domainname <domain_name>] [-domaintype <domain_type>] [--verbose]\n\n";
die;
}

my $fqdn_hostname;
my $username;
my $password;
my $domainname;
my $domaintype;
my $verbose;

GetOptions(
'nbmaster=s' => \$fqdn_hostname,
'username=s' => \$username,
'password=s' => \$password,
'domainname=s' => \$domainname,
'domaintype=s' => \$domaintype,
'verbose' => \$verbose
) or printUsage();

if (!$fqdn_hostname || !$username || !$password) {
printUsage();
}

if($verbose){
print "\nRecieved the following parameters : \n";
print " FQDN Hostname : $fqdn_hostname\n";
print " Username : $username\n";
print " Password : $password\n";
if ($domainname) {
print " Domain Name : $domainname\n";
}
if ($domaintype) {
print " Domain Type : $domaintype\n";
}
}

print "\n";
my $myToken;
if ($domainname && $domaintype) {
$myToken = netbackup::login($fqdn_hostname, $username, $password, $domainname, $domaintype);
}
else{
$myToken = netbackup::login($fqdn_hostname, $username, $password);
}

my $jsonstring = netbackup::getAllResourceLimitsTemplates($fqdn_hostname, $myToken);

print "\nNetBackup resource limits templates for all supported workload types::\n";
netbackup::displayAllResourceLimitsTemplates($jsonstring);

netbackup::logout($fqdn_hostname, $myToken);
print "\n";
65 changes: 65 additions & 0 deletions snippets/perl/get_resource_limits.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#Load module netbackup.pm from current directory
use lib '.';

use netbackup;
use strict;
use warnings;
use Getopt::Long qw(GetOptions);

sub printUsage {
print "\nUsage : perl get_resource_limits.pl -nbmaster <master_server> -username <username> -password <password> -workloadtype <workloadtype> [-domainname <domain_name>] [-domaintype <domain_type>] [--verbose]\n\n";
die;
}

my $fqdn_hostname;
my $username;
my $password;
my $workloadtype;
my $domainname;
my $domaintype;
my $verbose;

GetOptions(
'nbmaster=s' => \$fqdn_hostname,
'username=s' => \$username,
'password=s' => \$password,
'workloadtype=s' => \$workloadtype,
'domainname=s' => \$domainname,
'domaintype=s' => \$domaintype,
'verbose' => \$verbose
) or printUsage();

if (!$fqdn_hostname || !$username || !$password || !$workloadtype) {
printUsage();
}

if($verbose){
print "\nRecieved the following parameters : \n";
print " FQDN Hostname : $fqdn_hostname\n";
print " Username : $username\n";
print " Password : $password\n";
print " Workload Type : $workloadtype\n";
if ($domainname) {
print " Domain Name : $domainname\n";
}
if ($domaintype) {
print " Domain Type : $domaintype\n";
}
}

print "\n";
my $myToken;
if ($domainname && $domaintype) {
$myToken = netbackup::login($fqdn_hostname, $username, $password, $domainname, $domaintype);
}
else{
$myToken = netbackup::login($fqdn_hostname, $username, $password);
}

my $jsonstring = netbackup::getResourceLimits($fqdn_hostname, $myToken, $workloadtype);

print "\n Resource limits for a given workload type:\n";
netbackup::displayResourceLimits($jsonstring);

netbackup::logout($fqdn_hostname, $myToken);
print "\n";
65 changes: 65 additions & 0 deletions snippets/perl/get_resource_limits_template.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#Load module netbackup.pm from current directory
use lib '.';

use netbackup;
use strict;
use warnings;
use Getopt::Long qw(GetOptions);

sub printUsage {
print "\nUsage : perl get_resource_limits_template.pl -nbmaster <master_server> -username <username> -password <password> -workloadtype <workloadtype> [-domainname <domain_name>] [-domaintype <domain_type>] [--verbose]\n\n";
die;
}

my $fqdn_hostname;
my $username;
my $password;
my $workloadtype;
my $domainname;
my $domaintype;
my $verbose;

GetOptions(
'nbmaster=s' => \$fqdn_hostname,
'username=s' => \$username,
'password=s' => \$password,
'workloadtype=s' => \$workloadtype,
'domainname=s' => \$domainname,
'domaintype=s' => \$domaintype,
'verbose' => \$verbose
) or printUsage();

if (!$fqdn_hostname || !$username || !$password || !$workloadtype) {
printUsage();
}

if($verbose){
print "\nRecieved the following parameters : \n";
print " FQDN Hostname : $fqdn_hostname\n";
print " Username : $username\n";
print " Password : $password\n";
print " Workload Type : $workloadtype\n";
if ($domainname) {
print " Domain Name : $domainname\n";
}
if ($domaintype) {
print " Domain Type : $domaintype\n";
}
}

print "\n";
my $myToken;
if ($domainname && $domaintype) {
$myToken = netbackup::login($fqdn_hostname, $username, $password, $domainname, $domaintype);
}
else{
$myToken = netbackup::login($fqdn_hostname, $username, $password);
}

my $jsonstring = netbackup::getResourceLimitsTemplate($fqdn_hostname, $myToken, $workloadtype);

print "\n Resource limits template for a given workload type:\n";
netbackup::displayResourceLimitsTemplate($jsonstring);

netbackup::logout($fqdn_hostname, $myToken);
print "\n";
65 changes: 65 additions & 0 deletions snippets/perl/get_vm_server.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#Load module netbackup.pm from current directory
use lib '.';

use netbackup;
use strict;
use warnings;
use Getopt::Long qw(GetOptions);

sub printUsage {
print "\nUsage : perl get_vm_server.pl -nbmaster <master_server> -username <username> -password <password> -servername <servername> [-domainname <domain_name>] [-domaintype <domain_type>] [--verbose]\n\n";
die;
}

my $fqdn_hostname;
my $username;
my $password;
my $servername;
my $domainname;
my $domaintype;
my $verbose;

GetOptions(
'nbmaster=s' => \$fqdn_hostname,
'username=s' => \$username,
'password=s' => \$password,
'servername=s' => \$servername,
'domainname=s' => \$domainname,
'domaintype=s' => \$domaintype,
'verbose' => \$verbose
) or printUsage();

if (!$fqdn_hostname || !$username || !$password || !$servername) {
printUsage();
}

if($verbose){
print "\nRecieved the following parameters : \n";
print " FQDN Hostname : $fqdn_hostname\n";
print " Username : $username\n";
print " Password : $password\n";
print " Servername : $servername\n";
if ($domainname) {
print " Domain Name : $domainname\n";
}
if ($domaintype) {
print " Domain Type : $domaintype\n";
}
}

print "\n";
my $myToken;
if ($domainname && $domaintype) {
$myToken = netbackup::login($fqdn_hostname, $username, $password, $domainname, $domaintype);
}
else{
$myToken = netbackup::login($fqdn_hostname, $username, $password);
}

my $jsonstring = netbackup::getVM_Server($fqdn_hostname, $myToken, $servername);

print "\nVM Server:\n";
netbackup::displayVM_Server($jsonstring);

netbackup::logout($fqdn_hostname, $myToken);
print "\n";
Loading

0 comments on commit f3a4799

Please sign in to comment.