Class: Fog::Compute::Aliyun::Vswitch

Inherits:
Model
  • Object
show all
Defined in:
lib/fog/aliyun/models/compute/vswitch.rb

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Vswitch

Returns a new instance of Vswitch.



18
19
20
# File 'lib/fog/aliyun/models/compute/vswitch.rb', line 18

def initialize(attributes = {})
  super
end

Instance Method Details

#allObject



66
67
68
# File 'lib/fog/aliyun/models/compute/vswitch.rb', line 66

def all
  Fog::JSON.decode(service.list_vswitchs(vpc_id).body)['VSwitches']['VSwitch']
end

#destroyObject

Removes an existing vpc

vpc.destroy

Returns

True or false depending on the result



36
37
38
39
40
41
# File 'lib/fog/aliyun/models/compute/vswitch.rb', line 36

def destroy
  requires :id

  service.delete_vswitch(id)
  true
end

#ready?Boolean

Returns:

  • (Boolean)


22
23
24
25
# File 'lib/fog/aliyun/models/compute/vswitch.rb', line 22

def ready?
  requires :state
  state == 'Available'
end

#save(options = {}) ⇒ Object

Create a vpc

>> g = Aliyun.vpcs.new(:cidr_block => “10.1.2.0/24”) >> g.save

Returns:

True or an exception depending on the result. Keep in mind that this creates a new vpc. As such, it yields an InvalidGroup.Duplicate exception if you attempt to save an existing vpc.



54
55
56
57
58
59
60
# File 'lib/fog/aliyun/models/compute/vswitch.rb', line 54

def save(options = {})
  requires :vpc, :cidr_block
  options[:name] = name if name
  options[:description] = description if description
  Fog::JSON.decode(service.create_vswitch(vpc.id, cidr_block, options).body)
  true
end

#vpcObject



62
63
64
# File 'lib/fog/aliyun/models/compute/vswitch.rb', line 62

def vpc
  $vpc
end