mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
add models for firewall, egress_firewall, networks, port_forwarding, projects, public_ip_addresses. Also fix 3015 (support project_id in key calls)
This commit is contained in:
parent
5ffa0ddac1
commit
7a1a43fb6b
41 changed files with 572 additions and 73 deletions
|
@ -11,33 +11,45 @@ module Fog
|
|||
requires :cloudstack_host
|
||||
|
||||
recognizes :cloudstack_api_key, :cloudstack_secret_access_key, :cloudstack_session_key, :cloudstack_session_id,
|
||||
:cloudstack_port, :cloudstack_path, :cloudstack_scheme, :cloudstack_persistent
|
||||
|
||||
request_path 'fog/cloudstack/requests/compute'
|
||||
|
||||
:cloudstack_port, :cloudstack_path, :cloudstack_scheme, :cloudstack_persistent, :cloudstack_project_id
|
||||
|
||||
model_path 'fog/cloudstack/models/compute'
|
||||
request_path 'fog/cloudstack/requests/compute'
|
||||
|
||||
model :address
|
||||
model :disk_offering
|
||||
collection :disk_offerings
|
||||
model :egress_firewall_rule
|
||||
collection :egress_firewall_rules
|
||||
model :firewall_rule
|
||||
collection :firewall_rules
|
||||
model :flavor
|
||||
collection :flavors
|
||||
model :job
|
||||
collection :jobs
|
||||
model :server
|
||||
collection :servers
|
||||
model :image
|
||||
collection :images
|
||||
model :job
|
||||
collection :jobs
|
||||
model :network
|
||||
collection :networks
|
||||
model :public_ip_address
|
||||
collection :public_ip_addresses
|
||||
model :port_forwarding_rule
|
||||
collection :port_forwarding_rules
|
||||
model :project
|
||||
collection :projects
|
||||
model :security_group
|
||||
collection :security_groups
|
||||
model :security_group_rule
|
||||
collection :security_group_rules
|
||||
model :server
|
||||
collection :servers
|
||||
model :volume
|
||||
collection :volumes
|
||||
model :snapshot
|
||||
collection :snapshots
|
||||
model :zone
|
||||
collection :zones
|
||||
|
||||
request :activate_project
|
||||
request :add_account_to_project
|
||||
request :add_baremetal_dhcp
|
||||
|
@ -532,6 +544,7 @@ module Fog
|
|||
@cloudstack_secret_access_key = options[:cloudstack_secret_access_key]
|
||||
@cloudstack_session_id = options[:cloudstack_session_id]
|
||||
@cloudstack_session_key = options[:cloudstack_session_key]
|
||||
@cloudstack_project_id = options[:cloudstack_project_id]
|
||||
@host = options[:cloudstack_host]
|
||||
@path = options[:cloudstack_path] || '/client/api'
|
||||
@port = options[:cloudstack_port] || 443
|
||||
|
|
15
lib/fog/cloudstack/models/compute/egress_firewall_rule.rb
Normal file
15
lib/fog/cloudstack/models/compute/egress_firewall_rule.rb
Normal file
|
@ -0,0 +1,15 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Cloudstack
|
||||
class EgressFirewallRule < Fog::Model
|
||||
identity :id, :aliases => 'id'
|
||||
attribute :protocol, :aliases => 'protocol'
|
||||
attribute :network_id, :aliases => 'networkid'
|
||||
attribute :state, :aliases => 'state'
|
||||
attribute :cidr_list, :aliases => 'cidrlist'
|
||||
attribute :tags, :type => :array
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
25
lib/fog/cloudstack/models/compute/egress_firewall_rules.rb
Normal file
25
lib/fog/cloudstack/models/compute/egress_firewall_rules.rb
Normal file
|
@ -0,0 +1,25 @@
|
|||
require 'fog/core/collection'
|
||||
require 'fog/cloudstack/models/compute/egress_firewall_rule'
|
||||
|
||||
module Fog
|
||||
module Compute
|
||||
class Cloudstack
|
||||
class EgressFirewallRules < Fog::Collection
|
||||
model Fog::Compute::Cloudstack::EgressFirewallRule
|
||||
|
||||
def all(options = {})
|
||||
response = service.list_egress_firewall_rules(options)
|
||||
egress_firewall_rules = response["listegressfirewallrulesresponse"]["firewallrule"] || []
|
||||
load(egress_firewall_rules)
|
||||
end
|
||||
|
||||
def get(address_id)
|
||||
options = { 'id' => address_id }
|
||||
response = service.list_egress_firewall_rules(options)
|
||||
egress_firewall_rules = response["listegressfirewallrulesresponse"]["firewallrule"].first
|
||||
new(egress_firewall_rules)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
24
lib/fog/cloudstack/models/compute/firewall_rule.rb
Normal file
24
lib/fog/cloudstack/models/compute/firewall_rule.rb
Normal file
|
@ -0,0 +1,24 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Cloudstack
|
||||
class FirewallRule < Fog::Model
|
||||
identity :id, :aliases => 'id'
|
||||
attribute :cidr_list, :aliases => 'cidrlist'
|
||||
attribute :start_port, :aliases => 'startport', :type => :integer
|
||||
attribute :end_port, :aliases => 'endport', :type => :integer
|
||||
attribute :icmp_code, :aliases => 'icmpcode'
|
||||
attribute :icmp_type, :aliases => 'icmptype'
|
||||
attribute :ip_address, :aliases => 'ipaddress'
|
||||
attribute :ip_address_id, :aliases => 'ipaddressid'
|
||||
attribute :network_id, :aliases => 'networkid'
|
||||
attribute :protocol
|
||||
attribute :state
|
||||
attribute :tags, :type => :array
|
||||
|
||||
# def save
|
||||
# end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
25
lib/fog/cloudstack/models/compute/firewall_rules.rb
Normal file
25
lib/fog/cloudstack/models/compute/firewall_rules.rb
Normal file
|
@ -0,0 +1,25 @@
|
|||
require 'fog/core/collection'
|
||||
require 'fog/cloudstack/models/compute/firewall_rule'
|
||||
|
||||
module Fog
|
||||
module Compute
|
||||
class Cloudstack
|
||||
class FirewallRules < Fog::Collection
|
||||
model Fog::Compute::Cloudstack::FirewallRule
|
||||
|
||||
def all(options = {})
|
||||
response = service.list_firewall_rules(options)
|
||||
firewall_rules = response["listfirewallrulesresponse"]["firewallrule"] || []
|
||||
load(firewall_rules)
|
||||
end
|
||||
|
||||
def get(address_id)
|
||||
options = { 'id' => address_id }
|
||||
response = service.list_firewall_rules(options)
|
||||
firewall_rules = response["listfirewallrulesresponse"]["firewallrule"].first
|
||||
new(firewall_rules)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -5,12 +5,14 @@ module Fog
|
|||
identity :id, :aliases => 'id'
|
||||
attribute :cpu_number, :aliases => 'cpunumber'
|
||||
attribute :cpu_speed, :aliases => 'cpuspeed'
|
||||
attribute :created
|
||||
attribute :created, :type => :time
|
||||
attribute :default_use, :aliases => 'defaultuse'
|
||||
attribute :display_text, :aliases => 'display_text'
|
||||
attribute :domain
|
||||
attribute :host_tags, :aliases => 'host_tags'
|
||||
attribute :is_system, :aliases => 'is_system'
|
||||
attribute :is_system, :aliases => 'issystem', :type => :boolean
|
||||
attribute :is_volatile, :aliases => 'isvolatile', :type => :boolean
|
||||
attribute :is_customized, :aliases => 'iscustomized', :type => :boolean
|
||||
attribute :limit_cpu_use, :aliases => 'limitcpuuse'
|
||||
attribute :tags
|
||||
attribute :system_vm_type, :aliases => 'systemvm'
|
||||
|
@ -27,7 +29,8 @@ module Fog
|
|||
def destroy
|
||||
raise Fog::Errors::Error.new('Destroying a flavor is not supported')
|
||||
end
|
||||
end # Server
|
||||
|
||||
end # Flavor
|
||||
end # Cloudstack
|
||||
end # Compute
|
||||
end # Fog
|
||||
|
|
|
@ -7,7 +7,7 @@ module Fog
|
|||
attribute :account_id, :aliases => 'accountid'
|
||||
attribute :bootable
|
||||
attribute :checksum
|
||||
attribute :created
|
||||
attribute :created, :type => :time
|
||||
attribute :cross_zones, :aliases => 'crossZones'
|
||||
attribute :details
|
||||
attribute :display_text, :aliases => 'displaytext'
|
||||
|
@ -19,10 +19,10 @@ module Fog
|
|||
attribute :hypervisor
|
||||
attribute :job_id, :aliases => 'jobid'
|
||||
attribute :job_status, :aliases => 'jobstatus'
|
||||
attribute :is_extractable, :aliases => 'isextractable'
|
||||
attribute :is_featured, :aliases => 'isfeatured'
|
||||
attribute :is_public, :aliases => 'ispublic'
|
||||
attribute :is_ready, :aliases => 'isready'
|
||||
attribute :is_extractable, :aliases => 'isextractable', :type => :boolean
|
||||
attribute :is_featured, :aliases => 'isfeatured', :type => :boolean
|
||||
attribute :is_public, :aliases => 'ispublic', :type => :boolean
|
||||
attribute :is_ready, :aliases => 'isready', :type => :boolean
|
||||
attribute :name
|
||||
attribute :os_type_id, :aliases => 'ostypeid'
|
||||
attribute :os_type_name, :aliases => 'ostypename'
|
||||
|
|
|
@ -9,7 +9,6 @@ module Fog
|
|||
|
||||
def all(filters={})
|
||||
options = get_filter_options(filters)
|
||||
|
||||
data = service.list_templates(options)["listtemplatesresponse"]["template"] || []
|
||||
load(data)
|
||||
end
|
||||
|
@ -17,7 +16,6 @@ module Fog
|
|||
def get(template_id, filters={})
|
||||
filter_option = get_filter_options(filters)
|
||||
options = filter_option.merge('id' => template_id)
|
||||
|
||||
if template = service.list_templates(options)["listtemplatesresponse"]["template"].first
|
||||
new(template)
|
||||
end
|
||||
|
|
|
@ -35,6 +35,16 @@ module Fog
|
|||
else self.job_result
|
||||
end
|
||||
end
|
||||
|
||||
def save
|
||||
raise Fog::Errors::Error.new('Creating a job is not supported')
|
||||
end
|
||||
|
||||
def destroy
|
||||
raise Fog::Errors::Error.new('Destroying a job is not supported')
|
||||
end
|
||||
|
||||
|
||||
end # Job
|
||||
end # Cloudstack
|
||||
end # Compute
|
||||
|
|
63
lib/fog/cloudstack/models/compute/network.rb
Normal file
63
lib/fog/cloudstack/models/compute/network.rb
Normal file
|
@ -0,0 +1,63 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Cloudstack
|
||||
class Network < Fog::Model
|
||||
identity :id, :aliases => 'id'
|
||||
attribute :name, :aliases => 'name'
|
||||
attribute :display_text, :aliases => 'displaytext'
|
||||
|
||||
attribute :broadcast_domain_type, :aliases => 'broadcastdomaintype'
|
||||
attribute :traffic_type, :aliases => 'traffictype'
|
||||
attribute :gateway, :aliases => 'gateway'
|
||||
attribute :cidr, :aliases => 'cidr'
|
||||
attribute :zone_id, :aliases => 'zoneid'
|
||||
attribute :zone_name, :aliases => 'zonename'
|
||||
|
||||
attribute :network_offering_id, :aliases => 'networkofferingid'
|
||||
attribute :network_offering_name, :aliases => 'networkofferingname'
|
||||
attribute :network_offering_display_text, :aliases => 'networkofferingdisplaytext'
|
||||
attribute :network_offering_conserve_mode, :aliases => 'networkofferingconservemode'
|
||||
attribute :network_offering_availability, :aliases => 'networkofferingavailability'
|
||||
attribute :is_system, :aliases => 'issystem', :type => :boolean
|
||||
attribute :state, :aliases => 'state'
|
||||
|
||||
attribute :related, :aliases => 'related'
|
||||
attribute :dns1, :aliases => 'dns1'
|
||||
attribute :dns2, :aliases => 'dns2'
|
||||
attribute :type, :aliases => 'type'
|
||||
attribute :acl_type, :aliases => 'acltype'
|
||||
attribute :project_id, :aliases => 'projectid'
|
||||
attribute :domain_id, :aliases => 'domainid'
|
||||
attribute :domain, :aliases => 'domain'
|
||||
|
||||
attribute :service, :aliases => 'service'
|
||||
attribute :network_domain, :aliases => 'domain'
|
||||
attribute :physical_network_id, :aliases => 'physicalnetworkid'
|
||||
attribute :restart_required, :aliases => 'restartrequired'
|
||||
attribute :specify_ip_ranges, :aliases => 'specifyipranges'
|
||||
attribute :canuse_for_deploy, :aliases => 'canusefordeploy'
|
||||
attribute :is_persistent, :aliases => 'ispersistent', :type => :boolean
|
||||
attribute :display_network, :aliases => 'displaynetwork'
|
||||
|
||||
def restart
|
||||
# AN - need to test
|
||||
response = @connection.restart_network( self.id)
|
||||
# there are a bunch of fields
|
||||
# should be mapped back to attributes
|
||||
end
|
||||
|
||||
def save
|
||||
raise Fog::Errors::Error.new('Creating a network is not supported')
|
||||
end
|
||||
|
||||
def destroy
|
||||
raise Fog::Errors::Error.new('Destroying a network is not supported')
|
||||
|
||||
# response = @connection.delete_network( {'id' => @self.id })
|
||||
# returns success & displaytext
|
||||
end
|
||||
|
||||
end # Network
|
||||
end # Cloudstack
|
||||
end # Compute
|
||||
end # Fog
|
39
lib/fog/cloudstack/models/compute/networks.rb
Normal file
39
lib/fog/cloudstack/models/compute/networks.rb
Normal file
|
@ -0,0 +1,39 @@
|
|||
|
||||
|
||||
require 'fog/core/collection'
|
||||
require 'fog/cloudstack/models/compute/network'
|
||||
|
||||
module Fog
|
||||
module Compute
|
||||
class Cloudstack
|
||||
class Networks < Fog::Collection
|
||||
model Fog::Compute::Cloudstack::Network
|
||||
|
||||
def all(filters={})
|
||||
options = get_filter_options(filters)
|
||||
data = service.list_networks(options)["listnetworksresponse"]["network"] || []
|
||||
load(data)
|
||||
end
|
||||
|
||||
def get(network_id, filters={})
|
||||
filter_option = get_filter_options(filters)
|
||||
options = filter_option.merge('id' => network_id)
|
||||
if data = service.list_networks(options)["listnetworksresponse"]["network"].first
|
||||
new(data)
|
||||
end
|
||||
rescue Fog::Compute::Cloudstack::BadRequest
|
||||
nil
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def get_filter_options(filters)
|
||||
default_filter = {
|
||||
'projectfilter' => 'self'
|
||||
}
|
||||
default_filter.merge(filters)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
25
lib/fog/cloudstack/models/compute/port_forwarding_rule.rb
Normal file
25
lib/fog/cloudstack/models/compute/port_forwarding_rule.rb
Normal file
|
@ -0,0 +1,25 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Cloudstack
|
||||
class PortForwardingRule < Fog::Model
|
||||
identity :id, :aliases => 'id'
|
||||
|
||||
attribute :private_port, :aliases => 'privateport'
|
||||
attribute :private_end_port, :aliases => 'privateendport'
|
||||
attribute :protocol, :aliases => 'protocol'
|
||||
attribute :public_port, :aliases => 'publicport'
|
||||
attribute :public_end_port, :aliases => 'publicendport'
|
||||
attribute :virtual_machine_id, :aliases => 'virtualmachineid'
|
||||
attribute :virtualmachinename, :aliases => 'virtualmachinename'
|
||||
attribute :virtualmachinedisplayname, :aliases => 'virtualmachinedisplayname'
|
||||
attribute :ipaddressid, :aliases => 'ipaddressid'
|
||||
attribute :ipaddress, :aliases => 'ipaddress'
|
||||
attribute :state, :aliases => 'state'
|
||||
attribute :cidrlist, :aliases => 'cidrlist'
|
||||
attribute :vmguestip, :aliases => 'vmguestip'
|
||||
attribute :networkid, :aliases => 'networkid'
|
||||
attribute :tags, :type => :array
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
25
lib/fog/cloudstack/models/compute/port_forwarding_rules.rb
Normal file
25
lib/fog/cloudstack/models/compute/port_forwarding_rules.rb
Normal file
|
@ -0,0 +1,25 @@
|
|||
require 'fog/core/collection'
|
||||
require 'fog/cloudstack/models/compute/port_forwarding_rule'
|
||||
|
||||
module Fog
|
||||
module Compute
|
||||
class Cloudstack
|
||||
class PortForwardingRules < Fog::Collection
|
||||
model Fog::Compute::Cloudstack::PortForwardingRule
|
||||
|
||||
def all(options = {})
|
||||
response = service.list_port_forwarding_rules(options)
|
||||
port_forwarding_rules = response["listportforwardingrulesresponse"]["portforwardingrule"] || []
|
||||
load(port_forwarding_rules)
|
||||
end
|
||||
|
||||
def get(address_id)
|
||||
options = { 'id' => address_id }
|
||||
response = service.list_port_forwarding_rules(options)
|
||||
port_forwarding_rules = response["listportforwardingrulesresponse"]["portforwardingrule"].first
|
||||
new(port_forwarding_rules)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
58
lib/fog/cloudstack/models/compute/project.rb
Normal file
58
lib/fog/cloudstack/models/compute/project.rb
Normal file
|
@ -0,0 +1,58 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Cloudstack
|
||||
class Project < Fog::Model
|
||||
identity :id, :aliases => 'id'
|
||||
attribute :name, :aliases => 'name'
|
||||
attribute :display_text, :aliases => 'displaytext'
|
||||
attribute :domain_id, :aliases => 'domainid'
|
||||
attribute :domain, :aliases => 'domain'
|
||||
attribute :account, :aliases => 'account'
|
||||
attribute :state, :aliases => 'state'
|
||||
attribute :tags, :aliases => 'tags'
|
||||
attribute :network_limit, :aliases => 'networklimit'
|
||||
attribute :network_total, :aliases => 'networktotal', :type => :integer
|
||||
attribute :network_available, :aliases => 'networkavailable'
|
||||
attribute :vpc_limit, :aliases => 'vpclimit'
|
||||
attribute :vpc_total, :aliases => 'vpctotal', :type => :integer
|
||||
attribute :vpc_available, :aliases => 'vpcavailable'
|
||||
attribute :cpu_limit, :aliases => 'cpulimit'
|
||||
attribute :cpu_total, :aliases => 'cputotal', :type => :integer
|
||||
attribute :cpu_available, :aliases => 'cpuavailable'
|
||||
attribute :memory_limit, :aliases => 'memorylimit'
|
||||
attribute :memory_total, :aliases => 'memorytotal', :type => :integer
|
||||
attribute :memory_available, :aliases => 'memoryavailable'
|
||||
attribute :primary_storage_limit, :aliases => 'primarystoragelimit'
|
||||
attribute :primary_storage_total, :aliases => 'primarystoragetotal', :type => :integer
|
||||
attribute :primary_storage_available, :aliases => 'primarystorageavailable'
|
||||
attribute :secondary_storage_limit, :aliases => 'secondarystoragelimit'
|
||||
attribute :secondary_storage_total, :aliases => 'secondarystoragetotal', :type => :integer
|
||||
attribute :secondary_storage_available, :aliases => 'secondarystorageavailable'
|
||||
attribute :vm_limit, :aliases => 'vmlimit'
|
||||
attribute :vm_total, :aliases => 'vmtotal', :type => :integer
|
||||
attribute :vm_available, :aliases => 'vmavailable'
|
||||
attribute :ip_limit, :aliases => 'iplimit'
|
||||
attribute :ip_total, :aliases => 'iptotal', :type => :integer
|
||||
attribute :ip_available, :aliases => 'ipavailable'
|
||||
attribute :volume_limit, :aliases => 'volumelimit'
|
||||
attribute :volume_total, :aliases => 'volumetotal', :type => :integer
|
||||
attribute :volume_available, :aliases => 'volumeavailable'
|
||||
attribute :snapshot_limit, :aliases => 'snapshotlimit'
|
||||
attribute :snapshot_total, :aliases => 'snapshottotal', :type => :integer
|
||||
attribute :snapshot_available, :aliases => 'snapshotavailable'
|
||||
attribute :template_limit, :aliases => 'templatelimit'
|
||||
attribute :template_total, :aliases => 'templatetotal', :type => :integer
|
||||
attribute :template_available, :aliases => 'templateavailable'
|
||||
|
||||
def save
|
||||
raise Fog::Errors::Error.new('Creating a project is not supported')
|
||||
end
|
||||
|
||||
def destroy
|
||||
raise Fog::Errors::Error.new('Destroying a project is not supported')
|
||||
end
|
||||
|
||||
end # Project
|
||||
end # Cloudstack
|
||||
end # Compute
|
||||
end # Fog
|
39
lib/fog/cloudstack/models/compute/projects.rb
Normal file
39
lib/fog/cloudstack/models/compute/projects.rb
Normal file
|
@ -0,0 +1,39 @@
|
|||
require 'fog/core/collection'
|
||||
require 'fog/cloudstack/models/compute/project'
|
||||
|
||||
module Fog
|
||||
module Compute
|
||||
class Cloudstack
|
||||
class Projects < Fog::Collection
|
||||
model Fog::Compute::Cloudstack::Project
|
||||
|
||||
def all(filters={})
|
||||
options = get_filter_options(filters)
|
||||
|
||||
data = service.list_projects(options)["listprojectsresponse"]["project"] || []
|
||||
load(data)
|
||||
end
|
||||
|
||||
def get(project_id, filters={})
|
||||
filter_option = get_filter_options(filters)
|
||||
options = filter_option.merge('id' => project_id)
|
||||
|
||||
if template = service.list_projects(options)["listprojectsresponse"]["project"].first
|
||||
new(template)
|
||||
end
|
||||
rescue Fog::Compute::Cloudstack::BadRequest
|
||||
nil
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def get_filter_options(filters)
|
||||
default_filter = {
|
||||
'projectfilter' => 'self'
|
||||
}
|
||||
default_filter.merge(filters)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
53
lib/fog/cloudstack/models/compute/public_ip_address.rb
Normal file
53
lib/fog/cloudstack/models/compute/public_ip_address.rb
Normal file
|
@ -0,0 +1,53 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Cloudstack
|
||||
class PublicIpAddress < Fog::Model
|
||||
identity :id, :aliases => 'id'
|
||||
attribute :network_id, :aliases => 'networkid'
|
||||
attribute :associated_network_id, :aliases => 'associatednetworkid'
|
||||
attribute :physical_network_id, :aliases => 'physicalnetworkid'
|
||||
attribute :ip_address, :aliases => 'ipaddress'
|
||||
attribute :mac_address, :aliases => 'macaddress'
|
||||
attribute :state, :aliases => 'state'
|
||||
attribute :traffic_type, :aliases => 'traffictype'
|
||||
attribute :is_default, :aliases => 'isdefault', :type => :boolean
|
||||
attribute :is_source_nat, :aliases => 'issourcenat', :type => :boolean
|
||||
attribute :is_static_nat, :aliases => 'isstaticnat', :type => :boolean
|
||||
attribute :is_system, :aliases => 'issytem', :type => :boolean
|
||||
attribute :is_portable, :aliases => 'isportable', :type => :boolean
|
||||
attribute :allocated, :aliases => 'allocated', :type => :time
|
||||
attribute :zone_id, :aliases => 'zone_id'
|
||||
attribute :domain_id, :aliases => 'domain_id'
|
||||
attribute :tags, :type => :array
|
||||
attribute :type
|
||||
|
||||
def save
|
||||
requires :display_text, :name
|
||||
|
||||
options = {
|
||||
'displaytext' => display_text,
|
||||
'name' => name,
|
||||
'customized' => is_customized,
|
||||
'disksize' => disk_size,
|
||||
'domain_id' => domain_id,
|
||||
'storagetype' => storage_type,
|
||||
'tags' => tags
|
||||
}
|
||||
|
||||
response = service.create_disk_offering(options)
|
||||
merge_attributes(response['creatediskofferingresponse'])
|
||||
end
|
||||
|
||||
def destroy
|
||||
requires :id
|
||||
|
||||
response = service.disassociate_ip_address('id' => id )
|
||||
success_status = response['deletediskofferingresponse']['success']
|
||||
|
||||
success_status == 'true'
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
25
lib/fog/cloudstack/models/compute/public_ip_addresses.rb
Normal file
25
lib/fog/cloudstack/models/compute/public_ip_addresses.rb
Normal file
|
@ -0,0 +1,25 @@
|
|||
require 'fog/core/collection'
|
||||
require 'fog/cloudstack/models/compute/address'
|
||||
|
||||
module Fog
|
||||
module Compute
|
||||
class Cloudstack
|
||||
class PublicIpAddresses < Fog::Collection
|
||||
model Fog::Compute::Cloudstack::PublicIpAddress
|
||||
|
||||
def all(options = {})
|
||||
response = service.list_public_ip_addresses(options)
|
||||
public_ip_addresses = response["listpublicipaddressesresponse"]["publicipaddress"] || []
|
||||
load(public_ip_addresses)
|
||||
end
|
||||
|
||||
def get(address_id)
|
||||
options = { 'id' => address_id }
|
||||
response = service.list_public_ip_addresses(options)
|
||||
public_ip_addresses = response["listpublicipaddressesresponse"]["publicipaddress"].first
|
||||
new(public_ip_addresses)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -8,7 +8,7 @@ module Fog
|
|||
attribute :name
|
||||
attribute :account_name, :aliases => 'account'
|
||||
attribute :domain_name, :aliases => 'domain'
|
||||
attribute :created
|
||||
attribute :created, :type => :time
|
||||
attribute :state
|
||||
attribute :haenable
|
||||
attribute :memory
|
||||
|
@ -38,6 +38,7 @@ module Fog
|
|||
attribute :user_data, :aliases => 'userdata'
|
||||
attribute :security_group_list, :type => :array, :aliases => 'securitygroup'
|
||||
attribute :nics, :type => :array, :aliases => 'nic'
|
||||
attribute :job_id, :aliases => 'jobid' # only on create
|
||||
|
||||
attr_accessor :network_ids, :disk_offering_id, :ip_address, :ip_to_network_list
|
||||
attr_writer :security_group_ids
|
||||
|
|
|
@ -8,6 +8,7 @@ module Fog
|
|||
model Fog::Compute::Cloudstack::Server
|
||||
|
||||
def all(attributes={})
|
||||
# add project id if we have one
|
||||
response = service.list_virtual_machines(attributes)
|
||||
data = response["listvirtualmachinesresponse"]["virtualmachine"] || []
|
||||
load(data)
|
||||
|
@ -20,7 +21,9 @@ module Fog
|
|||
end
|
||||
|
||||
def get(server_id)
|
||||
servers = service.list_virtual_machines('id' => server_id)["listvirtualmachinesresponse"]["virtualmachine"]
|
||||
attributes = {'id' => server_id}
|
||||
# add project id if we have one
|
||||
servers = service.list_virtual_machines(attributes)["listvirtualmachinesresponse"]["virtualmachine"]
|
||||
if servers.nil? || servers.empty?
|
||||
servers = service.list_virtual_machines('id' => server_id, 'projectid' => '-1')["listvirtualmachinesresponse"]["virtualmachine"]
|
||||
end
|
||||
|
|
|
@ -25,6 +25,7 @@ module Fog
|
|||
attribute :server_id, :aliases => 'virtualmachineid'
|
||||
attribute :server_name, :aliases => 'vmname'
|
||||
attribute :server_display_name, :aliases => 'vmdisplayname'
|
||||
attribute :job_id, :aliases => 'jobid' # only on create
|
||||
|
||||
attr_accessor :snapshot_id, :project_id
|
||||
|
||||
|
@ -39,6 +40,7 @@ module Fog
|
|||
'snapshotid' => snapshot_id,
|
||||
'projectid' => project_id
|
||||
}
|
||||
|
||||
data = service.create_volume(options)
|
||||
merge_attributes(data['createvolumeresponse'])
|
||||
end
|
||||
|
|
|
@ -31,6 +31,7 @@ module Fog
|
|||
data = service.create_zone(options)
|
||||
merge_attributes(data['createzoneresponse'])
|
||||
end
|
||||
|
||||
end # Zone
|
||||
end # Cloudstack
|
||||
end # Compute
|
||||
|
|
|
@ -14,6 +14,8 @@ module Fog
|
|||
else
|
||||
options.merge!('command' => 'associateIpAddress')
|
||||
end
|
||||
# add project id if we have one
|
||||
@cloudstack_project_id ? options.merge!('projectid' => @cloudstack_project_id) : nil
|
||||
request(options)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -18,6 +18,8 @@ module Fog
|
|||
'name' => args[2],
|
||||
'networkofferingid' => args[3])
|
||||
end
|
||||
# add project id if we have one
|
||||
@cloudstack_project_id ? options.merge!('projectid' => @cloudstack_project_id) : nil
|
||||
request(options)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -15,6 +15,8 @@ module Fog
|
|||
options.merge!('command' => 'createSSHKeyPair',
|
||||
'name' => args[0])
|
||||
end
|
||||
# add project id if we have one
|
||||
@cloudstack_project_id ? options.merge!('projectid' => @cloudstack_project_id) : nil
|
||||
request(options)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -15,6 +15,8 @@ module Fog
|
|||
options.merge!('command' => 'createVolume',
|
||||
'name' => args[0])
|
||||
end
|
||||
# add project id if we have one
|
||||
@cloudstack_project_id ? options.merge!('projectid' => @cloudstack_project_id) : nil
|
||||
request(options)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -15,6 +15,8 @@ module Fog
|
|||
options.merge!('command' => 'deleteSSHKeyPair',
|
||||
'name' => args[0])
|
||||
end
|
||||
# add project id if we have one
|
||||
@cloudstack_project_id ? options.merge!('projectid' => @cloudstack_project_id) : nil
|
||||
request(options)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -17,6 +17,8 @@ module Fog
|
|||
'zoneid' => args[1],
|
||||
'serviceofferingid' => args[2])
|
||||
end
|
||||
# add project id if we have one
|
||||
@cloudstack_project_id ? options.merge!('projectid' => @cloudstack_project_id) : nil
|
||||
request(options)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -14,6 +14,10 @@ module Fog
|
|||
else
|
||||
options.merge!('command' => 'listEgressFirewallRules')
|
||||
end
|
||||
|
||||
# add project id if we have one
|
||||
@cloudstack_project_id ? options.merge!('projectid' => @cloudstack_project_id) : nil
|
||||
|
||||
request(options)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -14,6 +14,10 @@ module Fog
|
|||
else
|
||||
options.merge!('command' => 'listFirewallRules')
|
||||
end
|
||||
|
||||
# add project id if we have one
|
||||
@cloudstack_project_id ? options.merge!('projectid' => @cloudstack_project_id) : nil
|
||||
|
||||
request(options)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -14,6 +14,10 @@ module Fog
|
|||
else
|
||||
options.merge!('command' => 'listNetworks')
|
||||
end
|
||||
|
||||
# add project id if we have one
|
||||
@cloudstack_project_id ? options.merge!('projectid' => @cloudstack_project_id) : nil
|
||||
|
||||
request(options)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -14,6 +14,10 @@ module Fog
|
|||
else
|
||||
options.merge!('command' => 'listPortForwardingRules')
|
||||
end
|
||||
|
||||
# add project id if we have one
|
||||
@cloudstack_project_id ? options.merge!('projectid' => @cloudstack_project_id) : nil
|
||||
|
||||
request(options)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -14,6 +14,10 @@ module Fog
|
|||
else
|
||||
options.merge!('command' => 'listPublicIpAddresses')
|
||||
end
|
||||
|
||||
# add project id if we have one
|
||||
@cloudstack_project_id ? options.merge!('projectid' => @cloudstack_project_id) : nil
|
||||
|
||||
request(options)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -14,6 +14,8 @@ module Fog
|
|||
else
|
||||
options.merge!('command' => 'listSnapshots')
|
||||
end
|
||||
# add project id if we have one
|
||||
@cloudstack_project_id ? options.merge!('projectid' => @cloudstack_project_id) : nil
|
||||
request(options)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -14,6 +14,8 @@ module Fog
|
|||
else
|
||||
options.merge!('command' => 'listSSHKeyPairs')
|
||||
end
|
||||
# add project id if we have one
|
||||
@cloudstack_project_id ? options.merge!('projectid' => @cloudstack_project_id) : nil
|
||||
request(options)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -15,6 +15,10 @@ module Fog
|
|||
options.merge!('command' => 'listTemplates',
|
||||
'templatefilter' => args[0])
|
||||
end
|
||||
|
||||
# add project id if we have one
|
||||
@cloudstack_project_id ? options.merge!('projectid' => @cloudstack_project_id) : nil
|
||||
|
||||
request(options)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -14,6 +14,8 @@ module Fog
|
|||
else
|
||||
options.merge!('command' => 'listVirtualMachines')
|
||||
end
|
||||
# add project id if we have one
|
||||
@cloudstack_project_id ? options.merge!('projectid' => @cloudstack_project_id) : nil
|
||||
request(options)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -14,6 +14,8 @@ module Fog
|
|||
else
|
||||
options.merge!('command' => 'listVMSnapshot')
|
||||
end
|
||||
# add project id if we have one
|
||||
@cloudstack_project_id ? options.merge!('projectid' => @cloudstack_project_id) : nil
|
||||
request(options)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -14,6 +14,8 @@ module Fog
|
|||
else
|
||||
options.merge!('command' => 'listVolumes')
|
||||
end
|
||||
# add project id if we have one
|
||||
@cloudstack_project_id ? options.merge!('projectid' => @cloudstack_project_id) : nil
|
||||
request(options)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -16,6 +16,8 @@ module Fog
|
|||
'name' => args[0],
|
||||
'publickey' => args[1])
|
||||
end
|
||||
# add project id if we have one
|
||||
@cloudstack_project_id ? options.merge!('projectid' => @cloudstack_project_id) : nil
|
||||
request(options)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -16,6 +16,8 @@ module Fog
|
|||
'id' => args[0],
|
||||
'keypair' => args[1])
|
||||
end
|
||||
# add project id if we have one
|
||||
@cloudstack_project_id ? options.merge!('projectid' => @cloudstack_project_id) : nil
|
||||
request(options)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -18,6 +18,8 @@ module Fog
|
|||
'zoneid' => args[2],
|
||||
'name' => args[3])
|
||||
end
|
||||
# add project id if we have one
|
||||
@cloudstack_project_id ? options.merge!('projectid' => @cloudstack_project_id) : nil
|
||||
request(options)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue