lib/vagabond/cookbooks/lxc/resources/container.rb in vagabond-0.2.0 vs lib/vagabond/cookbooks/lxc/resources/container.rb in vagabond-0.2.2
- old
+ new
@@ -1,9 +1,13 @@
-actions :create, :delete, :clone
+def initialize(*args)
+ @subresources = []
+ super
+end
+
+actions :create, :delete
default_action :create
-attribute :base_container, :kind_of => String
attribute :validation_client, :kind_of => String
attribute :validator_pem, :kind_of => String, :default => nil
attribute :server_uri, :kind_of => String
attribute :chef_environment, :kind_of => String, :default => '_default'
attribute :node_name, :kind_of => String
@@ -18,12 +22,33 @@
attribute :static_gateway, :kind_of => String
attribute :default_config, :kind_of => [TrueClass, FalseClass], :default => true
attribute :default_fstab, :kind_of => [TrueClass, FalseClass], :default => true
attribute :container_commands, :kind_of => Array, :default => []
attribute :initialize_commands, :kind_of => Array, :default => []
-attribute :new_container, :kind_of => [TrueClass, FalseClass], :default => false
+attribute :clone, :kind_of => String
attribute :template, :kind_of => String, :default => 'ubuntu'
attribute :template_opts, :kind_of => Hash, :default => {}
attribute :create_environment, :kind_of => Hash, :default => {}
-attribute :_lxc
-# TODO: We should ultimately have support for all these templates
-#attribute :template, :equal_to => %w(busybox debian fedora opensuse sshd ubuntu ubuntu-cloud), :default => 'ubuntu'
+
+def fstab_mount(fname, &block)
+ fstab = Chef::Resource::LxcFstab.new("lxc_fstab[#{self.name} - #{fname}]", nil)
+ fstab.action :nothing
+ fstab.container self.name
+
+ @subresources << [fstab, block]
+end
+
+def interface(iname, &block)
+ iface = Chef::Resource::LxcInterface.new("lxc_interface[#{self.name} - #{iname}]", nil)
+ iface.container self.name
+ iface.action :nothing
+ @subresources << [iface, block]
+end
+
+def config(cname, &block)
+ conf = Chef::Resource::LxcConfig.new("lxc_config[#{self.name} - #{cname}]", nil)
+ conf.container self.name
+ conf.action :nothing
+ @subresources << [conf, block]
+end
+
+attr_reader :subresources