Class: Fog::Compute::QingCloud::Vxnets

Inherits:
Fog::Collection
  • Object
show all
Defined in:
lib/fog/qingcloud/models/compute/vxnets.rb

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ Vxnets

Creates a new vxnet

QingCloud.vxnets.new



18
19
20
21
# File 'lib/fog/qingcloud/models/compute/vxnets.rb', line 18

def initialize(attributes)
  self.filters ||= {}
  super
end

Instance Method Details

#all(filters = filters) ⇒ Object

Returns an array of all Vxnets that have been created

QingCloud.vxnets.all

Returns

Returns an array of all VPCs

>> QingCloud.vxnets.all <Fog::QingCloud::Compute::Vxnet filters={} [ vxnet_id=vxnet-someId, status=, vpc_id=vpc-someId cidr_block=someIpRange available_ip_address_count=someInt tagset=nil ] >



45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/fog/qingcloud/models/compute/vxnets.rb', line 45

def all(filters = filters)
  unless filters.is_a?(Hash)
    Fog::Logger.warning("all with #{filters.class} param is deprecated, use all('vxnet-id' => []) instead [light_black](#{caller.first})[/]")
    filters = {'vxnet-id' => [*filters]}
  end
  self.filters = filters
  data = service.describe_vxnets(filters).body
  load(data['vxnet_set'].map do |vxnet|
      rt = vxnet.delete('router')
      vxnet['router_id'] = rt['router_id'] if rt
      vxnet
    end
  )
end

#get(vxnet_id) ⇒ Object

Used to retrieve a Vxnet vxnet-id is required to get the associated VPC information.

You can run the following command to get the details: QingCloud.vxnets.get(“vxnet-12345678”)

Returns

>> QingCloud.vxnets.get(“vxnet-12345678”) <Fog::QingCloud::Compute::Vxnet vxnet_id=vxnet-someId, status=, vpc_id=vpc-someId cidr_block=someIpRange available_ip_address_count=someInt tagset=nil >



79
80
81
82
83
# File 'lib/fog/qingcloud/models/compute/vxnets.rb', line 79

def get(vxnet_id)
  if vxnet_id
    self.class.new(:service => service).all('vxnet-id' => vxnet_id).first
  end
end