|
| 1 | +//This script can be run using NetBackup 8.2 and higher. |
| 2 | +//It sets exclude list for the given host and reads exclude list to confirm the value was set correctly. |
| 3 | + |
| 4 | +package main |
| 5 | + |
| 6 | +import ( |
| 7 | + "flag" |
| 8 | + "fmt" |
| 9 | + "log" |
| 10 | + "os" |
| 11 | + "apihelper" |
| 12 | +) |
| 13 | + |
| 14 | +//################### |
| 15 | +// Global Variables |
| 16 | +//################### |
| 17 | +var ( |
| 18 | + nbmaster = flag.String("nbmaster", "", "NetBackup Master Server") |
| 19 | + username = flag.String("username", "", "User name to log into the NetBackup webservices") |
| 20 | + password = flag.String("password", "", "Password for the given user") |
| 21 | + domainName = flag.String("domainName", "", "Domain name of the given user") |
| 22 | + domainType = flag.String("domainType", "", "Domain type of the given user") |
| 23 | + client = flag.String("client", "", "NetBackup host name") |
| 24 | +) |
| 25 | + |
| 26 | +const usage = "\n\nUsage: go run ./get_set_host_config.go -nbmaster <masterServer> -username <username> -password <password> [-domainName <domainName>] [-domainType <domainType>] -client <client>\n\n" |
| 27 | + |
| 28 | +func main() { |
| 29 | + // Print usage |
| 30 | + flag.Usage = func() { |
| 31 | + fmt.Fprintf(os.Stderr, usage) |
| 32 | + os.Exit(1) |
| 33 | + } |
| 34 | + |
| 35 | + // Read command line arguments |
| 36 | + flag.Parse() |
| 37 | + |
| 38 | + if len(*nbmaster) == 0 { |
| 39 | + log.Fatalf("Please specify the name of the NetBackup Master Server using the -nbmaster parameter.\n") |
| 40 | + } |
| 41 | + if len(*username) == 0 { |
| 42 | + log.Fatalf("Please specify the username using the -username parameter.\n") |
| 43 | + } |
| 44 | + if len(*password) == 0 { |
| 45 | + log.Fatalf("Please specify the password using the -password parameter.\n") |
| 46 | + } |
| 47 | + if len(*client) == 0 { |
| 48 | + log.Fatalf("Please specify the name of a NetBackup host using the -client parameter.\n") |
| 49 | + } |
| 50 | + |
| 51 | + httpClient := apihelper.GetHTTPClient() |
| 52 | + jwt := apihelper.Login(*nbmaster, httpClient, *username, *password, *domainName, *domainType) |
| 53 | + hostUuid := apihelper.GetHostUUID(*nbmaster, httpClient, jwt, *client); |
| 54 | + apihelper.GetExcludeLists(*nbmaster, httpClient, jwt, hostUuid); |
| 55 | + apihelper.SetExcludeLists(*nbmaster, httpClient, jwt, hostUuid); |
| 56 | + apihelper.GetExcludeLists(*nbmaster, httpClient, jwt, hostUuid); |
| 57 | +} |
0 commit comments