lib/poolparty/net/remoter_base.rb in auser-poolparty-0.2.45 vs lib/poolparty/net/remoter_base.rb in auser-poolparty-0.2.46

- old
+ new

@@ -75,10 +75,24 @@ end # List the instances for the current key pair, regardless of their states # If no keypair is passed, select them all def list_of_instances(keyp=nil) key = keyp ? keyp : keypair - @describe_instances ||= describe_instances.select {|a| key ? a[:keypair] == key : true } + unless @describe_instances + tmpInstanceList = describe_instances.select {|a| key ? a[:keypair] == key : true } + has_master = tmpInstanceList.collect {|a| a[:name] }.include?("master") + if has_master + @describe_instances = tmpInstanceList + else + @id = 0 + @describe_instances = tmpInstanceList.sort_by {|a| a[:status] }.map do |inst| + inst[:name] = (@id == 0 ? "master" : "node#{@id}") + @id += 1 + inst + end + end + end + @describe_instances end # Instances # Get the master from the cloud def master # remote_instances_list.select {|a| a.master }.first \ No newline at end of file