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.



16
17
18
# File 'lib/fog/aliyun/models/compute/vswitch.rb', line 16

def initialize(attributes = {})
  super
end

Instance Method Details

#allObject



64
65
66
# File 'lib/fog/aliyun/models/compute/vswitch.rb', line 64

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



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

def destroy
  requires :id

  service.delete_vswitch(id)
  true
end

#ready?Boolean

Returns:

  • (Boolean)


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

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.



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

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



60
61
62
# File 'lib/fog/aliyun/models/compute/vswitch.rb', line 60

def vpc
  $vpc
end