vcloud-cli-utils 0.8.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/bin/vcloud-rename-vm +8 -0
- data/lib/vcloud/cli/utils.rb +1 -0
- data/lib/vcloud/cli/utils/rename_vm.rb +67 -0
- data/lib/vcloud/cli/utils/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a312c6aed92b3c9151557e72d87bb36f45426b4b
|
4
|
+
data.tar.gz: d7511060851404dcb422b4fcffce2ba9db6966b6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9055d663e99e701b220dbd9bda4d5d19995356bd8b05676fd31ba4ab59a0e9399075738c5cee759c90ed2710f89d6f7ae9e4e5d2e44206821b7194ff3299d0a8
|
7
|
+
data.tar.gz: f52fc4eacaa06e1e1ad037d930b818c9a86f021a7462ee1603cc6391644210fce090f15553224f373c6fa9851d0d12ef87b34cdc0a8f5d5438580421c9b329eb
|
data/CHANGELOG.md
CHANGED
data/lib/vcloud/cli/utils.rb
CHANGED
@@ -0,0 +1,67 @@
|
|
1
|
+
require 'methadone'
|
2
|
+
require 'vcloud/core'
|
3
|
+
require 'pp'
|
4
|
+
|
5
|
+
module Vcloud
|
6
|
+
module CLI
|
7
|
+
module Utils
|
8
|
+
class RenameVm
|
9
|
+
|
10
|
+
include Methadone::Main
|
11
|
+
include Methadone::CLILogging
|
12
|
+
|
13
|
+
def self.run
|
14
|
+
|
15
|
+
main do |identifier, name|
|
16
|
+
Fog.mock! if ENV['FOG_MOCK']
|
17
|
+
if identifier =~ /^vm-[-0-9a-f]+/
|
18
|
+
vapp = Vcloud::Core::Vapp.get_by_child_vm_id(identifier)
|
19
|
+
vm = Vcloud::Core::Vm.new(identifier, vapp)
|
20
|
+
elsif identifier =~ /^vapp-[-0-9a-f]+/
|
21
|
+
vapp = Vcloud::Core::Vapp.new(identifier)
|
22
|
+
vm_href = vapp.vms.first.fetch(:href)
|
23
|
+
vm = Vcloud::Core::Vm.new(vm_href.split('/').last, vapp)
|
24
|
+
else
|
25
|
+
vapp = Vcloud::Core::Vapp.get_by_name(identifier)
|
26
|
+
vm_href = vapp.vms.first.fetch(:href)
|
27
|
+
vm = Vcloud::Core::Vm.new(vm_href.split('/').last, vapp)
|
28
|
+
end
|
29
|
+
|
30
|
+
if options[:rename_to_match_vapp]
|
31
|
+
new_name = vapp.name
|
32
|
+
else
|
33
|
+
if name.nil?
|
34
|
+
raise "Need a name to rename the VM to!"
|
35
|
+
else
|
36
|
+
new_name = name
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
vm.update_name(new_name)
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
arg :identifier
|
45
|
+
arg :name, :optional
|
46
|
+
|
47
|
+
on("-r", "--rename_to_match_vapp", "Make the vm name match the vApp name")
|
48
|
+
|
49
|
+
description "
|
50
|
+
Renames a vCloud VM given by :identifier (existing name or ID).
|
51
|
+
|
52
|
+
If a 'name' parameter is specified, renames to that.
|
53
|
+
|
54
|
+
If --rename_to_match_vapp is specified, treat the identifier as a selector of the vApp, and
|
55
|
+
rename the VM to that.
|
56
|
+
|
57
|
+
If a vApp with multiple VMs is given, only the first is renamed.
|
58
|
+
"
|
59
|
+
|
60
|
+
go!
|
61
|
+
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vcloud-cli-utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Pountney
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-02-
|
11
|
+
date: 2015-02-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fog
|
@@ -137,6 +137,7 @@ executables:
|
|
137
137
|
- vcloud-get-entity
|
138
138
|
- vcloud-get_vms_attached_to-disk
|
139
139
|
- vcloud-make-vapp-template
|
140
|
+
- vcloud-rename-vm
|
140
141
|
- vcloud-start-vapp
|
141
142
|
- vcloud-stop-vapp
|
142
143
|
extensions: []
|
@@ -158,6 +159,7 @@ files:
|
|
158
159
|
- bin/vcloud-get-entity
|
159
160
|
- bin/vcloud-get_vms_attached_to-disk
|
160
161
|
- bin/vcloud-make-vapp-template
|
162
|
+
- bin/vcloud-rename-vm
|
161
163
|
- bin/vcloud-start-vapp
|
162
164
|
- bin/vcloud-stop-vapp
|
163
165
|
- lib/vcloud/cli/utils.rb
|
@@ -169,6 +171,7 @@ files:
|
|
169
171
|
- lib/vcloud/cli/utils/get_entity.rb
|
170
172
|
- lib/vcloud/cli/utils/get_vms_attached_to_disk.rb
|
171
173
|
- lib/vcloud/cli/utils/make_vapp_template.rb
|
174
|
+
- lib/vcloud/cli/utils/rename_vm.rb
|
172
175
|
- lib/vcloud/cli/utils/start_vapp.rb
|
173
176
|
- lib/vcloud/cli/utils/stop_vapp.rb
|
174
177
|
- lib/vcloud/cli/utils/version.rb
|