Submitted by pcfreak30 on Wed, 02/19/2014 - 19:36
Would like the ability for api commands to be able to reference a server by its ip as well as its hostname.
A ton of our vps's have a dummy hostname of vps.server.com due to solusvm, so its near to impossible to pick a single one out if a owner has more than 1. I was looking to check the status of a server, and some other commands, but am being impacted due to this.
I am really needing a solution to this as soon as possible too.
Status:
Closed (fixed)
Comments
Submitted by JamieCameron on Wed, 02/19/2014 - 19:48 Comment #1
Your code that calls the API could use the list-systems call with the multiline flag to get a list of all VMs, which includes all their IP addresses. Being able to specify a system by IP is a good idea though... I will look into allowing this in the next release.
Submitted by pcfreak30 on Wed, 02/19/2014 - 19:53 Comment #2
sub find_managed_servers
foreach my $s (&list_managed_servers_sorted(undef, 1)) { my ($ingroup) = grep { $wantgroups{lc($_)} } split(/\t/, $s->{'group'}); my $p = @$hostedon ? &get_parent_server($s) : undef; if (($all && &can_action($s)) || $ingroup || &indexoflc($s->{'host'}, @$hosts) >= 0 || &indexoflc($s->{'ip'}, @$hosts) >= 0 || &indexoflc($s->{'manager'}, @$managers) >= 0 || &indexoflc($s->{'type'}, @$types) >= 0 || &indexoflc($s->{'status'}, @$expstatuses) >= 0 || $wantowned{$s->{'id'}} || $p && $wanthost{$p->{'id'}}) { &complete_managed_server($s); push(@rv, $s); } }
Added - &indexoflc($s->{'ip'}, @$hosts) >= 0 ||
Since find_managed_servers is used everywhere, it just added global support.
Though I can say the mechanism to convert plaintext to json/xml isnt extremely good. An example is the refresh-systems, the status is all one string and would require text manipulation/regex to parse.
Submitted by JamieCameron on Wed, 02/19/2014 - 20:29 Comment #3
Thanks, I will apply that patch (with some modifications) in the next release.
Submitted by pcfreak30 on Thu, 02/20/2014 - 11:22 Comment #4
It seems other commands are using get_managed_server_by(), so I changed passwd-system.pl
$server = &get_managed_server_by("host", $host);
to
$server = &get_managed_server_by("host", $host) || &get_managed_server_by("ip", $host);
You need to do it across all API's.
Submitted by JamieCameron on Thu, 02/20/2014 - 15:56 Comment #5
Yeah, I'll fix those up too.
Submitted by JamieCameron on Thu, 02/20/2014 - 19:40 Comment #6
Done
Submitted by pcfreak30 on Thu, 02/20/2014 - 19:42 Comment #7
Can you provide a patch so I can ensure our API calls work as intended?
I have my own hackups presently.
Submitted by JamieCameron on Thu, 02/20/2014 - 20:52 Comment #8
Sure. Actually it may make more sense for me to provide a complete new version once I'm implemented all your suggestions.
Submitted by Issues on Thu, 03/06/2014 - 21:01 Comment #9
Automatically closed -- issue fixed for 2 weeks with no activity.