vagrant-hivemind 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 37e005addc8503ba5ab6d4258211d6467da98cc2
4
- data.tar.gz: cb535a157c3ec342bf9f6f5463bb4f97647e8e0b
3
+ metadata.gz: 50d4a8040973f3f420d21e5d57b4caa10a4d4cee
4
+ data.tar.gz: cef39ddce159974e3fddceebab5fa654f114c5ad
5
5
  SHA512:
6
- metadata.gz: 8aa3bf6452dfb1f4d2a369de2901813a0c39731960dcc6ca7964a8ac820c72efbc1295e42780ab30badc447aaae590251072736e470746060599712358fc87b7
7
- data.tar.gz: fc57c480818d6eda514e92566b47ee8a2d3cccddaac2ba8090ae4e7bc956ad5e88341753117e730761af62af462885828eedf942cb3cc21a9214db9f65c5dbda
6
+ metadata.gz: 0f56a4b3aeb1ad4b0409366be075419ac6276eb18a0f69949e0d43aa82613581fb485d2520151794951171df9a583643013980b9fd8258a3d20e3051dd7e6458
7
+ data.tar.gz: bee703c4db7d000cdde0f576df72d2db3afcd5c8238e87b9360905ef442d084aa235bfb42b1085582c63ec24f15eec79c62c712634b549044f1c73a5b64b9d95
@@ -24,8 +24,8 @@ module Vagrant
24
24
  o.separator "Options:"
25
25
  o.separator ""
26
26
 
27
- o.on("-n", "--hostname HOSTNAME", "The hostname of the Drone (REQUIRED)") do |n|
28
- options[:hostname] = n
27
+ o.on("-n", "--hostname HOSTNAME", "A comma-separated list of Drone hostnames (REQUIRED)") do |n|
28
+ options[:hostname] = Args.from_csv n
29
29
  end
30
30
 
31
31
  o.on("-d", "--directory DIRECTORY", "Specify the directory where '#{HIVE_FILE}' is located (default: current directory)") do |d|
@@ -51,12 +51,18 @@ module Vagrant
51
51
 
52
52
  hosts = HiveFile.read_from root_path
53
53
 
54
- unless hosts.values.map(&:hostname).include? options[:hostname]
55
- @env.ui.error "The specified hostname does not exist!"
56
- return 1
54
+ hostnames = []
55
+ options[:hostname].each do |hostname|
56
+ if hosts.values.map(&:hostname).include? hostname
57
+ hostnames << hostname
58
+ else
59
+ @env.ui.warn "The hostname '#{hostname}' does not exist in the Hive!"
60
+ end
57
61
  end
58
62
 
59
- host = hosts[options[:hostname]]
63
+ hostnames.each do |hostname|
64
+
65
+ host = hosts[hostname]
60
66
 
61
67
  @env.ui.info "Hostname : #{host.hostname}"
62
68
  @env.ui.info "IP Address : #{host.ip_address}"
@@ -65,14 +71,15 @@ module Vagrant
65
71
  @env.ui.info "Box Type : #{BOX_TYPES[host.box_type.to_sym][:name]} (#{BOX_TYPES[host.box_type.to_sym][:box_id]})"
66
72
  @env.ui.info "GUI Machine : #{BOX_TYPES[host.box_type.to_sym][:is_gui] ? 'Yes' : 'No'}"
67
73
  @env.ui.info "Detached Data : #{host.is_data_detached ? 'Yes' : 'No'}"
68
- @env.ui.info ""
69
74
 
70
75
  if host.forwarded_ports and !host.forwarded_ports.empty?
71
76
  @env.ui.info "Forwarded Ports"
72
77
  host.forwarded_ports.each do |forwarded_port|
73
78
  @env.ui.info "#{'%15.15s' % forwarded_port["guest_port"]} : #{forwarded_port["host_port"]}"
74
79
  end
75
- @env.ui.info ""
80
+ end
81
+ @env.ui.info ""
82
+
76
83
  end
77
84
 
78
85
  0
@@ -24,8 +24,8 @@ module Vagrant
24
24
  o.separator "Options:"
25
25
  o.separator ""
26
26
 
27
- o.on("-n", "--hostname HOSTNAME", "The hostname of the Drone (REQUIRED)") do |n|
28
- options[:hostname] = n
27
+ o.on("-n", "--hostname HOSTNAME", "A comma-separated list of Drone hostnames (REQUIRED)") do |n|
28
+ options[:hostname] = Args.from_csv n
29
29
  end
30
30
 
31
31
  o.on("-f", "--force", "Force shut down (equivalent of pulling power)") do |f|
@@ -55,14 +55,18 @@ module Vagrant
55
55
 
56
56
  hosts = HiveFile.read_from root_path
57
57
 
58
- unless hosts.values.map(&:hostname).include? options[:hostname]
59
- @env.ui.error "The specified hostname does not exist!"
60
- return 1
58
+ hostnames = []
59
+ options[:hostname].each do |hostname|
60
+ if hosts.values.map(&:hostname).include? hostname
61
+ hostnames << hostname
62
+ else
63
+ @env.ui.warn "The hostname '#{hostname}' does not exist in the Hive!"
64
+ end
61
65
  end
62
66
 
63
67
  Vagrant::Hivemind::Util::Vagrantfile.generate_hivemind_vagrantfile @env, hosts, root_path
64
68
 
65
- with_target_vms(options[:hostname]) do |vm|
69
+ with_target_vms(hostnames) do |vm|
66
70
  vm.action(:halt, force_halt: options[:force])
67
71
  end
68
72
 
@@ -24,8 +24,8 @@ module Vagrant
24
24
  o.separator "Options:"
25
25
  o.separator ""
26
26
 
27
- o.on("-n", "--hostname HOSTNAME", "The hostname of the Drone (REQUIRED)") do |n|
28
- options[:hostname] = n
27
+ o.on("-n", "--hostname HOSTNAME", "A comma-separated list of Drone hostnames (REQUIRED)") do |n|
28
+ options[:hostname] = Args.from_csv n
29
29
  end
30
30
 
31
31
  o.on("-d", "--directory DIRECTORY", "Specify the directory where '#{HIVE_FILE}' is located (default: current directory)") do |d|
@@ -51,20 +51,26 @@ module Vagrant
51
51
 
52
52
  hosts = HiveFile.read_from root_path
53
53
 
54
- unless hosts.values.map(&:hostname).include? options[:hostname]
55
- @env.ui.error "The specified hostname does not exist!"
56
- return 1
54
+ hostnames = []
55
+ options[:hostname].each do |hostname|
56
+ if hosts.values.map(&:hostname).include? hostname
57
+ hostnames << hostname
58
+ else
59
+ @env.ui.warn "The hostname '#{hostname}' does not exist in the Hive!"
60
+ end
57
61
  end
58
62
 
59
63
  Vagrant::Hivemind::Util::Vagrantfile.generate_hivemind_vagrantfile @env, hosts, root_path
60
64
 
61
- with_target_vms(options[:hostname]) do |vm|
65
+ with_target_vms(hostnames) do |vm|
62
66
  action_env = vm.action(:destroy, force_confirm_destroy: true)
63
67
  end
64
68
 
65
- hosts.delete options[:hostname]
66
- HiveFile.write_to hosts, root_path
67
- @env.ui.info "Killed the Drone with hostname '#{options[:hostname]}'"
69
+ hostnames.each do |hostname|
70
+ hosts.delete hostname
71
+ HiveFile.write_to hosts, root_path
72
+ @env.ui.info "Killed the Drone with hostname '#{hostname}'"
73
+ end
68
74
 
69
75
  0
70
76
  end
@@ -24,8 +24,8 @@ module Vagrant
24
24
  o.separator "Options:"
25
25
  o.separator ""
26
26
 
27
- o.on("-n", "--hostname HOSTNAME", "The hostname of the Drone (REQUIRED)") do |n|
28
- options[:hostname] = n
27
+ o.on("-n", "--hostname HOSTNAME", "A comma-separated list of Drone hostnames (REQUIRED)") do |n|
28
+ options[:hostname] = Args.from_csv n
29
29
  end
30
30
 
31
31
  o.on("-c", "--control", "Assign the Drone to be a Control Machine") do |c|
@@ -67,29 +67,40 @@ module Vagrant
67
67
 
68
68
  hosts = HiveFile.read_from root_path
69
69
 
70
- if hosts.values.map(&:hostname).include? options[:hostname]
71
- @env.ui.error "The specified hostname already exists!"
72
- return 1
70
+ hostnames = []
71
+ options[:hostname].each do |hostname|
72
+ if hosts.values.map(&:hostname).include? hostname
73
+ @env.ui.warn "The hostname '#{hostname}' already exists in the Hive!"
74
+ else
75
+ if Network.is_valid_hostname? hostname
76
+ hostnames << hostname
77
+ else
78
+ @env.ui.warn "Invalid hostname format!"
79
+ end
80
+ end
73
81
  end
74
82
 
75
- unless Network.is_valid_hostname? options[:hostname]
76
- @env.ui.error "Invalid hostname format!"
83
+ if hostnames.empty?
84
+ @env.ui.warn "No Drones to spawn!"
77
85
  return 1
78
86
  end
79
87
 
80
- drone = {
81
- options[:hostname] => Vagrant::Hivemind::Host.new(
82
- options[:hostname],
83
- Network.next_ip_address(hosts),
84
- {
85
- is_control: options[:control],
86
- box_size: options[:size],
87
- box_type: options[:type],
88
- is_data_detached: options[:detach]
89
- })
90
- }
91
- HiveFile.write_to hosts.merge(drone), root_path
92
- @env.ui.info "Spawned the Drone with hostname '#{options[:hostname]}'"
88
+ hostnames.each do |hostname|
89
+ drone = {
90
+ hostname => Vagrant::Hivemind::Host.new(
91
+ hostname,
92
+ Network.next_ip_address(hosts),
93
+ {
94
+ is_control: options[:control],
95
+ box_size: options[:size],
96
+ box_type: options[:type],
97
+ is_data_detached: options[:detach]
98
+ })
99
+ }
100
+ hosts = hosts.merge(drone)
101
+ @env.ui.info "Spawned the Drone with hostname '#{hostname}'"
102
+ end
103
+ HiveFile.write_to hosts, root_path
93
104
 
94
105
  0
95
106
  end
@@ -25,8 +25,8 @@ module Vagrant
25
25
  o.separator "Options:"
26
26
  o.separator ""
27
27
 
28
- o.on("-n", "--hostname HOSTNAME", "The hostname of the Drone (REQUIRED)") do |n|
29
- options[:hostname] = n
28
+ o.on("-n", "--hostname HOSTNAME", "A comma-separated list of Drone hostnames (REQUIRED)") do |n|
29
+ options[:hostname] = Args.from_csv n
30
30
  end
31
31
 
32
32
  o.on("-d", "--directory DIRECTORY", "Specify the directory where '#{HIVE_FILE}' is located (default: current directory)") do |d|
@@ -52,9 +52,13 @@ module Vagrant
52
52
 
53
53
  hosts = HiveFile.read_from root_path
54
54
 
55
- unless hosts.values.map(&:hostname).include? options[:hostname]
56
- @env.ui.error "The specified hostname does not exist!"
57
- return 1
55
+ hostnames = []
56
+ options[:hostname].each do |hostname|
57
+ if hosts.values.map(&:hostname).include? hostname
58
+ hostnames << hostname
59
+ else
60
+ @env.ui.warn "The hostname '#{hostname}' does not exist in the Hive!"
61
+ end
58
62
  end
59
63
 
60
64
  Vagrant::Hivemind::Util::Vagrantfile.generate_hivemind_vagrantfile @env, hosts, root_path
@@ -63,7 +67,7 @@ module Vagrant
63
67
 
64
68
  machines = []
65
69
  @env.batch do |batch|
66
- with_target_vms(options[:hostname]) do |machine|
70
+ with_target_vms(hostnames) do |machine|
67
71
  @env.ui.info(I18n.t("vagrant.commands.up.upping",
68
72
  name: machine.name,
69
73
  provider: machine.provider_name))
@@ -36,6 +36,14 @@ module Vagrant
36
36
  end
37
37
  end
38
38
 
39
+ class Args
40
+ def self.from_csv(csv)
41
+ return nil unless csv
42
+ tokens = csv.delete(" ").split(",").select do |token| !token.empty? end
43
+ tokens.empty? ? nil : tokens
44
+ end
45
+ end
46
+
39
47
  class Network
40
48
  def self.is_valid_hostname?(hostname)
41
49
  return false unless hostname and hostname.size > 0 and hostname.size <= Vagrant::Hivemind::Constants::SIMPLE_HOSTNAME_MAX_LENGTH
@@ -1,5 +1,5 @@
1
1
  module Vagrant
2
2
  module Hivemind
3
- VERSION = "0.1.3"
3
+ VERSION = "0.1.4"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-hivemind
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nap Ramirez
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-10-05 00:00:00.000000000 Z
11
+ date: 2015-10-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler