OCCIServer.rb-issue1749.patch
| OCCIServer.rb 2013-02-04 15:01:13.483028529 +0100 | ||
|---|---|---|
| 48 | 48 |
# Secs to sleep between checks to see if image upload© to repo is finished |
| 49 | 49 |
IMAGE_POLL_SLEEP_TIME = 5 |
| 50 | 50 | |
| 51 |
# Allow read access to @vm_info |
|
| 52 |
class VirtualMachineOCCI |
|
| 53 |
attr_reader :vm_info |
|
| 54 |
end |
|
| 55 | ||
| 51 | 56 |
class OCCIServer < CloudServer |
| 52 | 57 |
# Server initializer |
| 53 | 58 |
# config_file:: _String_ path of the config file |
| ... | ... | |
| 246 | 251 |
@config[:instance_types], |
| 247 | 252 |
@config[:template_location]) |
| 248 | 253 | |
| 254 |
# --- Get User's VMs --- |
|
| 255 |
vmpool = VirtualMachinePoolOCCI.new( |
|
| 256 |
@client, |
|
| 257 |
POOL_FILTER) |
|
| 258 |
|
|
| 259 |
rc = vmpool.info |
|
| 260 |
if OpenNebula.is_error?(rc) |
|
| 261 |
return rc, CloudServer::HTTP_ERROR_CODE[rc.errno] |
|
| 262 |
end |
|
| 263 | ||
| 264 |
# --- Check for duplicate names --- |
|
| 265 |
if vmpool.map{|user_vm| user_vm.name }.include?(vm.vm_info['/COMPUTE/NAME'])
|
|
| 266 |
rc=OpenNebula::Error.new("[VirtualMachineAllocate] A VM with the same name already exist")
|
|
| 267 |
return rc, CloudServer::HTTP_ERROR_CODE[rc.errno] |
|
| 268 |
end |
|
| 269 | ||
| 249 | 270 |
# --- Generate the template and Allocate the new Instance --- |
| 250 | 271 |
template = vm.to_one_template |
| 251 | 272 |
return template, 500 if OpenNebula.is_error?(template) |