wakame-vdc-agents 11.06.0 → 11.12.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +19 -31
- data/bin/hva +15 -5
- data/bin/nsa +15 -5
- data/bin/sta +9 -222
- data/config/db/migrations/0001_v1110_origin.rb +446 -0
- data/config/hva.conf.example +19 -11
- data/config/nsa.conf.example +1 -1
- data/lib/dcmgr.rb +99 -22
- data/lib/dcmgr/cli/base.rb +34 -1
- data/lib/dcmgr/cli/host.rb +24 -20
- data/lib/dcmgr/cli/image.rb +38 -19
- data/lib/dcmgr/cli/keypair.rb +16 -12
- data/lib/dcmgr/cli/network.rb +189 -81
- data/lib/dcmgr/cli/quota.rb +2 -2
- data/lib/dcmgr/cli/security_group.rb +106 -0
- data/lib/dcmgr/cli/spec.rb +144 -39
- data/lib/dcmgr/cli/storage.rb +16 -15
- data/lib/dcmgr/cli/tag.rb +20 -14
- data/lib/dcmgr/cli/vlan.rb +5 -5
- data/lib/dcmgr/drivers/backing_store.rb +32 -0
- data/lib/dcmgr/drivers/comstar.rb +81 -0
- data/lib/dcmgr/drivers/iijgio_storage.rb +9 -19
- data/lib/dcmgr/drivers/iscsi_target.rb +41 -0
- data/lib/dcmgr/drivers/kvm.rb +161 -28
- data/lib/dcmgr/drivers/linux_iscsi.rb +60 -0
- data/lib/dcmgr/drivers/local_storage.rb +24 -0
- data/lib/dcmgr/drivers/lxc.rb +167 -125
- data/lib/dcmgr/drivers/raw.rb +74 -0
- data/lib/dcmgr/drivers/s3_storage.rb +7 -19
- data/lib/dcmgr/drivers/snapshot_storage.rb +18 -28
- data/lib/dcmgr/drivers/storage_initiator.rb +28 -0
- data/lib/dcmgr/drivers/sun_iscsi.rb +32 -0
- data/lib/dcmgr/drivers/zfs.rb +77 -0
- data/lib/dcmgr/endpoints/core_api.rb +315 -263
- data/lib/dcmgr/endpoints/errors.rb +21 -10
- data/lib/dcmgr/endpoints/metadata.rb +360 -23
- data/lib/dcmgr/helpers/cli_helper.rb +6 -3
- data/lib/dcmgr/helpers/ec2_metadata_helper.rb +9 -0
- data/lib/dcmgr/helpers/nic_helper.rb +11 -0
- data/lib/dcmgr/helpers/snapshot_storage_helper.rb +34 -0
- data/lib/dcmgr/models/account.rb +0 -6
- data/lib/dcmgr/models/account_resource.rb +0 -4
- data/lib/dcmgr/models/base_new.rb +14 -2
- data/lib/dcmgr/models/dhcp_range.rb +38 -0
- data/lib/dcmgr/models/frontend_system.rb +0 -6
- data/lib/dcmgr/models/history.rb +0 -11
- data/lib/dcmgr/models/host_node.rb +131 -0
- data/lib/dcmgr/models/hostname_lease.rb +0 -8
- data/lib/dcmgr/models/image.rb +31 -18
- data/lib/dcmgr/models/instance.rb +137 -143
- data/lib/dcmgr/models/instance_nic.rb +52 -29
- data/lib/dcmgr/models/instance_security_group.rb +9 -0
- data/lib/dcmgr/models/instance_spec.rb +163 -31
- data/lib/dcmgr/models/ip_lease.rb +10 -21
- data/lib/dcmgr/models/mac_lease.rb +30 -11
- data/lib/dcmgr/models/network.rb +148 -27
- data/lib/dcmgr/models/physical_network.rb +18 -0
- data/lib/dcmgr/models/quota.rb +0 -10
- data/lib/dcmgr/models/request_log.rb +3 -18
- data/lib/dcmgr/models/security_group.rb +66 -0
- data/lib/dcmgr/models/security_group_rule.rb +145 -0
- data/lib/dcmgr/models/ssh_key_pair.rb +16 -19
- data/lib/dcmgr/models/{storage_pool.rb → storage_node.rb} +35 -25
- data/lib/dcmgr/models/tag.rb +0 -14
- data/lib/dcmgr/models/tag_mapping.rb +1 -7
- data/lib/dcmgr/models/vlan_lease.rb +2 -8
- data/lib/dcmgr/models/volume.rb +49 -37
- data/lib/dcmgr/models/volume_snapshot.rb +15 -17
- data/lib/dcmgr/node_modules/hva_collector.rb +69 -28
- data/lib/dcmgr/node_modules/instance_ha.rb +23 -12
- data/lib/dcmgr/node_modules/instance_monitor.rb +16 -2
- data/lib/dcmgr/node_modules/openflow_controller.rb +784 -0
- data/lib/dcmgr/node_modules/scheduler.rb +189 -0
- data/lib/dcmgr/node_modules/service_netfilter.rb +452 -227
- data/lib/dcmgr/node_modules/service_openflow.rb +731 -0
- data/lib/dcmgr/node_modules/sta_collector.rb +20 -0
- data/lib/dcmgr/node_modules/sta_tgt_initializer.rb +35 -0
- data/lib/dcmgr/rack/request_logger.rb +11 -6
- data/lib/dcmgr/rpc/hva_handler.rb +256 -110
- data/lib/dcmgr/rpc/sta_handler.rb +244 -0
- data/lib/dcmgr/scheduler.rb +122 -8
- data/lib/dcmgr/scheduler/host_node/exclude_same.rb +24 -0
- data/lib/dcmgr/scheduler/host_node/find_first.rb +12 -0
- data/lib/dcmgr/scheduler/host_node/least_usage.rb +28 -0
- data/lib/dcmgr/scheduler/host_node/per_instance.rb +18 -0
- data/lib/dcmgr/scheduler/host_node/specify_node.rb +26 -0
- data/lib/dcmgr/scheduler/network/flat_single.rb +23 -0
- data/lib/dcmgr/scheduler/network/nat_one_to_one.rb +23 -0
- data/lib/dcmgr/scheduler/network/per_instance.rb +39 -0
- data/lib/dcmgr/scheduler/network/vif_template.rb +19 -0
- data/lib/dcmgr/scheduler/storage_node/find_first.rb +13 -0
- data/lib/dcmgr/scheduler/storage_node/least_usage.rb +23 -0
- data/lib/dcmgr/storage_service.rb +39 -40
- data/lib/dcmgr/tags.rb +3 -3
- data/lib/dcmgr/version.rb +1 -1
- data/lib/dcmgr/vnet.rb +105 -0
- data/lib/dcmgr/vnet/factories.rb +141 -0
- data/lib/dcmgr/vnet/isolators/by_securitygroup.rb +21 -0
- data/lib/dcmgr/vnet/isolators/dummy.rb +17 -0
- data/lib/dcmgr/vnet/netfilter/cache.rb +51 -0
- data/lib/dcmgr/vnet/netfilter/chain.rb +66 -0
- data/lib/dcmgr/vnet/netfilter/controller.rb +193 -0
- data/lib/dcmgr/vnet/netfilter/ebtables_rule.rb +53 -0
- data/lib/dcmgr/vnet/netfilter/iptables_rule.rb +45 -0
- data/lib/dcmgr/vnet/netfilter/task_manager.rb +459 -0
- data/lib/dcmgr/vnet/tasks/accept_all_dns.rb +19 -0
- data/lib/dcmgr/vnet/tasks/accept_arp_broadcast.rb +24 -0
- data/lib/dcmgr/vnet/tasks/accept_arp_from_friends.rb +34 -0
- data/lib/dcmgr/vnet/tasks/accept_arp_from_gateway.rb +21 -0
- data/lib/dcmgr/vnet/tasks/accept_arp_to_host.rb +30 -0
- data/lib/dcmgr/vnet/tasks/accept_ip_from_friends.rb +26 -0
- data/lib/dcmgr/vnet/tasks/accept_ip_from_gateway.rb +23 -0
- data/lib/dcmgr/vnet/tasks/accept_ip_to_anywhere.rb +18 -0
- data/lib/dcmgr/vnet/tasks/accept_related_established.rb +45 -0
- data/lib/dcmgr/vnet/tasks/accept_wakame_dhcp_only.rb +33 -0
- data/lib/dcmgr/vnet/tasks/accept_wakame_dns_only.rb +33 -0
- data/lib/dcmgr/vnet/tasks/debug_iptables.rb +21 -0
- data/lib/dcmgr/vnet/tasks/drop_arp_forwarding.rb +27 -0
- data/lib/dcmgr/vnet/tasks/drop_arp_to_host.rb +24 -0
- data/lib/dcmgr/vnet/tasks/drop_ip_from_anywhere.rb +18 -0
- data/lib/dcmgr/vnet/tasks/drop_ip_spoofing.rb +34 -0
- data/lib/dcmgr/vnet/tasks/drop_mac_spoofing.rb +33 -0
- data/lib/dcmgr/vnet/tasks/exclude_from_nat.rb +47 -0
- data/lib/dcmgr/vnet/tasks/security_group.rb +37 -0
- data/lib/dcmgr/vnet/tasks/static_nat.rb +54 -0
- data/lib/dcmgr/vnet/tasks/translate_metadata_address.rb +32 -0
- metadata +105 -68
- data/lib/dcmgr/cli/group.rb +0 -101
- data/lib/dcmgr/endpoints/core_api_mock.rb +0 -865
- data/lib/dcmgr/models/host_pool.rb +0 -122
- data/lib/dcmgr/models/instance_netfilter_group.rb +0 -16
- data/lib/dcmgr/models/netfilter_group.rb +0 -89
- data/lib/dcmgr/models/netfilter_rule.rb +0 -21
- data/lib/dcmgr/scheduler/find_last.rb +0 -16
- data/lib/dcmgr/scheduler/find_random.rb +0 -16
- data/lib/dcmgr/stm/instance.rb +0 -25
- data/lib/dcmgr/stm/snapshot_context.rb +0 -33
- data/lib/dcmgr/stm/volume_context.rb +0 -65
data/config/hva.conf.example
CHANGED
@@ -5,21 +5,20 @@
|
|
5
5
|
# directory to store VM local data.
|
6
6
|
config.vm_data_dir = "/home/demo/vm"
|
7
7
|
|
8
|
-
# netfilter
|
8
|
+
# Decides what kind of edge networking will be used. If omitted, the default 'netfilter' option will be used
|
9
|
+
# * 'netfilter'
|
10
|
+
# * 'legacy_netfilter' #no longer supported, has issues with multiple vnic vm isolation
|
11
|
+
# * 'openflow' #experimental, requires additional setup
|
12
|
+
# * 'off'
|
13
|
+
config.edge_networking = 'netfilter'
|
14
|
+
|
15
|
+
# netfilter and openflow
|
9
16
|
config.enable_ebtables = true
|
10
17
|
config.enable_iptables = true
|
11
18
|
|
12
|
-
#
|
13
|
-
config.hv_ifindex = 2 # ex. /sys/class/net/eth0/ifindex => 2
|
14
|
-
|
15
|
-
# bridge device name prefix
|
16
|
-
config.bridge_prefix = 'br'
|
17
|
-
|
18
|
-
# bridge device name novlan
|
19
|
-
config.bridge_novlan = 'br0'
|
20
|
-
|
21
|
-
# display netfitler commands
|
19
|
+
# display netfilter and openflow commands
|
22
20
|
config.verbose_netfilter = false
|
21
|
+
config.verbose_openflow = false
|
23
22
|
|
24
23
|
# netfilter log output flag
|
25
24
|
config.packet_drop_log = false
|
@@ -29,3 +28,12 @@ config.debug_iptables = false
|
|
29
28
|
|
30
29
|
# Use ipset for netfilter
|
31
30
|
config.use_ipset = false
|
31
|
+
|
32
|
+
# Directory used by Open vSwitch daemon for run files
|
33
|
+
config.ovs_run_dir = '/usr/var/run/openvswitch'
|
34
|
+
|
35
|
+
# Path for ovs-ofctl
|
36
|
+
config.ovs_ofctl_path = '/usr/bin/ovs-ofctl'
|
37
|
+
|
38
|
+
# Trema base directory
|
39
|
+
config.trema_dir = '/home/demo/trema'
|
data/config/nsa.conf.example
CHANGED
data/lib/dcmgr.rb
CHANGED
@@ -82,15 +82,6 @@ module Dcmgr
|
|
82
82
|
class UUIDPrefixDuplication < StandardError; end
|
83
83
|
autoload :Base, 'dcmgr/models/base'
|
84
84
|
|
85
|
-
CREATE_TABLE_CLASSES=[:Account,:Tag,:TagMapping,:FrontendSystem,
|
86
|
-
:Image,:HostPool,:RequestLog,:Instance,
|
87
|
-
:NetfilterGroup, :NetfilterRule,
|
88
|
-
:StoragePool,:Volume,:VolumeSnapshot,
|
89
|
-
:InstanceNetfilterGroup,
|
90
|
-
:InstanceSpec, :InstanceNic, :Network, :IpLease,
|
91
|
-
:SshKeyPair, :History, :HostnameLease, :MacLease,
|
92
|
-
:VlanLease, :Quota
|
93
|
-
].freeze
|
94
85
|
autoload :BaseNew, 'dcmgr/models/base_new'
|
95
86
|
autoload :Account, 'dcmgr/models/account'
|
96
87
|
autoload :Tag, 'dcmgr/models/tag'
|
@@ -98,49 +89,50 @@ module Dcmgr
|
|
98
89
|
autoload :AccountResource, 'dcmgr/models/account_resource'
|
99
90
|
autoload :Instance, 'dcmgr/models/instance'
|
100
91
|
autoload :Image, 'dcmgr/models/image'
|
101
|
-
autoload :
|
92
|
+
autoload :HostNode, 'dcmgr/models/host_node'
|
102
93
|
autoload :RequestLog, 'dcmgr/models/request_log'
|
103
94
|
autoload :FrontendSystem, 'dcmgr/models/frontend_system'
|
104
|
-
autoload :
|
95
|
+
autoload :StorageNode, 'dcmgr/models/storage_node'
|
105
96
|
autoload :Volume, 'dcmgr/models/volume'
|
106
97
|
autoload :VolumeSnapshot, 'dcmgr/models/volume_snapshot'
|
107
|
-
autoload :
|
108
|
-
autoload :
|
98
|
+
autoload :SecurityGroup, 'dcmgr/models/security_group'
|
99
|
+
autoload :SecurityGroupRule, 'dcmgr/models/security_group_rule'
|
109
100
|
autoload :InstanceSpec, 'dcmgr/models/instance_spec'
|
110
101
|
autoload :InstanceNic, 'dcmgr/models/instance_nic'
|
111
102
|
autoload :Network, 'dcmgr/models/network'
|
112
103
|
autoload :IpLease, 'dcmgr/models/ip_lease'
|
113
|
-
autoload :
|
104
|
+
autoload :InstanceSecurityGroup, 'dcmgr/models/instance_security_group'
|
114
105
|
autoload :SshKeyPair, 'dcmgr/models/ssh_key_pair'
|
115
106
|
autoload :History, 'dcmgr/models/history'
|
116
107
|
autoload :HostnameLease, 'dcmgr/models/hostname_lease'
|
117
108
|
autoload :MacLease, 'dcmgr/models/mac_lease'
|
118
109
|
autoload :VlanLease, 'dcmgr/models/vlan_lease'
|
119
110
|
autoload :Quota, 'dcmgr/models/quota'
|
111
|
+
autoload :DhcpRange, 'dcmgr/models/dhcp_range'
|
112
|
+
autoload :PhysicalNetwork, 'dcmgr/models/physical_network'
|
120
113
|
end
|
121
114
|
|
122
115
|
module Endpoints
|
123
116
|
autoload :CoreAPI, 'dcmgr/endpoints/core_api'
|
124
|
-
autoload :
|
117
|
+
autoload :Ec2Metadata, 'dcmgr/endpoints/metadata'
|
125
118
|
end
|
126
119
|
|
127
120
|
module NodeModules
|
128
121
|
autoload :StaCollector, 'dcmgr/node_modules/sta_collector'
|
122
|
+
autoload :StaTgtInitializer, 'dcmgr/node_modules/sta_tgt_initializer'
|
129
123
|
autoload :HvaCollector, 'dcmgr/node_modules/hva_collector'
|
130
124
|
autoload :InstanceHA, 'dcmgr/node_modules/instance_ha'
|
125
|
+
autoload :OpenFlowController, 'dcmgr/node_modules/openflow_controller'
|
131
126
|
autoload :ServiceNetfilter, 'dcmgr/node_modules/service_netfilter'
|
127
|
+
autoload :ServiceOpenFlow, 'dcmgr/node_modules/service_openflow'
|
132
128
|
autoload :InstanceMonitor, 'dcmgr/node_modules/instance_monitor'
|
133
|
-
|
134
|
-
|
135
|
-
module Stm
|
136
|
-
autoload :VolumeContext, 'dcmgr/stm/volume_context'
|
137
|
-
autoload :SnapshotContext, 'dcmgr/stm/snapshot_context'
|
138
|
-
autoload :Instance, 'dcmgr/stm/instance'
|
129
|
+
autoload :Scheduler, 'dcmgr/node_modules/scheduler'
|
139
130
|
end
|
140
131
|
|
141
132
|
module Helpers
|
142
133
|
autoload :CliHelper, 'dcmgr/helpers/cli_helper'
|
143
134
|
autoload :NicHelper, 'dcmgr/helpers/nic_helper'
|
135
|
+
autoload :SnapshotStorageHelper, 'dcmgr/helpers/snapshot_storage_helper'
|
144
136
|
end
|
145
137
|
|
146
138
|
autoload :Tags, 'dcmgr/tags'
|
@@ -157,7 +149,7 @@ module Dcmgr
|
|
157
149
|
autoload :Vlan, 'dcmgr/cli/vlan'
|
158
150
|
autoload :Image, 'dcmgr/cli/image'
|
159
151
|
autoload :KeyPair, 'dcmgr/cli/keypair'
|
160
|
-
autoload :
|
152
|
+
autoload :SecurityGroup, 'dcmgr/cli/security_group'
|
161
153
|
autoload :Spec, 'dcmgr/cli/spec'
|
162
154
|
autoload :Tag, 'dcmgr/cli/tag'
|
163
155
|
autoload :Quota, 'dcmgr/cli/quota'
|
@@ -165,6 +157,7 @@ module Dcmgr
|
|
165
157
|
|
166
158
|
module Rpc
|
167
159
|
autoload :HvaHandler, 'dcmgr/rpc/hva_handler'
|
160
|
+
autoload :StaHandler, 'dcmgr/rpc/sta_handler'
|
168
161
|
autoload :KvmHelper, 'dcmgr/rpc/hva_handler'
|
169
162
|
end
|
170
163
|
|
@@ -176,12 +169,96 @@ module Dcmgr
|
|
176
169
|
|
177
170
|
module Drivers
|
178
171
|
autoload :SnapshotStorage, 'dcmgr/drivers/snapshot_storage'
|
172
|
+
autoload :LocalStorage, 'dcmgr/drivers/local_storage'
|
179
173
|
autoload :S3Storage, 'dcmgr/drivers/s3_storage'
|
180
174
|
autoload :IIJGIOStorage, 'dcmgr/drivers/iijgio_storage'
|
181
175
|
autoload :Hypervisor, 'dcmgr/drivers/hypervisor'
|
182
176
|
autoload :Kvm , 'dcmgr/drivers/kvm'
|
183
177
|
autoload :Lxc , 'dcmgr/drivers/lxc'
|
178
|
+
autoload :BackingStore, 'dcmgr/drivers/backing_store'
|
179
|
+
autoload :Zfs, 'dcmgr/drivers/zfs'
|
180
|
+
autoload :Raw, 'dcmgr/drivers/raw'
|
181
|
+
autoload :IscsiTarget, 'dcmgr/drivers/iscsi_target'
|
182
|
+
autoload :SunIscsi, 'dcmgr/drivers/sun_iscsi'
|
183
|
+
autoload :LinuxIscsi, 'dcmgr/drivers/linux_iscsi'
|
184
|
+
autoload :Comstar, 'dcmgr/drivers/comstar'
|
184
185
|
end
|
185
186
|
|
186
187
|
autoload :StorageService, 'dcmgr/storage_service'
|
188
|
+
|
189
|
+
require 'dcmgr/scheduler'
|
190
|
+
module Scheduler
|
191
|
+
module StorageNode
|
192
|
+
autoload :FindFirst, 'dcmgr/scheduler/storage_node/find_first'
|
193
|
+
autoload :LeastUsage, 'dcmgr/scheduler/storage_node/least_usage'
|
194
|
+
end
|
195
|
+
module HostNode
|
196
|
+
autoload :FindFirst, 'dcmgr/scheduler/host_node/find_first'
|
197
|
+
autoload :LeastUsage, 'dcmgr/scheduler/host_node/least_usage'
|
198
|
+
autoload :ExcludeSame, 'dcmgr/scheduler/host_node/exclude_same'
|
199
|
+
autoload :SpecifyNode, 'dcmgr/scheduler/host_node/specify_node'
|
200
|
+
end
|
201
|
+
module Network
|
202
|
+
autoload :FlatSingle, 'dcmgr/scheduler/network/flat_single'
|
203
|
+
autoload :NatOneToOne, 'dcmgr/scheduler/network/nat_one_to_one'
|
204
|
+
autoload :VifTemplate, 'dcmgr/scheduler/network/vif_template'
|
205
|
+
autoload :PerInstance, 'dcmgr/scheduler/network/per_instance'
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
require 'dcmgr/vnet'
|
210
|
+
module VNet
|
211
|
+
autoload :ControllerFactory, 'dcmgr/vnet/factories'
|
212
|
+
autoload :IsolatorFactory, 'dcmgr/vnet/factories'
|
213
|
+
autoload :TaskFactory, 'dcmgr/vnet/factories'
|
214
|
+
autoload :TaskManagerFactory, 'dcmgr/vnet/factories'
|
215
|
+
|
216
|
+
module Netfilter
|
217
|
+
autoload :NetfilterCache, 'dcmgr/vnet/netfilter/cache'
|
218
|
+
autoload :NetfilterController, 'dcmgr/vnet/netfilter/controller'
|
219
|
+
autoload :Chain, 'dcmgr/vnet/netfilter/chain'
|
220
|
+
autoload :IptablesChain, 'dcmgr/vnet/netfilter/chain'
|
221
|
+
autoload :EbtablesChain, 'dcmgr/vnet/netfilter/chain'
|
222
|
+
autoload :EbtablesRule, 'dcmgr/vnet/netfilter/ebtables_rule'
|
223
|
+
autoload :IptablesRule, 'dcmgr/vnet/netfilter/iptables_rule'
|
224
|
+
autoload :NetfilterTaskManager, 'dcmgr/vnet/netfilter/task_manager'
|
225
|
+
autoload :VNicProtocolTaskManager, 'dcmgr/vnet/netfilter/task_manager'
|
226
|
+
end
|
227
|
+
|
228
|
+
module Tasks
|
229
|
+
autoload :AcceptAllDNS, 'dcmgr/vnet/tasks/accept_all_dns'
|
230
|
+
autoload :AcceptArpBroadcast, 'dcmgr/vnet/tasks/accept_arp_broadcast'
|
231
|
+
autoload :AcceptARPFromFriends, 'dcmgr/vnet/tasks/accept_arp_from_friends'
|
232
|
+
autoload :AcceptARPFromGateway, 'dcmgr/vnet/tasks/accept_arp_from_gateway'
|
233
|
+
autoload :AcceptARPToHost, 'dcmgr/vnet/tasks/accept_arp_to_host'
|
234
|
+
autoload :AcceptIpFromFriends, 'dcmgr/vnet/tasks/accept_ip_from_friends'
|
235
|
+
autoload :AcceptIpFromGateway, 'dcmgr/vnet/tasks/accept_ip_from_gateway'
|
236
|
+
autoload :AcceptIpToAnywhere, 'dcmgr/vnet/tasks/accept_ip_to_anywhere'
|
237
|
+
autoload :AcceptRelatedEstablished, 'dcmgr/vnet/tasks/accept_related_established'
|
238
|
+
autoload :AcceptTcpRelatedEstablished, 'dcmgr/vnet/tasks/accept_related_established'
|
239
|
+
autoload :AcceptUdpEstablished, 'dcmgr/vnet/tasks/accept_related_established'
|
240
|
+
autoload :AcceptIcmpRelatedEstablished, 'dcmgr/vnet/tasks/accept_related_established'
|
241
|
+
autoload :AcceptWakameDHCPOnly, 'dcmgr/vnet/tasks/accept_wakame_dhcp_only'
|
242
|
+
autoload :AcceptWakameDNSOnly, 'dcmgr/vnet/tasks/accept_wakame_dns_only'
|
243
|
+
autoload :DebugIptables, 'dcmgr/vnet/tasks/debug_iptables'
|
244
|
+
autoload :DropArpForwarding, 'dcmgr/vnet/tasks/drop_arp_forwarding'
|
245
|
+
autoload :DropArpToHost, 'dcmgr/vnet/tasks/drop_arp_to_host'
|
246
|
+
autoload :DropIpFromAnywhere, 'dcmgr/vnet/tasks/drop_ip_from_anywhere'
|
247
|
+
autoload :DropIpSpoofing, 'dcmgr/vnet/tasks/drop_ip_spoofing'
|
248
|
+
autoload :DropMacSpoofing, 'dcmgr/vnet/tasks/drop_mac_spoofing'
|
249
|
+
autoload :ExcludeFromNat, 'dcmgr/vnet/tasks/exclude_from_nat'
|
250
|
+
autoload :ExcludeFromNatIpSet, 'dcmgr/vnet/tasks/exclude_from_nat'
|
251
|
+
autoload :SecurityGroup, 'dcmgr/vnet/tasks/security_group'
|
252
|
+
autoload :StaticNat, 'dcmgr/vnet/tasks/static_nat'
|
253
|
+
autoload :StaticNatLog, 'dcmgr/vnet/tasks/static_nat'
|
254
|
+
autoload :TranslateMetadataAddress, 'dcmgr/vnet/tasks/translate_metadata_address'
|
255
|
+
end
|
256
|
+
|
257
|
+
module Isolators
|
258
|
+
autoload :BySecurityGroup, 'dcmgr/vnet/isolators/by_securitygroup'
|
259
|
+
autoload :DummyIsolator, 'dcmgr/vnet/isolators/dummy'
|
260
|
+
end
|
261
|
+
|
262
|
+
end
|
263
|
+
|
187
264
|
end
|
data/lib/dcmgr/cli/base.rb
CHANGED
@@ -27,6 +27,40 @@ module Dcmgr::Cli
|
|
27
27
|
def after_task
|
28
28
|
end
|
29
29
|
}
|
30
|
+
|
31
|
+
no_tasks {
|
32
|
+
class MapperDSL
|
33
|
+
attr_reader :defs
|
34
|
+
|
35
|
+
def initialize()
|
36
|
+
@defs = {}
|
37
|
+
end
|
38
|
+
|
39
|
+
def option(key, map_key=nil, &blk)
|
40
|
+
map_key ||= key
|
41
|
+
@defs[key]=proc { |h,v| h[map_key]=blk.call(v) }
|
42
|
+
end
|
43
|
+
|
44
|
+
def map(key, map_key)
|
45
|
+
@defs[key]=proc { |h, v| h[map_key] = v}
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
public
|
50
|
+
def optmap(h, &blk)
|
51
|
+
ret = {}
|
52
|
+
d = MapperDSL.new
|
53
|
+
blk.call(d)
|
54
|
+
h.each { |k, v|
|
55
|
+
if d.defs.has_key?(k.to_sym)
|
56
|
+
d.defs[k.to_sym].call(ret, v)
|
57
|
+
else
|
58
|
+
ret[k.to_sym] = v
|
59
|
+
end
|
60
|
+
}
|
61
|
+
ret
|
62
|
+
end
|
63
|
+
}
|
30
64
|
|
31
65
|
def add(model,options)
|
32
66
|
raise ArgumentError unless options.is_a? Hash
|
@@ -67,7 +101,6 @@ module Dcmgr::Cli
|
|
67
101
|
fields_nonil.delete_if {|key,value| value.nil?}
|
68
102
|
|
69
103
|
to_modify.set(fields_nonil)
|
70
|
-
to_modify.updated_at = Time.now.utc.iso8601 if to_modify.with_timestamps?
|
71
104
|
to_modify.save_changes
|
72
105
|
end
|
73
106
|
end
|
data/lib/dcmgr/cli/host.rb
CHANGED
@@ -9,23 +9,25 @@ class Host < Base
|
|
9
9
|
include Dcmgr::Models
|
10
10
|
|
11
11
|
desc "add NODE_ID [options]", "Register a new host node"
|
12
|
-
method_option :uuid, :type => :string, :
|
13
|
-
|
14
|
-
method_option :
|
15
|
-
method_option :
|
16
|
-
method_option :
|
17
|
-
method_option :
|
18
|
-
method_option :
|
12
|
+
method_option :uuid, :type => :string, :desc => "The UUID for the new host node"
|
13
|
+
method_option :name, :type => :string, :size => 255, :desc => "The name for the new host node"
|
14
|
+
method_option :force, :type => :boolean, :default=>false, :desc => "Force new entry creation"
|
15
|
+
method_option :cpu_cores, :type => :numeric, :default=>1, :desc => "Number of cpu cores to be offered"
|
16
|
+
method_option :memory_size, :type => :numeric, :default=>1024, :desc => "Amount of memory to be offered (in MB)"
|
17
|
+
method_option :hypervisor, :type => :string, :default=>'kvm', :desc => "The hypervisor name. [#{HostNode::SUPPORTED_HYPERVISOR.join(', ')}]"
|
18
|
+
method_option :arch, :type => :string, :default=>'x86_64', :desc => "The CPU architecture type. [#{HostNode::SUPPORTED_ARCH.join(', ')}]"
|
19
|
+
method_option :account_id, :type => :string, :default=>'a-shpoolxx', :desc => "The account ID to own this"
|
19
20
|
def add(node_id)
|
20
21
|
UnknownUUIDError.raise(options[:account_id]) if Account[options[:account_id]].nil?
|
21
|
-
UnsupportedArchError.raise(options[:arch]) unless
|
22
|
-
UnsupportedHypervisorError.raise(options[:hypervisor]) unless
|
22
|
+
UnsupportedArchError.raise(options[:arch]) unless HostNode::SUPPORTED_ARCH.member?(options[:arch])
|
23
|
+
UnsupportedHypervisorError.raise(options[:hypervisor]) unless HostNode::SUPPORTED_HYPERVISOR.member?(options[:hypervisor])
|
23
24
|
|
24
|
-
|
25
|
+
unless (options[:force] || Isono::Models::NodeState.find(:node_id=>node_id))
|
25
26
|
abort("Node ID is not registered yet: #{node_id}")
|
26
27
|
end
|
27
28
|
|
28
29
|
fields = {
|
30
|
+
:name=>options[:name],
|
29
31
|
:node_id=>node_id,
|
30
32
|
:offering_cpu_cores=>options[:cpu_cores],
|
31
33
|
:offering_memory_size=>options[:memory_size],
|
@@ -34,35 +36,37 @@ class Host < Base
|
|
34
36
|
:account_id=>options[:account_id],
|
35
37
|
}
|
36
38
|
fields.merge!({:uuid => options[:uuid]}) unless options[:uuid].nil?
|
37
|
-
puts super(
|
39
|
+
puts super(HostNode,fields)
|
38
40
|
end
|
39
41
|
|
40
42
|
desc "modify UUID [options]", "Modify a registered host node"
|
41
|
-
method_option :
|
42
|
-
method_option :
|
43
|
-
method_option :
|
44
|
-
method_option :
|
43
|
+
method_option :name, :type => :string, :size => 255, :desc => "The name for the new host node"
|
44
|
+
method_option :cpu_cores, :type => :numeric, :desc => "Number of cpu cores to be offered"
|
45
|
+
method_option :account_id, :type => :string, :desc => "The account ID to own this"
|
46
|
+
method_option :memory_size, :type => :numeric, :desc => "Amount of memory to be offered (in MB)"
|
47
|
+
method_option :hypervisor, :type => :string, :desc => "The hypervisor name. [#{HostNode::SUPPORTED_HYPERVISOR.join(', ')}]"
|
45
48
|
def modify(uuid)
|
46
49
|
UnknownUUIDError.raise(options[:account_id]) if options[:account_id] && Account[options[:account_id]].nil?
|
47
|
-
UnsupportedHypervisorError.raise(options[:hypervisor]) unless options[:hypervisor].nil? ||
|
50
|
+
UnsupportedHypervisorError.raise(options[:hypervisor]) unless options[:hypervisor].nil? || HostNode::SUPPORTED_HYPERVISOR.member?(options[:hypervisor])
|
48
51
|
fields = {
|
52
|
+
:name=>options[:name],
|
49
53
|
:offering_memory_size=>options[:memory_size],
|
50
54
|
:offering_cpu_cores=>options[:cpu_cores],
|
51
55
|
:account_id=>options[:account_id],
|
52
56
|
:hypervisor=>options[:hypervisor]
|
53
57
|
}
|
54
|
-
super(
|
58
|
+
super(HostNode,uuid,fields)
|
55
59
|
end
|
56
60
|
|
57
61
|
desc "del UUID", "Deregister a host node"
|
58
62
|
def del(uuid)
|
59
|
-
super(
|
63
|
+
super(HostNode,uuid)
|
60
64
|
end
|
61
65
|
|
62
66
|
desc "show [UUID]", "Show list of host nodes and details"
|
63
67
|
def show(uuid=nil)
|
64
68
|
if uuid
|
65
|
-
host =
|
69
|
+
host = HostNode[uuid] || UnknownUUIDError.raise(uuid)
|
66
70
|
puts ERB.new(<<__END, nil, '-').result(binding)
|
67
71
|
Host UUID:
|
68
72
|
<%= host.canonical_uuid %>
|
@@ -77,7 +81,7 @@ Hypervisor:
|
|
77
81
|
__END
|
78
82
|
else
|
79
83
|
cond = {}
|
80
|
-
all =
|
84
|
+
all = HostNode.filter(cond).all
|
81
85
|
puts ERB.new(<<__END, nil, '-').result(binding)
|
82
86
|
<%- all.each { |row| -%>
|
83
87
|
<%= "%-15s %-20s %-10s" % [row.canonical_uuid, row.node_id, row.status] %>
|
data/lib/dcmgr/cli/image.rb
CHANGED
@@ -10,15 +10,16 @@ module Dcmgr::Cli
|
|
10
10
|
namespace :add
|
11
11
|
|
12
12
|
desc "local IMAGE_LOCATION [options]", "Register local store machine image"
|
13
|
-
method_option :uuid, :type => :string, :
|
14
|
-
method_option :account_id, :type => :string, :
|
15
|
-
method_option :arch, :type => :string, :default => 'x86_64', :
|
16
|
-
method_option :is_public, :type => :boolean, :
|
17
|
-
method_option :
|
18
|
-
method_option :
|
13
|
+
method_option :uuid, :type => :string, :desc => "The UUID for the new machine image"
|
14
|
+
method_option :account_id, :type => :string, :required => true, :desc => "The UUID of the account that this machine image belongs to"
|
15
|
+
method_option :arch, :type => :string, :default => 'x86_64', :desc => "The architecture for the new machine image. [#{M::HostNode::SUPPORTED_ARCH.join(', ')}]"
|
16
|
+
method_option :is_public, :type => :boolean, :default => false, :desc => "A flag that determines whether the new machine image is public or not"
|
17
|
+
method_option :md5sum, :type => :string, :required => true, :desc => "The md5 checksum of the image you are registering."
|
18
|
+
method_option :description, :type => :string, :desc => "An arbitrary description of the new machine image"
|
19
|
+
#method_option :state, :type => :string, :default => "init", :desc => "The state for the new machine image"
|
19
20
|
def local(location)
|
20
21
|
UnknownUUIDError.raise(options[:account_id]) if M::Account[options[:account_id]].nil?
|
21
|
-
UnsupportedArchError.raise(options[:arch]) unless M::
|
22
|
+
UnsupportedArchError.raise(options[:arch]) unless M::HostNode::SUPPORTED_ARCH.member?(options[:arch])
|
22
23
|
|
23
24
|
full_path = File.expand_path(location)
|
24
25
|
File.exists?(full_path) || Error.raise("File not found: #{full_path}",100)
|
@@ -33,15 +34,16 @@ module Dcmgr::Cli
|
|
33
34
|
end
|
34
35
|
|
35
36
|
desc "volume snapshot_id [options]", "Register volume store machine image."
|
36
|
-
method_option :uuid, :type => :string, :
|
37
|
-
method_option :account_id, :type => :string, :
|
38
|
-
method_option :arch, :type => :string, :default => 'x86_64', :
|
39
|
-
method_option :is_public, :type => :boolean, :
|
40
|
-
method_option :
|
41
|
-
method_option :
|
37
|
+
method_option :uuid, :type => :string, :desc => "The UUID for the new machine image."
|
38
|
+
method_option :account_id, :type => :string, :required => true, :desc => "The UUID of the account that this machine image belongs to."
|
39
|
+
method_option :arch, :type => :string, :default => 'x86_64', :desc => "The architecture for the new machine image. [#{M::HostNode::SUPPORTED_ARCH.join(', ')}]"
|
40
|
+
method_option :is_public, :type => :boolean, :default => false, :desc => "A flag that determines whether the new machine image is public or not."
|
41
|
+
method_option :md5sum, :type => :string, :required => true, :desc => "The md5 checksum of the image you are registering."
|
42
|
+
method_option :description, :type => :string, :desc => "An arbitrary description of the new machine image"
|
43
|
+
#method_option :state, :type => :string, :default => "init", :desc => "The state for the new machine image"
|
42
44
|
def volume(snapshot_id)
|
43
45
|
UnknownUUIDError.raise(options[:account_id]) if M::Account[options[:account_id]].nil?
|
44
|
-
UnsupportedArchError.raise(options[:arch]) unless M::
|
46
|
+
UnsupportedArchError.raise(options[:arch]) unless M::HostNode::SUPPORTED_ARCH.member?(options[:arch])
|
45
47
|
UnknownUUIDError.raise(snapshot_id) if M::VolumeSnapshot[snapshot_id].nil?
|
46
48
|
#TODO: Check if :state is a valid state
|
47
49
|
fields = options.dup
|
@@ -61,8 +63,8 @@ module Dcmgr::Cli
|
|
61
63
|
register AddOperation, 'add', "add IMAGE_TYPE [options]", "Add image metadata [#{AddOperation.tasks.keys.join(', ')}]"
|
62
64
|
|
63
65
|
desc "modify UUID [options]", "Modify a registered machine image"
|
64
|
-
method_option :description, :type => :string, :
|
65
|
-
method_option :state, :type => :string, :
|
66
|
+
method_option :description, :type => :string, :desc => "An arbitrary description of the machine image"
|
67
|
+
method_option :state, :type => :string, :default => "init", :desc => "The state for the machine image"
|
66
68
|
def modify(uuid)
|
67
69
|
#TODO: Check if state is valid here too
|
68
70
|
super(M::Image,uuid,options)
|
@@ -77,15 +79,17 @@ module Dcmgr::Cli
|
|
77
79
|
desc "show [IMAGE_ID]", "Show list of machine image and details"
|
78
80
|
def show(uuid=nil)
|
79
81
|
if uuid
|
80
|
-
img = M::Image[uuid]
|
82
|
+
img = M::Image[uuid] || UnknownUUIDError.raise(uuid)
|
81
83
|
print ERB.new(<<__END, nil, '-').result(binding)
|
82
84
|
UUID:
|
83
85
|
<%= img.canonical_uuid %>
|
84
86
|
Boot Type:
|
85
|
-
<%= img.boot_dev_type %>
|
87
|
+
<%= img.boot_dev_type == M::Image::BOOT_DEV_LOCAL ? 'local' : 'volume'%>
|
86
88
|
Arch:
|
87
89
|
<%= img.arch %>
|
88
90
|
<%- if img.description -%>
|
91
|
+
MD5 Sum:
|
92
|
+
<%= img.md5sum %>
|
89
93
|
Description:
|
90
94
|
<%= img.description %>
|
91
95
|
<%- end -%>
|
@@ -93,16 +97,31 @@ Is Public:
|
|
93
97
|
<%= img.is_public %>
|
94
98
|
State:
|
95
99
|
<%= img.state %>
|
100
|
+
Features:
|
101
|
+
<%= img.features %>
|
96
102
|
__END
|
97
103
|
else
|
98
104
|
cond = {}
|
99
105
|
imgs = M::Image.filter(cond).all
|
100
106
|
print ERB.new(<<__END, nil, '-').result(binding)
|
101
107
|
<%- imgs.each { |row| -%>
|
102
|
-
<%=
|
108
|
+
<%= row.canonical_uuid %>\t<%= row.boot_dev_type == M::Image::BOOT_DEV_LOCAL ? 'local' : 'volume'%>\t<%= row.arch %>
|
103
109
|
<%- } -%>
|
104
110
|
__END
|
105
111
|
end
|
106
112
|
end
|
113
|
+
|
114
|
+
desc "features IMAGE_ID", "Set features attribute to the image"
|
115
|
+
method_option :virtio, :type => :boolean, :desc => "Virtio ready image."
|
116
|
+
def features(uuid)
|
117
|
+
img = M::Image[uuid]
|
118
|
+
UnknownUUIDError.raise(uuid) if img.nil?
|
119
|
+
|
120
|
+
if options[:virtio]
|
121
|
+
img.set_feature(:virtio, options[:virtio])
|
122
|
+
end
|
123
|
+
img.save_changes
|
124
|
+
end
|
125
|
+
|
107
126
|
end
|
108
127
|
end
|