[pve-devel] [PATCH] HA parse_sid changed to accept CT

Daniel Hunsaker danhunsaker at gmail.com
Mon Aug 31 17:52:27 CEST 2015


Also note that "colon" (:) only has one "l"...

On Mon, Aug 31, 2015, 07:48 Alen Grizonic <a.grizonic at proxmox.com> wrote:

> ---
>  src/PVE/HA/Tools.pm | 15 +++++++++++----
>  1 file changed, 11 insertions(+), 4 deletions(-)
>
> diff --git a/src/PVE/HA/Tools.pm b/src/PVE/HA/Tools.pm
> index 94613de..2b9ca6c 100644
> --- a/src/PVE/HA/Tools.pm
> +++ b/src/PVE/HA/Tools.pm
> @@ -5,6 +5,7 @@ use warnings;
>  use JSON;
>  use PVE::JSONSchema;
>  use PVE::Tools;
> +use PVE::Cluster;
>
>  PVE::JSONSchema::register_format('pve-ha-resource-id',
> \&pve_verify_ha_resource_id);
>  sub pve_verify_ha_resource_id {
> @@ -18,7 +19,7 @@ sub pve_verify_ha_resource_id {
>  }
>
>  PVE::JSONSchema::register_standard_option('pve-ha-resource-id', {
> -    description => "HA resource ID. This consists of a resource type
> followed by a resource specific name, separated with collon (example:
> vm:100).",
> +    description => "HA resource ID. This consists of a resource type
> followed by a resource specific name, separated with collon (example:
> vm:100 / ct:100).",
>      typetext => "<type>:<name>",
>      type => 'string', format => 'pve-ha-resource-id',
>  });
> @@ -35,7 +36,7 @@ sub pve_verify_ha_resource_or_vm_id {
>  }
>
>  PVE::JSONSchema::register_standard_option('pve-ha-resource-or-vm-id', {
> -    description => "HA resource ID. This consists of a resource type
> followed by a resource specific name, separated with collon (example:
> vm:100). For virtual machines, you can simply use the VM id as shortcut
> (example: 100).",
> +    description => "HA resource ID. This consists of a resource type
> followed by a resource specific name, separated with collon (example:
> vm:100 / ct:100). For virtual machines and containers, you can simply use
> the VM or CT id as shortcut (example: 100).",
>      typetext => "<type>:<name>",
>      type => 'string', format => 'pve-ha-resource-or-vm-id',
>  });
> @@ -69,8 +70,14 @@ sub parse_sid {
>
>      if ($sid =~ m/^(\d+)$/) {
>         $name = $1;
> -       $type ='vm';
> -       $sid = "vm:$name";
> +       my $vmlist = PVE::Cluster::get_vmlist();
> +       my $type = $vmlist->{ids}->{$name}->{type};
> +       if ($type eq 'lxc') {
> +           $type = 'ct';
> +       } elsif ($type eq 'qemu') {
> +           $type = 'vm';
> +       }
> +       $sid = "$type:$name";
>      } elsif  ($sid =~m/^(\S+):(\S+)$/) {
>         $name = $2;
>         $type = $1;
> --
> 2.1.4
>
>
> _______________________________________________
> pve-devel mailing list
> pve-devel at pve.proxmox.com
> http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.proxmox.com/pipermail/pve-devel/attachments/20150831/5187824d/attachment.htm>


More information about the pve-devel mailing list