Browse files

Add group property to cloudstack instance

  • Loading branch information...
1 parent 60f9649 commit a5b939d93e5ffea79a7801945faa5334b5c0ff05 Dan Bode committed Nov 26, 2012
View
9 lib/puppet/provider/cloudstack_instance/default.rb
@@ -25,6 +25,7 @@ def self.instances
:domain => server.domain_name,
:host => server.host_name,
:state => server.state.downcase,
+ :group => server.group,
#:keypair => server.keypair,
:ensure => :present
# I may want to print network information here
@@ -53,7 +54,8 @@ def create
:image_id => image_id,
:flavor_id => flavor_id,
:zone_id => zone_id,
- :network_ids => network_id
+ :network_ids => network_id,
+ :group => resource[:group]
#:keypair => resource[:keypair]
)
end
@@ -67,6 +69,7 @@ def internal_ipaddress
return @property_hash[:internal_ipaddress] if @property_hash[:internal_ipaddress]
end
+
# perform adhoc state changes
def state=(state)
if state == 'running'
@@ -79,6 +82,10 @@ def state=(state)
@property_hash[:state] = state
end
+ def group
+ @property_hash[:group]
+ end
+
def network
if nets = connection.list_networks('id' => @property_hash[:network_id])['listnetworksresponse']['network']
nets.first['name']
View
5 lib/puppet/type/cloudstack_instance.rb
@@ -45,6 +45,10 @@
desc 'name of zone'
end
+ newproperty(:group) do
+ desc 'group of system'
+ end
+
newproperty(:network) do
desc 'name of network the instance belongs to'
end
@@ -74,6 +78,7 @@ def insync?(is)
end
end
+
# this causes querying the resources to fail ;(
#validate do
# unless self[:zone_id] and self[:template_id] and self[:service_offering_id]
View
9 tests/example.pp
@@ -43,6 +43,15 @@
# hostname
}
+cloudstack_instance { 'foo2':
+ ensure => present,
+ flavor => 'Small Instance',
+ zone => 'FMT-ACS-001',
+ image => 'CentOS 5.6(64-bit) no GUI (XenServer)',
+ network => 'puppetlabs-network',
+ group => 'foo2',
+}
+
}

0 comments on commit a5b939d

Please sign in to comment.