Contributor
Contributor

vSpher CLI not working with Non-english language vCenter


Here vCenter installed on French locale system.


My vSphere cli is installed on English language machine.


Getting output in French language.


Is there any way we can convert output to english ?

0 Kudos
2 Replies
Virtuoso
Virtuoso

You should be able to use setLocale() from the SessionManager object to set the specific localization strings for output (never tried it myself, however).

The problem is the CLI commands do not have this hook built-in.  What you may need to do is write a small script to establish the session with a sessionfile and then call setLocale(). Then you should be able to call other CLI scripts using that session file and get the localization strings you prefer.

Again, not tested, so I'd be curious if this works, but try the following:

# Initialize and save a vSphere API session cookie to file; save_session is part of the Perl SDK download

perl save_session.pl --savesessionfile <location> --server <server>

# Call a setLocale() script; set_locale.pl is the custom locale script

perl set_locale.pl --sessionfile= <location> --locale=en

# Call CLI script utilities using --sessionfile; see the CLI documentation for the session file usage notes

...

A simple set_locale.pl script would be:

#!/usr/bin/perl

use strict;

use warnings;

my %opts = (

     locale => {

          type => ":s",

          required => 1,

          default => 'en',

     },

);

Opts::add_options(%opts);

Opts::parse();

Opts::validate();

Util::connect();

my ($session_manager, $locale);

$locale = Opts::get_option('locale');

$session_manager = Vim::get_view(mo_ref => Vim::get_service_content()->{'sessionManager'});

$session_manager->setLocale(locale => $locale);

Util::disconnect();

If you are writing your own Perl SDK scripts, then you can just add the locale call in the script and avoid the session file usage.  For the pre-made CLI tools from the SDK vicfg-*, etc, you probably need the steps above.  I didn't see anything in VICommon.pm to support locale parameters globally for the API CLI tools.

If you give it a try, let me know if you hit any bugs in the logic -- might be something easily fixed.

Reuben Stump | http://www.virtuin.com | @ReubenStump
0 Kudos
Contributor
Contributor


Yes,


It working , Thanks.


my $serviceContent    = Vim::get_service_content();


my $sessionManager    = Vim::get_view( mo_ref => $serviceContent->sessionManager );


$sessionManager->SetLocale(locale => "en_US");

my $serviceContent= Vim::get_service_content();



 



my $sessionManager= Vim::get_view( mo_ref => $serviceContent->sessionManager );



 



$sessionManager->SetLocale(locale => "en_US");


0 Kudos