All,
Is there a way to set the locale to en_US in my perl application, so that the VC responds back with english text to all my api queries.
I know the vpx client UI can support this. From the release notes
"The following vSphere Client command will cause the individual session to appear in English:
vpxClient -locale en_US"
Thanks
Have you tried setLocale?
I could not find any such api/function in the perl programming guide (setLocale) or Are you refering to the perl/POSIX::setlocale function ?
Any details (or sample code) on how to use it ?
I take that back. I see that you have provided link to sessionmanager::setlocale. Somehow the html interface of the forums confused me initially. Will try out & let you know. Thanks for the pointer.
It's a function in the VI SDK.
So ignore my hack-ed out alarm retrieval code, but it seemed like the easiest way to get some localized strings:
use strict;
use warnings;
use VMware::VIRuntime;
my %opts = (
locale => {
type => "=s",
variable => "locale",
help => "Session locale",
required => 1,
},
);
Opts::add_options(%opts);
Opts::parse();
Opts::validate();
Util::connect();
my $session_manager = Vim::get_view( mo_ref => Vim::get_service_content()->sessionManager );
unless ($session_manager) {
die "Failed to get SessionManager entity object!";
}
$session_manager->SetLocale(locale => Opts::get_option("locale"));
my $alarm_manager = Vim::get_view(mo_ref => Vim::get_service_content()->alarmManager);
my $alarms = $alarm_manager->GetAlarm();
my $alarm_views = Vim::get_views(mo_ref_array => $alarms);
for my $alarm ( sort {$a->{info}->{name} cmp $b->{info}->{name}} @{$alarm_views} ) {
my ($creationEventId, $entity, $key, $lastModifiedTime, $lastModifiedUser, $action,
$actionFrequency, $description, $enabled, $expression, $name, $setting);
$name = $alarm->info->name;
$description = $alarm->info->description;
$enabled = $alarm->info->enabled;
$lastModifiedUser = $alarm->info->lastModifiedUser;
$entity = $alarm->info->entity;
$actionFrequency = $alarm->info->actionFrequency;
print $name . "," . $description . "," . $actionFrequency . "\n";;
}
Util::disconnect();
Some output:
perl setLocale.pl --locale=de --server=172.16.50.25 --username=administrator --password=VMware1! Alarm für Änderungen des Systemzustands,Standardalarm zum Überwachen von Änderungen des Systemzustands von Diensten und Erweiterungen, Arbeitsspeichernutzung der virtuellen Maschine,Standardalarm zum Überwachen der Arbeitsspeicherauslastung virtueller Maschinen, Arbeitsspeichernutzung des Hosts,Standardalarm zum Überwachen der Arbeitsspeicherauslastung des Hosts, Arbeitsspeicherstatus des Hosts,Standardalarm zum Überwachen von Arbeitsspeicher, Batteriestatus des Hosts,Standardalarm zum Überwachen von Batterien, Betriebsstatus der Hosthardware,Standardalarm zum Überwachen des Betriebs, CPU-Nutzung der virtuellen Maschine,Standardalarm zum Überwachen der CPU-Auslastung virtueller Maschinen, Cluster-Hochverfügbarkeitsfehler,Standardalarm zum Überwachen von Hochverfügbarkeitsfehlern auf einem Cluster, Datenauslagerungsrate der Servicekonsole des Hosts,Standardalarm zum Überwachen der Datenauslagerungsrate des Servicekonsolenarbeitsspeichers des Hosts,
In your case I think you just need "en".
Sorry if the forum mangles the code, does that sometimes with brackets.
This works out great. Thanks for all your help !
thank you very much .It solved my problem
