Class: Fog::Compute::QingCloud::Vxnet
- Inherits:
-
QingCloud::Model
- Object
- Model
- QingCloud::Model
- Fog::Compute::QingCloud::Vxnet
- Defined in:
- lib/fog/qingcloud/models/compute/vxnet.rb
Instance Method Summary collapse
-
#destroy ⇒ Object
Removes an existing vxnet.
- #join_router(router, cidr_block = '192.168.1.0/24', features = 1) ⇒ Object
- #leave_router ⇒ Object
-
#network_attrs ⇒ Object
The following attributes are available if the vxnet is connected to a router.
- #router ⇒ Object
-
#save ⇒ Object
Create a vxnet.
- #servers ⇒ Object
Methods inherited from QingCloud::Model
#changing?, inherited, #wait_for
Instance Method Details
#destroy ⇒ Object
Removes an existing vxnet
vxnet.destroy
Returns
True or false depending on the result
27 28 29 30 31 32 33 34 |
# File 'lib/fog/qingcloud/models/compute/vxnet.rb', line 27 def destroy requires :id service.delete_vxnets(id) true rescue Fog::QingCloud::Errors::PermissionDenied => e raise e unless e. =~ /has already been deleted/i true end |
#join_router(router, cidr_block = '192.168.1.0/24', features = 1) ⇒ Object
54 55 56 57 58 59 |
# File 'lib/fog/qingcloud/models/compute/vxnet.rb', line 54 def join_router(router, cidr_block = '192.168.1.0/24', features = 1) requires :id router = router.id if router.respond_to? :id service.join_router(router, id, cidr_block, features) true end |
#leave_router ⇒ Object
61 62 63 64 65 |
# File 'lib/fog/qingcloud/models/compute/vxnet.rb', line 61 def leave_router requires :id, :router_id service.leave_router(router_id, id) true end |
#network_attrs ⇒ Object
The following attributes are available if the vxnet is connected to a router.
ip_network
manager_ip
features
dyn_ip_start
dyn_ip_end
create_time
86 87 88 89 90 |
# File 'lib/fog/qingcloud/models/compute/vxnet.rb', line 86 def network_attrs requires :id return OpenStruct.new unless router_id OpenStruct.new(service.describe_router_vxnets(router_id).body['router_vxnet_set'].find{ |x| x['vxnet_id'] == id }) end |
#router ⇒ Object
67 68 69 70 |
# File 'lib/fog/qingcloud/models/compute/vxnet.rb', line 67 def router requires :id, :router_id service.routers.get(router_id) end |
#save ⇒ Object
Create a vxnet
40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/fog/qingcloud/models/compute/vxnet.rb', line 40 def save if persisted? modify_attributes(name, description) else requires :type = {'vxnet_name' => name, 'count' => 1, 'vxnet_type' => type} self.id = service.create_vxnets().body['vxnets'].first reload end true end |
#servers ⇒ Object
72 73 74 75 76 77 |
# File 'lib/fog/qingcloud/models/compute/vxnet.rb', line 72 def servers requires :id vxnet_instances = service.describe_vxnet_instances(id).body['instance_set'] instance_ids = vxnet_instances.map { |i| i['instance_id'] } service.servers.all('instance-id' => instance_ids) end |