bosh_vsphere_cpi 0.5.1 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,19 @@
|
|
1
|
+
# Copyright (c) 2009-2012 VMware, Inc.
|
2
|
+
|
3
|
+
Sequel.migration do
|
4
|
+
up do
|
5
|
+
# This used to be included in the director migrations, so we should not fail (hence create_table?) if this table
|
6
|
+
# already exists to allow old installations to keep working with the new migrations.
|
7
|
+
create_table? :vsphere_disk do
|
8
|
+
primary_key :id
|
9
|
+
String :path, :null => true
|
10
|
+
String :datacenter, :null => true
|
11
|
+
String :datastore, :null => true
|
12
|
+
Integer :size, :null => false
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
down do
|
17
|
+
drop_table :vsphere_disk
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# Copyright (c) 2009-2012 VMware, Inc.
|
2
|
+
|
3
|
+
Sequel.migration do
|
4
|
+
up do
|
5
|
+
add_column :vsphere_disk, :uuid, String
|
6
|
+
self[:vsphere_disk].update(:uuid => :id)
|
7
|
+
add_index :vsphere_disk, :uuid, :unique => true
|
8
|
+
end
|
9
|
+
|
10
|
+
down do
|
11
|
+
drop_index :vsphere_disk, :uuid, :unique => true
|
12
|
+
drop_column :vsphere_disk, :uuid
|
13
|
+
end
|
14
|
+
end
|
data/lib/cloud/vsphere/cloud.rb
CHANGED
@@ -128,8 +128,8 @@ module VSphereCloud
|
|
128
128
|
def disk_spec(persistent_disks)
|
129
129
|
disks = []
|
130
130
|
if persistent_disks
|
131
|
-
persistent_disks.each do |
|
132
|
-
disk = Models::Disk
|
131
|
+
persistent_disks.each do |disk_cid|
|
132
|
+
disk = Models::Disk.first(:uuid => disk_cid)
|
133
133
|
disks << {
|
134
134
|
:size => disk.size,
|
135
135
|
:dc_name => disk.datacenter,
|
@@ -488,7 +488,7 @@ module VSphereCloud
|
|
488
488
|
def attach_disk(vm_cid, disk_cid)
|
489
489
|
with_thread_name("attach_disk(#{vm_cid}, #{disk_cid})") do
|
490
490
|
@logger.info("Attaching disk: #{disk_cid} on vm: #{vm_cid}")
|
491
|
-
disk = Models::Disk
|
491
|
+
disk = Models::Disk.first(:uuid => disk_cid)
|
492
492
|
raise "Disk not found: #{disk_cid}" if disk.nil?
|
493
493
|
|
494
494
|
vm = get_vm_by_cid(vm_cid)
|
@@ -518,7 +518,7 @@ module VSphereCloud
|
|
518
518
|
source_path = disk.path
|
519
519
|
datacenter_disk_path = @resources.datacenters[disk.datacenter].disk_path
|
520
520
|
|
521
|
-
destination_path = "[#{persistent_datastore.name}] #{datacenter_disk_path}/#{disk.
|
521
|
+
destination_path = "[#{persistent_datastore.name}] #{datacenter_disk_path}/#{disk.uuid}"
|
522
522
|
@logger.info("Moving #{disk.datacenter}/#{source_path} to #{datacenter_name}/#{destination_path}")
|
523
523
|
|
524
524
|
if Config.copy_disks
|
@@ -544,7 +544,7 @@ module VSphereCloud
|
|
544
544
|
disk.datacenter = datacenter_name
|
545
545
|
disk.datastore = persistent_datastore.name
|
546
546
|
datacenter_disk_path = @resources.datacenters[disk.datacenter].disk_path
|
547
|
-
disk.path = "[#{disk.datastore}] #{datacenter_disk_path}/#{disk.
|
547
|
+
disk.path = "[#{disk.datastore}] #{datacenter_disk_path}/#{disk.uuid}"
|
548
548
|
disk.save
|
549
549
|
create_disk = true
|
550
550
|
end
|
@@ -564,7 +564,7 @@ module VSphereCloud
|
|
564
564
|
location = get_vm_location(vm, :datacenter => datacenter_name)
|
565
565
|
env = get_current_agent_env(location)
|
566
566
|
@logger.info("Reading current agent env: #{env.pretty_inspect}")
|
567
|
-
env["disks"]["persistent"][disk.
|
567
|
+
env["disks"]["persistent"][disk.uuid] = attached_disk_config.device.unit_number
|
568
568
|
@logger.info("Updating agent env to: #{env.pretty_inspect}")
|
569
569
|
set_agent_env(vm, location, env)
|
570
570
|
@logger.info("Attaching disk")
|
@@ -576,7 +576,7 @@ module VSphereCloud
|
|
576
576
|
def detach_disk(vm_cid, disk_cid)
|
577
577
|
with_thread_name("detach_disk(#{vm_cid}, #{disk_cid})") do
|
578
578
|
@logger.info("Detaching disk: #{disk_cid} from vm: #{vm_cid}")
|
579
|
-
disk = Models::Disk
|
579
|
+
disk = Models::Disk.first(:uuid => disk_cid)
|
580
580
|
raise "Disk not found: #{disk_cid}" if disk.nil?
|
581
581
|
|
582
582
|
vm = get_vm_by_cid(vm_cid)
|
@@ -595,7 +595,7 @@ module VSphereCloud
|
|
595
595
|
location = get_vm_location(vm)
|
596
596
|
env = get_current_agent_env(location)
|
597
597
|
@logger.info("Reading current agent env: #{env.pretty_inspect}")
|
598
|
-
env["disks"]["persistent"].delete(disk.
|
598
|
+
env["disks"]["persistent"].delete(disk.uuid)
|
599
599
|
@logger.info("Updating agent env to: #{env.pretty_inspect}")
|
600
600
|
set_agent_env(vm, location, env)
|
601
601
|
@logger.info("Detaching disk")
|
@@ -622,17 +622,18 @@ module VSphereCloud
|
|
622
622
|
with_thread_name("create_disk(#{size}, _)") do
|
623
623
|
@logger.info("Creating disk with size: #{size}")
|
624
624
|
disk = Models::Disk.new
|
625
|
+
disk.uuid = "disk-#{generate_unique_name}"
|
625
626
|
disk.size = size
|
626
627
|
disk.save
|
627
628
|
@logger.info("Created disk: #{disk.inspect}")
|
628
|
-
disk.
|
629
|
+
disk.uuid
|
629
630
|
end
|
630
631
|
end
|
631
632
|
|
632
633
|
def delete_disk(disk_cid)
|
633
634
|
with_thread_name("delete_disk(#{disk_cid})") do
|
634
635
|
@logger.info("Deleting disk: #{disk_cid}")
|
635
|
-
disk = Models::Disk
|
636
|
+
disk = Models::Disk.first(:uuid => disk_cid)
|
636
637
|
if disk
|
637
638
|
if disk.path
|
638
639
|
datacenter = client.find_by_inventory_path(disk.datacenter)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bosh_vsphere_cpi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-12-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bosh_common
|
@@ -113,6 +113,8 @@ executables: []
|
|
113
113
|
extensions: []
|
114
114
|
extra_rdoc_files: []
|
115
115
|
files:
|
116
|
+
- db/migrations/20120123235022_initial.rb
|
117
|
+
- db/migrations/20121204174707_add_uuid_to_disks.rb
|
116
118
|
- lib/cloud/vsphere.rb
|
117
119
|
- lib/cloud/vsphere/client.rb
|
118
120
|
- lib/cloud/vsphere/cloud.rb
|