sistero 0.7.3 → 0.7.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: 0e30ac237dbb3880332a0ce711d3c165f3137873
4
- data.tar.gz: 1a4490ef36377a71ecbfa8332c3f18063608bd00
3
+ metadata.gz: c966aa5e013e4a912ed85572ea3df024ba5b3552
4
+ data.tar.gz: e3a8f4a357ad77c63cb781c13b3a6700377ea798
5
5
  SHA512:
6
- metadata.gz: 3a62c0b266d8531b555b006c1b22e52e6663057917727c56b7b27297f883c77776ac71f13ee9997a01f60025927b49e3e825cdf704438b137d8f77672583de43
7
- data.tar.gz: 76e5cd39e8bb4ffc01451a250a397dc2222b9a0d1f10db3dc387bdf5c61f5a69ff1655e270a3f7793065654f0bdb5fded46d5d35ed1685d435be480854e2ba2e
6
+ metadata.gz: 85c52cd18afca7958e0a30991238cc737381f22eb6b5f6eb81c198483410ac77647788fcd06d8cae6b924c81d5fe4b4f9491b0b0a269e436c4af6b3ab539e5c3
7
+ data.tar.gz: cc127f77567046ba6ad2ffdd2aa904741c87b89fa96efad279401ff934d6efdbca52399f07d4d5c7b136c4a81702ae4abd64adc898891767996e62ad0b27e311
data/bin/sistero CHANGED
@@ -28,6 +28,8 @@ module Sistero::Command
28
28
  subop.on '-o val', 'add ssh options', 'ssh_options'
29
29
  end
30
30
 
31
+ op.subcommand 'rsync vm *cmd', 'rsync files to vm'
32
+
31
33
  op.subcommand 'create [*vms]', 'create vm'
32
34
  op.subcommand 'create-all', 'create all vms in config'
33
35
  op.subcommand 'destroy [*vms]', 'destroy vm'
@@ -56,8 +58,9 @@ module Sistero::Command
56
58
 
57
59
  case command
58
60
  when 'ssh'
59
- # TODO: pass ssh_args
60
61
  sistero.ssh_to_vm(command_cfg.vm, ssh_options: command_cfg.ssh_options, run: command_cfg.run)
62
+ when 'rsync'
63
+ sistero.rsync(command_cfg.vm, cmd: command_cfg.cmd)
61
64
  when 'create'
62
65
  vms = command_cfg.vms
63
66
  vms.push nil if vms.empty?
data/lib/sistero.rb CHANGED
@@ -70,22 +70,8 @@ module Sistero
70
70
  ssh_options ||= vm.ssh_options
71
71
 
72
72
  droplet = find_droplet(name) || create_droplet_from_vm(name)
73
- public_network = droplet.networks.v4.find { |network| network.type == 'public' }
74
- until public_network
75
- puts "no public interfaces, trying again in a second"
76
- sleep 1
77
- droplet = find_droplet(name)
78
- public_network = droplet.networks.v4.find { |network| network.type == 'public' }
79
- end
80
- ip = public_network.ip_address
81
-
82
- unless is_port_open? ip, 22
83
- puts "waiting for ssh port to open"
84
- sleep 1
85
- until is_port_open? ip, 22 do
86
- sleep 1
87
- end
88
- end
73
+ public_network = get_public_network name, droplet
74
+ ip = wait_for_ssh_port public_network
89
75
 
90
76
  cmd = "ssh -o 'StrictHostKeyChecking no' #{ssh_options} #{vm.ssh_user || 'root'}@#{ip}"
91
77
  unless run.empty?
@@ -96,6 +82,16 @@ module Sistero
96
82
  exec cmd
97
83
  end
98
84
 
85
+ def rsync(name, cmd: nil)
86
+ vm, name = get_vm name
87
+ droplet = find_droplet(name) || create_droplet_from_vm(name)
88
+ public_network = get_public_network name, droplet
89
+ ip = wait_for_ssh_port public_network
90
+
91
+ cmd_str = 'rsync ' + cmd.join(' ').gsub('vm:', "#{vm.ssh_user || 'root'}@#{ip}:")
92
+ exec cmd_str
93
+ end
94
+
99
95
  def destroy_vm(name)
100
96
  vm, name = get_vm name
101
97
 
@@ -147,5 +143,29 @@ module Sistero
147
143
  puts " regions #{image.regions.join ', '}"
148
144
  end
149
145
  end
146
+
147
+ private
148
+ def get_public_network name, droplet
149
+ public_network = droplet.networks.v4.find { |network| network.type == 'public' }
150
+ until public_network
151
+ puts "no public interfaces, trying again in a second"
152
+ sleep 1
153
+ droplet = find_droplet(name)
154
+ public_network = droplet.networks.v4.find { |network| network.type == 'public' }
155
+ end
156
+ public_network
157
+ end
158
+
159
+ def wait_for_ssh_port public_network
160
+ ip = public_network.ip_address
161
+ unless is_port_open? ip, 22
162
+ puts "waiting for ssh port to open"
163
+ sleep 1
164
+ until is_port_open? ip, 22 do
165
+ sleep 1
166
+ end
167
+ end
168
+ ip
169
+ end
150
170
  end
151
171
  end
@@ -1,3 +1,3 @@
1
1
  module Sistero
2
- VERSION = '0.7.3'
2
+ VERSION = '0.7.4'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sistero
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.3
4
+ version: 0.7.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Pike