1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

[terremark] Updates reference to service

This commit is contained in:
Paul Thornthwaite 2012-12-22 23:23:10 +00:00
parent 20a5da96bf
commit a0a38fd8ca
17 changed files with 79 additions and 79 deletions

View file

@ -12,7 +12,7 @@ module Fog
def destroy
requires :id
connection.delete_public_ip(id)
service.delete_public_ip(id)
true
end

View file

@ -4,13 +4,13 @@ module Fog
module Mock
def addresses(options = {})
Fog::Terremark::Shared::Addresses.new(options.merge(:connection => self))
Fog::Terremark::Shared::Addresses.new(options.merge(:service => self))
end
end
module Real
def addresses(options = {})
Fog::Terremark::Shared::Addresses.new(options.merge(:connection => self))
Fog::Terremark::Shared::Addresses.new(options.merge(:service => self))
end
end
@ -19,11 +19,11 @@ module Fog
model Fog::Terremark::Shared::Address
def all
load(connection.get_public_ips(vdc_id).body['PublicIpAddresses'])
load(service.get_public_ips(vdc_id).body['PublicIpAddresses'])
end
def get(ip_id)
if ip_id && ip = connection.get_public_ip(ip_id).body
if ip_id && ip = service.get_public_ip(ip_id).body
new(ip)
elsif !ip_id
nil
@ -33,7 +33,7 @@ module Fog
end
def vdc_id
@vdc_id ||= connection.default_vdc_id
@vdc_id ||= service.default_vdc_id
end
private

View file

@ -8,23 +8,23 @@ module Fog
module Mock
def images(options = {})
Fog::Terremark::Shared::Images.new(options.merge(:connection => self))
Fog::Terremark::Shared::Images.new(options.merge(:service => self))
end
end
module Real
def images(options = {})
Fog::Terremark::Shared::Images.new(options.merge(:connection => self))
Fog::Terremark::Shared::Images.new(options.merge(:service => self))
end
end
class Images < Fog::Collection
model Fog::Terremark::Shared::Image
model Fog::Terremark::Shared::Image
def all
data = connection.get_catalog(vdc_id).body['CatalogItems'].select do |entity|
data = service.get_catalog(vdc_id).body['CatalogItems'].select do |entity|
entity['type'] == "application/vnd.vmware.vcloud.catalogItem+xml"
end
load(data)
@ -32,7 +32,7 @@ module Fog
def vdc_id
@vdc_id ||= connection.default_vdc_id
@vdc_id ||= service.default_vdc_id
end
private

View file

@ -16,8 +16,8 @@ module Fog
attribute :public_ip_address_id
def destroy(delete_public_ip=true)
connection.delete_internet_service(self.Id)
connection.delete_public_ip(self.PublicIpAddress["Id"]) if delete_public_ip
service.delete_internet_service(self.Id)
service.delete_public_ip(self.PublicIpAddress["Id"]) if delete_public_ip
true
end
@ -25,8 +25,8 @@ module Fog
requires :Name, :Protocol, :Port
if not public_ip_address_id
#Create the first internet service and allocate public IP
data = connection.create_internet_service(
vdc = connection.default_vdc_id,
data = service.create_internet_service(
vdc = service.default_vdc_id,
name = self.Name,
protocol = self.Protocol,
port = self.Port,
@ -37,7 +37,7 @@ module Fog
)
else
#create additional services to existing Public IP
data = connection.add_internet_service(
data = service.add_internet_service(
ip_id = public_ip_address_id,
name = self.Name,
protocol = self.Protocol,
@ -46,7 +46,7 @@ module Fog
'Enabled' => 'true',
"Description" => self.Name
}
)
)
end
merge_attributes(data.body)
true

View file

@ -7,13 +7,13 @@ module Fog
module Mock
def internetservices(options = {})
Fog::Terremark::Shared::Servers.new(options.merge(:connection => self))
Fog::Terremark::Shared::Servers.new(options.merge(:service => self))
end
end
module Real
def internetservices(options = {})
Fog::Terremark::Shared::InternetServices.new(options.merge(:connection => self))
Fog::Terremark::Shared::InternetServices.new(options.merge(:service => self))
end
end
@ -22,18 +22,18 @@ module Fog
model Fog::Terremark::Shared::InternetService
def all
data = connection.get_internet_services(vdc_id).body["InternetServices"]
data = service.get_internet_services(vdc_id).body["InternetServices"]
load(data)
end
def get(service_id)
data = connection.get_internet_services(vdc_id)
data = service.get_internet_services(vdc_id)
internet_service = services.body["InternetServices"].select {|item| item["Id"] == service_id}
new(internetservice)
end
def vdc_id
@vdc_id ||= connection.default_vdc_id
@vdc_id ||= service.default_vdc_id
end
end

View file

@ -17,7 +17,7 @@ module Fog
def ips
#Until there is a real model for these ?
connection.get_network_ips(id).body['IpAddresses']
service.get_network_ips(id).body['IpAddresses']
end
private

View file

@ -4,13 +4,13 @@ module Fog
module Mock
def networks(options = {})
Fog::Terremark::Shared::Networks.new(options.merge(:connection => self))
Fog::Terremark::Shared::Networks.new(options.merge(:service => self))
end
end
module Real
def networks(options = {})
Fog::Terremark::Shared::Networks.new(options.merge(:connection => self))
Fog::Terremark::Shared::Networks.new(options.merge(:service => self))
end
end
@ -19,14 +19,14 @@ module Fog
model Fog::Terremark::Shared::Network
def all
data = connection.get_vdc(vdc_id).body['AvailableNetworks'].map do |network|
connection.get_network(network["href"].split("/").last).body
data = service.get_vdc(vdc_id).body['AvailableNetworks'].map do |network|
service.get_network(network["href"].split("/").last).body
end
load(data)
end
def get(network_id)
if network_id && network = connection.get_network(network_id).body
if network_id && network = service.get_network(network_id).body
new(network)
elsif !network_id
nil
@ -36,7 +36,7 @@ module Fog
end
def vdc_id
@vdc_id ||= connection.default_vdc_id
@vdc_id ||= service.default_vdc_id
end
private

View file

@ -16,12 +16,12 @@ module Fog
attribute :InternetServiceId
def destroy
connection.delete_node_service(self.Id)
service.delete_node_service(self.Id)
end
def save
requires :Name, :Port, :InternetServiceId
data = connection.add_node_service(
data = service.add_node_service(
service_id = self.InternetServiceId,
ip = self.IpAddress,
name = self.Name,
@ -29,7 +29,7 @@ module Fog
options = {"Enabled" => 'true',
"Description" => self.Name,
}
)
merge_attributes(data.body)
true

View file

@ -7,22 +7,22 @@ module Fog
module Mock
def nodeservices(options = {})
Fog::Terremark::Shared::Servers.new(options.merge(:connection => self))
Fog::Terremark::Shared::Servers.new(options.merge(:service => self))
end
end
module Real
def nodeservices(options = {})
Fog::Terremark::Shared::NodeServices.new(options.merge(:connection => self))
Fog::Terremark::Shared::NodeServices.new(options.merge(:service => self))
end
end
class NodeServices < Fog::Collection
model Fog::Terremark::Shared::NodeService
def all(internet_service_id)
data = connection.get_node_services(internet_service_id).body["NodeServices"]
data = service.get_node_services(internet_service_id).body["NodeServices"]
load(data)
end

View file

@ -31,17 +31,17 @@ module Fog
attribute :IpAddress
def reload
merge_attributes(connection.get_vapp(id).body)
merge_attributes(service.get_vapp(id).body)
end
def destroy
case self.status
when VAppStatus::BEING_CREATED, VAppStatus::BEING_DEPLOYED
return false
when VAppStatus::POWERED_ON
data = connection.power_off(self.id).body
data = service.power_off(self.id).body
wait_for { off? }
end
connection.delete_vapp(self.id)
service.delete_vapp(self.id)
true
end
@ -54,15 +54,15 @@ module Fog
end
def internet_services
@internet_services ||= connection.internetservices.all.select {|item| item.Name == self.name}
@internet_services ||= service.internetservices.all.select {|item| item.Name == self.name}
end
def delete_internet_services
#Find the internet service
while (service = internet_services.pop) do
nodes = connection.nodeservices.all(service.Id)
nodes = service.nodeservices.all(service.Id)
#Delete all the associated nodes
nodes.select { |item| item.destroy }
#Clear out the services
@ -87,7 +87,7 @@ module Fog
def power_on(options = {})
requires :id
begin
connection.power_on(id)
service.power_on(id)
rescue Excon::Errors::InternalServerError => e
#Frankly we shouldn't get here ...
raise e unless e.to_s =~ /because it is already powered on/
@ -98,7 +98,7 @@ module Fog
def power_off
requires :id
begin
connection.power_off(id)
service.power_off(id)
rescue Excon::Errors::InternalServerError => e
#Frankly we shouldn't get here ...
raise e unless e.to_s =~ /because it is already powered off/
@ -109,7 +109,7 @@ module Fog
def shutdown
requires :id
begin
connection.power_shutdown(id)
service.power_shutdown(id)
rescue Excon::Errors::InternalServerError => e
#Frankly we shouldn't get here ...
raise e unless e.to_s =~ /because it is already powered off/
@ -119,7 +119,7 @@ module Fog
def power_reset
requires :id
connection.power_reset(id)
service.power_reset(id)
true
end
@ -137,7 +137,7 @@ module Fog
for port in ports
if not public_ip_info
#Create the first internet service and allocate public IP
inet_services = connection.internetservices.create({
inet_services = service.internetservices.create({
"Name" => self.name,
"Protocol" => proto,
"Port" => port,
@ -147,8 +147,8 @@ module Fog
else
#create additional services to existing Public IP
inet_services = connection.internetservices.create({
"public_ip_address_id" => public_ip_info["Id"],
inet_services = service.internetservices.create({
"public_ip_address_id" => public_ip_info["Id"],
"Name" => self.name,
"Protocol" => proto,
"Port" => port,
@ -158,7 +158,7 @@ module Fog
end
#Create the associate node service to the server
connection.nodeservices.create({"Name" => self.name,
service.nodeservices.create({"Name" => self.name,
"IpAddress" => self.IpAddress,
"Port" => port,
"InternetServiceId" => internet_service_id
@ -172,9 +172,9 @@ module Fog
requires :name
if powerOn
end
data = connection.instantiate_vapp_template(
server_name=name,
vapp_template=image,
data = service.instantiate_vapp_template(
server_name=name,
vapp_template=image,
options={
'ssh_key_fingerprint' => sshkeyFingerPrint,
'cpus' => vcpus,

View file

@ -7,13 +7,13 @@ module Fog
module Mock
def servers(options = {})
Fog::Terremark::Shared::Servers.new(options.merge(:connection => self))
Fog::Terremark::Shared::Servers.new(options.merge(:service => self))
end
end
module Real
def servers(options = {})
Fog::Terremark::Shared::Servers.new(options.merge(:connection => self))
Fog::Terremark::Shared::Servers.new(options.merge(:service => self))
end
end
@ -23,22 +23,22 @@ module Fog
def all
data = []
connection.get_vdc(vdc_id).body['ResourceEntities'].select do |entity|
data << connection.servers.get(entity["href"].split('/').last)
service.get_vdc(vdc_id).body['ResourceEntities'].select do |entity|
data << service.servers.get(entity["href"].split('/').last)
end
data
end
def get(server_id)
if server_id
new(connection.get_vapp(server_id).body)
new(service.get_vapp(server_id).body)
else
nil
end
end
def vdc_id
@vdc_id ||= connection.default_vdc_id
@vdc_id ||= service.default_vdc_id
end
private

View file

@ -23,12 +23,12 @@ module Fog
new_cancel_link = attributes.delete('Link')
super
self.owner = connection.parse(new_owner)
self.owner = service.parse(new_owner)
if new_result
self.result = connection.parse(new_result)
self.result = service.parse(new_result)
end
self.error = connection.parse(new_error) if new_error
@cancel_link = connection.parse(new_cancel_link) if new_cancel_link
self.error = service.parse(new_error) if new_error
@cancel_link = service.parse(new_cancel_link) if new_cancel_link
end
def ready?

View file

@ -7,13 +7,13 @@ module Fog
module Mock
def tasks
Fog::Terremark::Shared::Tasks.new(:connection => self)
Fog::Terremark::Shared::Tasks.new(:service => self)
end
end
module Real
def tasks
Fog::Terremark::Shared::Tasks.new(:connection => self)
Fog::Terremark::Shared::Tasks.new(:service => self)
end
end
@ -22,12 +22,12 @@ module Fog
model Fog::Terremark::Shared::Task
def all
data = connection.get_tasks_list(task_list_id).body['Tasks']
data = service.get_tasks_list(task_list_id).body['Tasks']
load(data)
end
def get(task_id)
if task_id && task = connection.get_task(task_id).body
if task_id && task = service.get_task(task_id).body
new(task)
elsif !task_id
nil
@ -38,7 +38,7 @@ module Fog
def task_list_id
@task_list_id ||=
if connection.default_organization_id && organization = connection.get_organization(connection.default_organization_id).body
if service.default_organization_id && organization = service.get_organization(service.default_organization_id).body
organization['Links'].detect {|link| link['type'] == 'application/vnd.vmware.vcloud.tasksList+xml'}['href'].split('/').last.to_i
else
nil

View file

@ -13,19 +13,19 @@ module Fog
attribute :AvailableNetworks
attribute :links
def networks
connection.networks(:vdc_id => id)
service.networks(:vdc_id => id)
end
def addresses
connection.addresses(:vdc_id => id)
service.addresses(:vdc_id => id)
end
def servers
connection.servers(:vdc_id => id)
service.servers(:vdc_id => id)
end
def images
connection.images(:vdc_id => id)
service.images(:vdc_id => id)
end
private

View file

@ -4,13 +4,13 @@ module Fog
module Mock
def vdcs(options = {})
Fog::Terremark::Shared::Vdcs.new(options.merge(:connection => self))
Fog::Terremark::Shared::Vdcs.new(options.merge(:service => self))
end
end
module Real
def vdcs(options = {})
Fog::Terremark::Shared::Vdcs.new(options.merge(:connection => self))
Fog::Terremark::Shared::Vdcs.new(options.merge(:service => self))
end
end
@ -19,14 +19,14 @@ module Fog
model Fog::Terremark::Shared::Vdc
def all
data = connection.get_organization(organization_id).body['Links'].select do |entity|
data = service.get_organization(organization_id).body['Links'].select do |entity|
entity['type'] == 'application/vnd.vmware.vcloud.vdc+xml'
end
load(data)
end
def get(vdc_id)
if vdc_id && vdc = connection.get_vdc(vdc_id).body
if vdc_id && vdc = service.get_vdc(vdc_id).body
new(vdc)
elsif !vdc_id
nil
@ -36,7 +36,7 @@ module Fog
end
def organization_id
@vdc_id ||= connection.default_organization_id
@vdc_id ||= service.default_organization_id
end
private

View file

@ -7,7 +7,7 @@ module Fog
def parse(data)
case data['type']
when 'application/vnd.vmware.vcloud.vApp+xml'
servers.new(data.merge!(:connection => self))
servers.new(data.merge!(:service => self))
else
data
end

View file

@ -23,7 +23,7 @@ module Fog
def parse(data)
case data['type']
when 'application/vnd.vmware.vcloud.vApp+xml'
servers.new(data.merge!(:connection => self))
servers.new(data.merge!(:service => self))
else
data
end