hugo 0.1.10 → 0.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/hugo/app.rb +32 -7
- data/lib/hugo/aws/ec2.rb +5 -0
- data/lib/hugo/cloud.rb +13 -0
- metadata +2 -2
    
        data/lib/hugo/app.rb
    CHANGED
    
    | @@ -13,12 +13,19 @@ class Hugo::App | |
| 13 13 | 
             
                  elsif instances < lb.instances.length
         | 
| 14 14 | 
             
                    delete_ec2(lb.instances.length - instances)
         | 
| 15 15 | 
             
                  end    
         | 
| 16 | 
            +
                else
         | 
| 17 | 
            +
                  instance(build_ec2(1)) unless instance
         | 
| 16 18 | 
             
                end
         | 
| 17 19 | 
             
              end
         | 
| 18 20 |  | 
| 19 21 | 
             
              def setup
         | 
| 20 | 
            -
                lb | 
| 21 | 
            -
                   | 
| 22 | 
            +
                if lb
         | 
| 23 | 
            +
                  lb.instances.each do |i|
         | 
| 24 | 
            +
                    setup_ec2(i)
         | 
| 25 | 
            +
                  end
         | 
| 26 | 
            +
                else
         | 
| 27 | 
            +
                  puts instance
         | 
| 28 | 
            +
                  setup_ec2(instance)
         | 
| 22 29 | 
             
                end
         | 
| 23 30 | 
             
                puts "Setup Completed"
         | 
| 24 31 | 
             
              end
         | 
| @@ -44,6 +51,10 @@ class Hugo::App | |
| 44 51 | 
             
                  self.dna.merge!(options)
         | 
| 45 52 | 
             
                end
         | 
| 46 53 | 
             
              end
         | 
| 54 | 
            +
             | 
| 55 | 
            +
              def instance(arg=nil)
         | 
| 56 | 
            +
                set_or_return(:instance, arg, :kind_of => [String]) 
         | 
| 57 | 
            +
              end
         | 
| 47 58 |  | 
| 48 59 | 
             
              def name(arg=nil)
         | 
| 49 60 | 
             
                set_or_return(:name, arg, :kind_of => [String]) 
         | 
| @@ -112,11 +123,13 @@ class Hugo::App | |
| 112 123 | 
             
            private
         | 
| 113 124 |  | 
| 114 125 | 
             
              def build_ec2(i=1)
         | 
| 126 | 
            +
                instance_id = nil
         | 
| 115 127 | 
             
                i.times do
         | 
| 116 128 | 
             
                  instance_id = create_ec2
         | 
| 117 129 | 
             
                  #setup_ec2(instance_id)
         | 
| 118 | 
            -
                  lb.add(instance_id)
         | 
| 130 | 
            +
                  lb.add(instance_id) if lb
         | 
| 119 131 | 
             
                end
         | 
| 132 | 
            +
                instance_id
         | 
| 120 133 | 
             
              end
         | 
| 121 134 |  | 
| 122 135 | 
             
              def create_ec2
         | 
| @@ -155,13 +168,15 @@ private | |
| 155 168 | 
             
                commands << 'if [ -d "./hugo-repos" ]; then echo "setup already run"; else sudo gem install chef-deploy --no-ri --no-rdoc; fi'
         | 
| 156 169 | 
             
                commands << 'if [ -d "./hugo-repos" ]; then echo "setup already run"; else sudo gem install git --no-ri --no-rdoc; fi'
         | 
| 157 170 | 
             
                commands << "if [ -d \"./hugo-repos\" ]; then echo \"setup already run\"; else git clone #{self.cookbook} ~/hugo-repos; fi"
         | 
| 158 | 
            -
                Hugo::Aws::Ec2.find(instance_id) | 
| 171 | 
            +
                ec2 = Hugo::Aws::Ec2.find(instance_id)
         | 
| 172 | 
            +
                puts ec2.uri
         | 
| 173 | 
            +
                ec2.ssh(commands, nil, File.join(key_path, key_name))
         | 
| 159 174 | 
             
              end
         | 
| 160 175 |  | 
| 161 176 | 
             
              def deploy_ec2
         | 
| 162 177 |  | 
| 163 178 | 
             
                commands = []
         | 
| 164 | 
            -
                commands << "cd hugo-repos && git pull"
         | 
| 179 | 
            +
                commands << "cd hugo-repos && git reset --hard && git pull"
         | 
| 165 180 | 
             
                commands << 'sudo chef-solo -c /home/ubuntu/hugo-repos/config/solo.rb -j /home/ubuntu/dna.json'
         | 
| 166 181 |  | 
| 167 182 | 
             
                database_info = { 
         | 
| @@ -183,9 +198,14 @@ private | |
| 183 198 | 
             
                  :app => deploy_info
         | 
| 184 199 | 
             
                )
         | 
| 185 200 |  | 
| 186 | 
            -
                lb | 
| 187 | 
            -
                   | 
| 201 | 
            +
                if lb
         | 
| 202 | 
            +
                  lb.instances.each do |i|
         | 
| 203 | 
            +
                    Hugo::Aws::Ec2.find(i).ssh(commands, dna, File.join(key_path, key_name))
         | 
| 204 | 
            +
                  end
         | 
| 205 | 
            +
                else
         | 
| 206 | 
            +
                  Hugo::Aws::Ec2.find(instance).ssh(commands, dna, File.join(key_path, key_name))      
         | 
| 188 207 | 
             
                end
         | 
| 208 | 
            +
                
         | 
| 189 209 | 
             
              end
         | 
| 190 210 |  | 
| 191 211 | 
             
              def delete_ec2(i=1)
         | 
| @@ -196,5 +216,10 @@ private | |
| 196 216 |  | 
| 197 217 | 
             
                end  
         | 
| 198 218 | 
             
              end
         | 
| 219 | 
            +
              
         | 
| 220 | 
            +
              def get_instance(uri)
         | 
| 221 | 
            +
                nil
         | 
| 222 | 
            +
              end
         | 
| 223 | 
            +
              
         | 
| 199 224 |  | 
| 200 225 | 
             
            end
         | 
    
        data/lib/hugo/aws/ec2.rb
    CHANGED
    
    | @@ -102,6 +102,11 @@ module Hugo | |
| 102 102 | 
             
                    @ec2 = AWS::EC2::Base.new(:access_key_id => ACCESS_KEY, :secret_access_key => SECRET_KEY)
         | 
| 103 103 | 
             
                    self.new(@ec2.describe_instances(:instance_id => instance).reservationSet.item[0].instancesSet.item[0])
         | 
| 104 104 | 
             
                  end
         | 
| 105 | 
            +
             | 
| 106 | 
            +
                  # def self.find(url)
         | 
| 107 | 
            +
                  #   @ec2 = AWS::EC2::Base.new(:access_key_id => ACCESS_KEY, :secret_access_key => SECRET_KEY)
         | 
| 108 | 
            +
                  #   self.new(@ec2.describe_instances(:instance_id => instance).reservationSet.item[0].instancesSet.item[0])
         | 
| 109 | 
            +
                  # end
         | 
| 105 110 |  | 
| 106 111 | 
             
                  def self.find_or_create(options)
         | 
| 107 112 | 
             
                    if options[:name]
         | 
    
        data/lib/hugo/cloud.rb
    CHANGED
    
    | @@ -86,6 +86,19 @@ Zone: #{ec2.zone} | |
| 86 86 |  | 
| 87 87 | 
             
            REPORT
         | 
| 88 88 | 
             
                  end
         | 
| 89 | 
            +
                else
         | 
| 90 | 
            +
                  ec2 = Hugo::Aws::Ec2.find(cloud_app.instance)
         | 
| 91 | 
            +
                  puts <<REPORT
         | 
| 92 | 
            +
             | 
| 93 | 
            +
            Since you are not running a balancer
         | 
| 94 | 
            +
            you need to remember to add #{ec2.name} as the instance method in your app
         | 
| 95 | 
            +
            -----------------------      
         | 
| 96 | 
            +
            Id: #{ec2.name}
         | 
| 97 | 
            +
            Uri: #{ec2.uri}
         | 
| 98 | 
            +
            Type: #{ec2.type}
         | 
| 99 | 
            +
            Zone: #{ec2.zone}
         | 
| 100 | 
            +
                  
         | 
| 101 | 
            +
            REPORT
         | 
| 89 102 | 
             
                end
         | 
| 90 103 |  | 
| 91 104 | 
             
              end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification 
         | 
| 2 2 | 
             
            name: hugo
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version 
         | 
| 4 | 
            -
              version: 0.1. | 
| 4 | 
            +
              version: 0.1.11
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors: 
         | 
| 7 7 | 
             
            - Tom Wilson
         | 
| @@ -10,7 +10,7 @@ autorequire: | |
| 10 10 | 
             
            bindir: bin
         | 
| 11 11 | 
             
            cert_chain: []
         | 
| 12 12 |  | 
| 13 | 
            -
            date: 2010-02- | 
| 13 | 
            +
            date: 2010-02-04 00:00:00 -05:00
         | 
| 14 14 | 
             
            default_executable: 
         | 
| 15 15 | 
             
            dependencies: 
         | 
| 16 16 | 
             
            - !ruby/object:Gem::Dependency 
         |