Sha256: 120eb8a3277cf16a24e1b8694a0dba1875d5e6da15c9d11b148d77d148975be8
Contents?: true
Size: 1.68 KB
Versions: 1
Compression:
Stored size: 1.68 KB
Contents
require 'larrow/qingcloud' module Larrow module Runner module Service class Cloud include Qingcloud def initialize args={} Qingcloud.remove_connection access_id = args[:qy_access_key_id] secret_key = args[:qy_secret_access_key] zone_id = args[:zone_id] @keypair_id = args[:keypair_id] Qingcloud.establish_connection access_id,secret_key,zone_id end # return: Array< [ instance,eip ] > # WARN: eips contains promise object, so it should be force def create image_id:nil,count:1 RunLogger.level(1).detail "assign node" instances = Instance.create(image_id: image_id||'trustysrvx64c', count:count, login_mode:'keypair', keypair_id: @keypair_id ) eips = Eip.create(count:count) (0...count).map do |i| RunLogger.level(1).detail "bind ip: #{eips[i].address}" eips[i] = eips[i].associate instances[i].id [ instances[i], eips[i] ] end end # return image future def create_image instance_id Image.create instance_id end def image? image_id Image.list(:self, ids: [image_id]).size == 1 end # concurrent destroy(force) def destroy *args args.map(&:destroy).map(&:force) end def check_available KeyPair.list self rescue Qingcloud.remove_connection raise $! end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
larrow-runner-0.0.2 | lib/larrow/runner/service/cloud.rb |