Class: Fog::Compute::Aliyun::VPC

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

Instance Method Summary collapse

Instance Method Details

#destroyObject

Removes an existing vpc

vpc.destroy

Returns

True or false depending on the result



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

def destroy
  requires :id

  service.delete_vpc(id)
  true
end

#ready?Boolean

Returns:

  • (Boolean)


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

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.



69
70
71
72
73
74
75
# File 'lib/fog/aliyun/models/compute/vpc.rb', line 69

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

#security_groupsObject



54
55
56
57
# File 'lib/fog/aliyun/models/compute/vpc.rb', line 54

def security_groups
  requires :id
  Fog::Compute::Aliyun::SecurityGroups.new(service: service).all(vpcId: id)
end

#vrouterObject



49
50
51
52
# File 'lib/fog/aliyun/models/compute/vpc.rb', line 49

def vrouter
  requires :v_router_id
  Fog::Compute::Aliyun::Vrouters.new(service: service).all('vRouterId' => v_router_id)[0]
end

#vswitchesObject



40
41
42
43
44
45
46
47
# File 'lib/fog/aliyun/models/compute/vpc.rb', line 40

def vswitches
  @vswitches ||= begin
    Fog::Compute::Aliyun::Vswitches.new(
      vpc: self,
      service: service
    )
  end
end