summaryrefslogtreecommitdiffstats
path: root/lib/launch_helper.rb
blob: 0fe5ea6dce00570d38ae285c76dc1b386e99a50b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
module OpenShift
  module Ops
    class LaunchHelper
      MYDIR = File.expand_path(File.dirname(__FILE__))

      def self.expand_name(name)
        return [name] unless name =~ /^([a-zA-Z0-9\-]+)\{(\d+)-(\d+)\}$/

        # Regex matched, so grab the values
        start_num = $2
        end_num = $3

        retval = []
        start_num.upto(end_num) do |i|
          retval << "#{$1}#{i}"
        end

        return retval
      end

      def self.get_gce_host_types()
        return Dir.glob("#{MYDIR}/../playbooks/gce/*").map { |d| File.basename(d) }
      end

      def self.get_aws_host_types()
        return Dir.glob("#{MYDIR}/../playbooks/aws/*").map { |d| File.basename(d) }
      end
    end
  end
end