lib/fog/rackspace/models/compute_v2/server.rb in fog-maestrodev-1.18.0.20131219193542 vs lib/fog/rackspace/models/compute_v2/server.rb in fog-maestrodev-1.19.0.20131219203941

- old
+ new

@@ -1,5 +1,6 @@ +# -*- coding: utf-8 -*- require 'fog/compute/models/server' require 'fog/rackspace/models/compute_v2/metadata' module Fog module Compute @@ -519,25 +520,30 @@ # Setup server for SSH access # @see Servers#bootstrap def setup(credentials = {}) requires :public_ip_address, :identity, :public_key, :username - Fog::SSH.new(public_ip_address, username, credentials).run([ + commands = [ %{mkdir .ssh}, %{echo "#{public_key}" >> ~/.ssh/authorized_keys}, - %{passwd -l #{username}}, + password_lock, %{echo "#{Fog::JSON.encode(attributes)}" >> ~/attributes.json}, %{echo "#{Fog::JSON.encode(metadata)}" >> ~/metadata.json} - ]) + ].compact + Fog::SSH.new(public_ip_address, username, credentials).run(commands) rescue Errno::ECONNREFUSED sleep(1) retry end private def adminPass=(new_admin_pass) @password = new_admin_pass + end + + def password_lock + "passwd -l #{username}" unless attributes[:no_passwd_lock] end end end end end