Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
pve-manager
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
pve-manager
Commits
d065cd5a
Commit
d065cd5a
authored
Sep 05, 2012
by
Dietmar Maurer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix bug 178: correctly verify if VMID is already used
parent
33d02079
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
62 additions
and
21 deletions
+62
-21
Cluster.pm
PVE/API2/Cluster.pm
+37
-0
changelog.Debian
debian/changelog.Debian
+2
-0
VMIDSelector.js
www/manager/form/VMIDSelector.js
+23
-21
No files found.
PVE/API2/Cluster.pm
View file @
d065cd5a
...
...
@@ -7,6 +7,7 @@ use XML::Parser;
use
PVE::
SafeSyslog
;
use
PVE::
Tools
qw(extract_param)
;
use
PVE::
Exception
qw(raise_param_exc)
;
use
PVE::
INotify
;
use
PVE::
Cluster
qw(cfs_register_file cfs_lock_file cfs_read_file cfs_write_file)
;
use
PVE::
Storage
;
...
...
@@ -16,6 +17,7 @@ use PVE::API2::HAConfig;
use
JSON
;
use
PVE::
RESTHandler
;
use
PVE::
RPCEnvironment
;
use
PVE::
JSONSchema
qw(get_standard_option)
;
use
base
qw(PVE::RESTHandler)
;
...
...
@@ -70,6 +72,7 @@ __PACKAGE__->register_method ({
{
name
=>
'
backup
'
},
{
name
=>
'
ha
'
},
{
name
=>
'
status
'
},
{
name
=>
'
nextid
'
},
];
return
$result
;
...
...
@@ -480,4 +483,38 @@ __PACKAGE__->register_method({
}
}});
__PACKAGE__
->
register_method
({
name
=>
'
nextid
',
path
=>
'
nextid
',
method
=>
'
GET
',
description
=>
"
Get next free VMID. If you pass an VMID it will raise an error if the ID is already used.
",
permissions
=>
{
user
=>
'
all
'
},
parameters
=>
{
additionalProperties
=>
0
,
properties
=>
{
vmid
=>
get_standard_option
('
pve-vmid
',
{
optional
=>
1
}),
},
},
returns
=>
{
type
=>
'
integer
',
description
=>
"
The next free VMID.
",
},
code
=>
sub
{
my
(
$param
)
=
@_
;
my
$vmlist
=
PVE::Cluster::
get_vmlist
()
||
{};
my
$idlist
=
$vmlist
->
{
ids
}
||
{};
if
(
my
$vmid
=
$param
->
{
vmid
})
{
return
$vmid
if
!
defined
(
$idlist
->
{
$vmid
});
raise_param_exc
({
vmid
=>
"
VM
$vmid
already exists
"
});
}
for
(
my
$i
=
100
;
$i
<
10000
;
$i
++
)
{
return
$i
if
!
defined
(
$idlist
->
{
$i
});
}
die
"
unable to get any free VMID
\n
";
}});
1
;
debian/changelog.Debian
View file @
d065cd5a
pve-manager (2.1-16) unstable; urgency=low
* vzrestore: allow --storage option
* fix bug 178: correctly verify if VMID is already used
-- Proxmox Support Team <support@proxmox.com> Wed, 05 Sep 2012 08:04:28 +0200
...
...
www/manager/form/VMIDSelector.js
View file @
d065cd5a
...
...
@@ -10,31 +10,33 @@ Ext.define('PVE.form.VMIDSelector', {
validateExists
:
undefined
,
validator
:
function
(
value
)
{
/*jslint confusion: true */
var
me
=
this
;
if
(
!
Ext
.
isDefined
(
me
.
validateExists
))
{
return
true
;
}
if
(
PVE
.
data
.
ResourceStore
.
findVMID
(
value
))
{
if
(
me
.
validateExists
===
true
)
{
return
true
;
}
return
"
This VM ID is already in use.
"
;
}
else
{
if
(
me
.
validateExists
===
false
)
{
return
true
;
}
return
"
This VM ID does not exists.
"
;
}
},
initComponent
:
function
()
{
var
me
=
this
;
Ext
.
applyIf
(
me
,
{
fieldLabel
:
'
VM ID
'
fieldLabel
:
'
VM ID
'
,
listeners
:
{
'
change
'
:
function
(
field
,
newValue
,
oldValue
)
{
if
(
!
Ext
.
isDefined
(
me
.
validateExists
))
{
return
;
}
PVE
.
Utils
.
API2Request
({
params
:
{
vmid
:
newValue
},
url
:
'
/cluster/nextid
'
,
method
:
'
GET
'
,
success
:
function
(
response
,
opts
)
{
if
(
me
.
validateExists
===
true
)
{
me
.
markInvalid
(
"
This VM ID does not exists.
"
);
}
},
failure
:
function
(
response
,
opts
)
{
if
(
me
.
validateExists
===
false
)
{
me
.
markInvalid
(
"
This VM ID is already in use.
"
);
}
}
});
}
}
});
me
.
callParent
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment