wakame-vdc-agents 10.12.0 → 11.06.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. data/LICENSE +164 -201
  2. data/Rakefile +6 -11
  3. data/bin/hva +11 -1351
  4. data/bin/nsa +5 -9
  5. data/bin/sta +124 -71
  6. data/config/hva.conf.example +12 -0
  7. data/config/initializers/isono.rb +7 -23
  8. data/config/initializers/sequel.rb +11 -2
  9. data/lib/dcmgr.rb +70 -11
  10. data/lib/dcmgr/cli/base.rb +74 -0
  11. data/lib/dcmgr/cli/errors.rb +59 -0
  12. data/lib/dcmgr/cli/group.rb +101 -0
  13. data/lib/dcmgr/cli/host.rb +101 -0
  14. data/lib/dcmgr/cli/image.rb +108 -0
  15. data/lib/dcmgr/cli/keypair.rb +72 -0
  16. data/lib/dcmgr/cli/network.rb +198 -0
  17. data/lib/dcmgr/cli/quota.rb +28 -0
  18. data/lib/dcmgr/cli/spec.rb +82 -0
  19. data/lib/dcmgr/cli/storage.rb +88 -0
  20. data/lib/dcmgr/cli/tag.rb +81 -0
  21. data/lib/dcmgr/cli/vlan.rb +53 -0
  22. data/lib/dcmgr/drivers/hypervisor.rb +33 -0
  23. data/lib/dcmgr/drivers/iijgio_storage.rb +37 -0
  24. data/lib/dcmgr/drivers/kvm.rb +118 -0
  25. data/lib/dcmgr/drivers/lxc.rb +167 -0
  26. data/lib/dcmgr/drivers/s3_storage.rb +39 -0
  27. data/lib/dcmgr/drivers/snapshot_storage.rb +51 -0
  28. data/lib/dcmgr/endpoints/core_api.rb +188 -324
  29. data/lib/dcmgr/endpoints/core_api_mock.rb +52 -3
  30. data/lib/dcmgr/endpoints/errors.rb +73 -32
  31. data/lib/dcmgr/endpoints/metadata.rb +163 -16
  32. data/lib/dcmgr/helpers/cli_helper.rb +1 -1
  33. data/lib/dcmgr/helpers/nic_helper.rb +35 -0
  34. data/lib/dcmgr/logger.rb +5 -1
  35. data/lib/dcmgr/messaging_client.rb +117 -0
  36. data/lib/dcmgr/models/account.rb +27 -3
  37. data/lib/dcmgr/models/base_new.rb +21 -7
  38. data/lib/dcmgr/models/host_pool.rb +27 -7
  39. data/lib/dcmgr/models/image.rb +31 -3
  40. data/lib/dcmgr/models/instance.rb +72 -23
  41. data/lib/dcmgr/models/instance_nic.rb +12 -2
  42. data/lib/dcmgr/models/instance_spec.rb +16 -0
  43. data/lib/dcmgr/models/ip_lease.rb +37 -1
  44. data/lib/dcmgr/models/netfilter_group.rb +7 -7
  45. data/lib/dcmgr/models/network.rb +42 -3
  46. data/lib/dcmgr/models/quota.rb +25 -0
  47. data/lib/dcmgr/models/request_log.rb +26 -11
  48. data/lib/dcmgr/models/ssh_key_pair.rb +14 -1
  49. data/lib/dcmgr/models/storage_pool.rb +19 -72
  50. data/lib/dcmgr/models/tag.rb +5 -0
  51. data/lib/dcmgr/models/vlan_lease.rb +8 -0
  52. data/lib/dcmgr/models/volume.rb +26 -8
  53. data/lib/dcmgr/models/volume_snapshot.rb +37 -0
  54. data/lib/dcmgr/node_modules/hva_collector.rb +56 -36
  55. data/lib/dcmgr/node_modules/instance_ha.rb +1 -1
  56. data/lib/dcmgr/node_modules/instance_monitor.rb +70 -0
  57. data/lib/dcmgr/node_modules/service_netfilter.rb +914 -0
  58. data/lib/dcmgr/node_modules/sta_collector.rb +7 -30
  59. data/lib/dcmgr/rack/request_logger.rb +60 -0
  60. data/lib/dcmgr/rack/run_initializer.rb +42 -0
  61. data/lib/dcmgr/rpc/hva_handler.rb +388 -0
  62. data/lib/dcmgr/rubygems.rb +7 -0
  63. data/lib/dcmgr/storage_service.rb +98 -0
  64. data/lib/dcmgr/tags.rb +2 -2
  65. data/lib/dcmgr/version.rb +8 -0
  66. data/lib/ext/time.rb +8 -0
  67. data/lib/sinatra/respond_to.rb +3 -0
  68. data/lib/sinatra/sequel_transaction.rb +20 -5
  69. metadata +133 -100
  70. data/lib/dcmgr/models/physical_host.rb +0 -67
  71. data/lib/dcmgr/web/base.rb +0 -21
@@ -1,67 +0,0 @@
1
- module Dcmgr
2
- module Models
3
- class PhysicalHost < Base
4
- set_dataset :physical_hosts
5
- set_prefix_uuid 'PH'
6
-
7
- one_to_many :hv_agents
8
-
9
- many_to_many :tags, :join_table=>:tag_mappings, :left_key=>:target_id, :conditions=>{:target_type=>TagMapping::TYPE_PHYSICAL_HOST}
10
- many_to_many :location_tags, :class=>:Tag, :right_key=>:tag_id, :join_table=>:tag_mappings, :left_key=>:target_id, :conditions=>{:target_type=>TagMapping::TYPE_PHYSICAL_HOST_LOCATION}
11
-
12
- many_to_one :relate_user, :class=>:User
13
-
14
- def self.enable_hosts
15
- filter(~:id => TagMapping.filter(:target_type=>TagMapping::TYPE_PHYSICAL_HOST).select(:target_id)).order_by(:id).all
16
- end
17
-
18
- def self.assign(instance)
19
- Dcmgr::scheduler.assign_to_instance(enable_hosts, instance)
20
- end
21
-
22
- def before_create
23
- super
24
- end
25
-
26
- def after_create
27
- super
28
- TagMapping.create(:tag_id=>Tag.system_tag(:STANDBY_INSTANCE).id,
29
- :target_type=>TagMapping::TYPE_PHYSICAL_HOST,
30
- :target_id=>self.id)
31
- end
32
-
33
- def instances
34
- self.hv_agents.map{|hva| hva.instances}.flatten
35
- end
36
-
37
- def create_location_tag(name, account)
38
- TagMapping.create(:tag_id=>Tag.create(:name=>name, :account=>account).id,
39
- :target_type=>TagMapping::TYPE_PHYSICAL_HOST_LOCATION,
40
- :target_id=>self.id)
41
- end
42
-
43
- def space_cpu_mhz
44
- setup_space unless @space_cpu_mhz
45
- @space_cpu_mhz
46
- end
47
-
48
- def setup_space
49
-
50
- need_cpu_mhz = instances.inject(0) {|v, ins| v + ins.need_cpu_mhz}
51
- space_cpu_mhz = cpu_mhz - need_cpu_mhz
52
- # 10 % down
53
- @space_cpu_mhz = space_cpu_mhz * 0.9
54
-
55
- need_memory = instances.inject(0) {|v, ins| v + ins.need_memory}
56
- space_memory = memory - need_memory
57
- # 10 % down
58
- @space_memory = space_memory * 0.9
59
- end
60
-
61
- def space_memory
62
- setup_space unless @space_memory
63
- @space_memory
64
- end
65
- end
66
- end
67
- end
@@ -1,21 +0,0 @@
1
- require 'sinatra'
2
- require 'sequel'
3
-
4
- module Dcmgr::Web
5
- class Base < Sinatra::Base
6
- set :logger, false
7
- helpers { include Dcmgr::Helpers }
8
-
9
- def self.public_crud model
10
- model.actions {|action, pattern, proc|
11
- Dcmgr::logger.debug "REGISTER: %s %s" % [action, pattern]
12
- self.send action, pattern, &proc
13
- }
14
- end
15
-
16
- not_found do
17
- logger.debug "not found: #{request.request_method} #{request.path}"
18
- "not found"
19
- end
20
- end
21
- end