lib/vmc/client.rb in af-0.3.18.12 vs lib/vmc/client.rb in af-0.3.19.beta.1
- old
+ new
@@ -26,11 +26,11 @@
# Error codes
VMC_HTTP_ERROR_CODES = [ 400, 500 ]
HTTP_TIMEOUT = ENV['TIMEOUT'] ? ENV['TIMEOUT'].to_i : 10*60
-
+
# Errors
class BadTarget < RuntimeError; end
class AuthError < RuntimeError; end
class TargetError < RuntimeError; end
class NotFound < RuntimeError; end
@@ -156,20 +156,20 @@
path = path.gsub('//', '/')
url = path(VMC::APPS_PATH, name, "instances", instance, "files", path)
_, body, headers = http_get(url)
body
end
-
+
def app_download(name,path)
check_login_status
url = path(VMC::APPS_PATH, name, "application")
status, body, headers = http_get(url,'application/octet-stream')
file = File.new(path,"wb")
file.write(body)
file.close
end
-
+
def app_pull(name, dir)
check_login_status
url = path(VMC::APPS_PATH, name, "application")
status, body, headers = http_get(url,'application/octet-stream')
file = Tempfile.new(name)
@@ -245,15 +245,15 @@
services = app[:services] || []
services.delete(service)
app[:services] = services
update_app(appname, app)
end
-
+
def export_service(service)
json_get(path(VMC::SERVICE_EXPORT_PATH, service))
end
-
+
def import_service(service,uri)
json_post(path(VMC::SERVICE_IMPORT_PATH, service),{:uri => uri})
end
######################################################
@@ -388,20 +388,20 @@
@target.sub(pattern,'')
else
"aws.af.cm"
end
end
-
- def infra_valid?(name)
+
+ def infra_valid?(name)
infras.detect { |i| i[:infra] == name }
end
def infra_descriptions
- infras.map { |i| i[:description] }
+ infras.select{|i| !i.has_key?(:available) || i[:available] == true}.map { |i| i[:description] }
end
-
- def infra_name_for_description(desc)
+
+ def infra_name_for_description(desc)
info = infras.detect { |i| i[:description] == desc }
info ? info[:infra] : ""
end
def suggest_url(infra=nil)
@@ -557,7 +557,7 @@
end
def infras_match?(o1,o2)
o1 && o2 && ( o1[:infra] == o2[:infra])
end
-
+
end