Skip to content

Commit

Permalink
working vagrant for castled with filestore osds
Browse files Browse the repository at this point in the history
  • Loading branch information
travisn committed Oct 19, 2016
1 parent 634c6cc commit 579f78b
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ debug.test

.vagrant/
demo/vagrant/cloud-config.yml

.virtualbox/
4 changes: 4 additions & 0 deletions demo/vagrant/Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ VAGRANTFILE_API_VERSION = "2"
$channel = "alpha"
$nodes = 3
$new_discovery_url="https://discovery.etcd.io/new?size=1"
$node_disks = 3
$disk_size = 5

require_relative 'util.rb'
require 'open-uri'
Expand All @@ -15,6 +17,8 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
node.vm.hostname = name
node.vm.network "private_network", ip: "172.20.20.#{10+i}"

attach_volumes(node, $node_disks, $disk_size)

# enable if you want to run for locally build ACI files
#node.vm.synced_folder "../../release", "/release", id: "release", :nfs => true, :mount_options => ['nolock,vers=3,tcp']

Expand Down
5 changes: 3 additions & 2 deletions demo/vagrant/cloud-config.yml.in
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@ coreos:
Environment=CASTLED_DISCOVERY_URL=%%token%%
Environment=CASTLED_PUBLIC_IPV4=$public_ipv4
Environment=CASTLED_PRIVATE_IPV4=$private_ipv4
Environment=CASTLED_DATA_DIRS=/var/lib/castled/data
Environment=CASTLED_DATA_DIR=/var/lib/castled
#Environment=CASTLED_DATA_DEVICES=sdb,sdc,sdd

ExecStartPre=/usr/bin/mkdir -p ${CASTLED_DATA_DIRS}
ExecStartPre=/usr/bin/mkdir -p ${CASTLED_DATA_DIR}

ExecStart=/usr/bin/rkt run \
--trust-keys-from-https \
Expand Down
47 changes: 46 additions & 1 deletion demo/vagrant/util.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
def set_coreos_box(config, channel)
config.vm.box = "coreos-%s" % channel
config.vm.box_url = "http://%s.release.core-os.net/amd64-usr/current/coreos_production_vagrant.json" % $coreos_channel
config.vm.box_url = "http://%s.release.core-os.net/amd64-usr/current/coreos_production_vagrant.json" % $channel

["vmware_fusion", "vmware_workstation"].each do |vmware|
config.vm.provider vmware do |v, override|
Expand Down Expand Up @@ -54,3 +54,48 @@ def provision
Provisioner
end
end

class VagrantPlugins::ProviderVirtualBox::Action::SetName
alias_method :original_call, :call
def call(env)
machine = env[:machine]
driver = machine.provider.driver
uuid = driver.instance_eval { @uuid }
ui = env[:ui]

controller_name="SATA Controller"

vm_info = driver.execute("showvminfo", uuid)
controller_already_exists = vm_info.match("Storage Controller Name.*#{controller_name}")

if controller_already_exists
ui.info "already has the #{controller_name} hdd controller, skipping creation/add"
else
ui.info "creating #{controller_name} hdd controller"
driver.execute(
'storagectl',
uuid,
'--name', "#{controller_name}",
'--add', 'sata',
'--controller', 'IntelAHCI')
end

original_call(env)
end
end

# Add persistent storage volumes
def attach_volumes(node, num_volumes, volume_size)

node.vm.provider :virtualbox do |v, override|
(1..num_volumes).each do |disk|
diskname = File.join(File.dirname(File.expand_path(__FILE__)), ".virtualbox", "#{node.vm.hostname}-#{disk}.vdi")
unless File.exist?(diskname)
v.customize ['createhd', '--filename', diskname, '--size', volume_size * 1024]
end
v.customize ['storageattach', :id, '--storagectl', 'SATA Controller', '--port', disk, '--device', 0, '--type', 'hdd', '--medium', diskname]
end
end

end

0 comments on commit 579f78b

Please sign in to comment.