cyoi 0.6.1 → 0.7.0
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 +8 -8
- data/.gitignore +2 -1
- data/ChangeLog.md +4 -0
- data/Gemfile +1 -0
- data/lib/cyoi/cli/auto_detection.rb +1 -1
- data/lib/cyoi/cli/auto_detection/auto_detection_fog.rb +10 -0
- data/lib/cyoi/cli/provider.rb +2 -1
- data/lib/cyoi/cli/provider_addresses/address_cli_vsphere.rb +44 -0
- data/lib/cyoi/cli/provider_key_pair/key_pair_vsphere.rb +57 -0
- data/lib/cyoi/cli/providers/provider_cli_vsphere.rb +94 -0
- data/lib/cyoi/providers.rb +6 -0
- data/lib/cyoi/providers/clients/vsphere_provider_client.rb +15 -0
- data/lib/cyoi/version.rb +1 -1
- data/spec/integration/cli/provider/provider_aws_spec.rb +3 -2
- data/spec/integration/cli/provider/provider_openstack_spec.rb +5 -3
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NWU4Y2U2YzZjMjI1ZmI0ZTdlNzM4OTA3ZjBhZmY2NmY2MjVlNGM5ZA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MDhjN2E4NzE4ODgyOTk5ZDA4ODBhYTgxZWU0MzM4NmZiMjAyMDc3Yg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NGNjNTU4ZWMzMDA0M2JkMzRlMDRhYWJhYjZlMDFjNDVjYzVmYTIyNmI3NGIy
|
10
|
+
NGJmYTJjN2ZkOGYwOTcyNzYyZTI3NTI4OTVhNmQ1MTFjNzE3NThlNGZlYmMw
|
11
|
+
Yzc2NTExNTdiZWE3MTBiYWJmZmNkNmQ4MzdiYzY0YTcxMDJlODQ=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NTIzZTEyMWRhMjcyZmEyZDExMDM0MjRhMWJlODlkZDNmNzdhNWY3NWE2MTBl
|
14
|
+
NGExMWQ0NDhiYTZkYmQ2NjgyZjc2MjFjOTIxYTlmYWQ2MzhhYjBjZDk2ZTA1
|
15
|
+
ZWZhOTFjMmJkZThkODMzMjIzMDAwOGE0ZjRiOWNlZTcwODVhMDg=
|
data/.gitignore
CHANGED
data/ChangeLog.md
CHANGED
@@ -2,6 +2,10 @@
|
|
2
2
|
|
3
3
|
Cyoi (choose-your-own-infrastructure) is a library to ask an end-user to choose an infrastructure (AWS, OpenStack, etc), region, and login credentials.
|
4
4
|
|
5
|
+
## v0.7
|
6
|
+
|
7
|
+
* vsphere provising
|
8
|
+
|
5
9
|
## v0.6
|
6
10
|
|
7
11
|
* added `cyoi image` - AWS: public AMI for Ubuntu 13.04; OpenStack: choose an Image from menu
|
data/Gemfile
CHANGED
@@ -17,7 +17,7 @@ class Cyoi::Cli::AutoDetection::UI
|
|
17
17
|
# Include "Alternate credentials" as the last option
|
18
18
|
if aggregated_detector_choices.keys.size > 0
|
19
19
|
hl.choose do |menu|
|
20
|
-
menu.prompt = "Choose an auto-detected infrastructure:
|
20
|
+
menu.prompt = "Choose an auto-detected infrastructure: "
|
21
21
|
aggregated_detector_choices.each do |label, credentials|
|
22
22
|
menu.choice(label) do
|
23
23
|
attributes.set("name", credentials.delete("name"))
|
@@ -75,6 +75,16 @@ class Cyoi::Cli::AutoDetection::AutoDetectionFog
|
|
75
75
|
choice["openstack_region"] = profile[:openstack_region] if profile[:openstack_region]
|
76
76
|
fog_choices["OpenStack (#{profile_name})"] = choice
|
77
77
|
end
|
78
|
+
if profile[:vsphere_username]
|
79
|
+
fog_choices["vSphere (#{profile_name})"] = {
|
80
|
+
"name" => "vsphere",
|
81
|
+
"provider" => "vSphere",
|
82
|
+
"vsphere_username" => profile[:vsphere_username],
|
83
|
+
"vsphere_password" => profile[:vsphere_password],
|
84
|
+
"vsphere_server" => profile[:vsphere_server],
|
85
|
+
"vsphere_expected_pubkey_hash" => profile[:vsphere_expected_pubkey_hash]
|
86
|
+
}
|
87
|
+
end
|
78
88
|
end
|
79
89
|
fog_choices
|
80
90
|
end
|
data/lib/cyoi/cli/provider.rb
CHANGED
@@ -0,0 +1,44 @@
|
|
1
|
+
module Cyoi::Cli::Addresses; end
|
2
|
+
class Cyoi::Cli::Addresses::AddressCliVsphere
|
3
|
+
attr_reader :provider_client
|
4
|
+
attr_reader :attributes
|
5
|
+
attr_reader :hl
|
6
|
+
|
7
|
+
def initialize(provider_client, attributes, highline)
|
8
|
+
@provider_client = provider_client
|
9
|
+
@hl = highline
|
10
|
+
@attributes = attributes.is_a?(Hash) ? ReadWriteSettings.new(attributes) : attributes
|
11
|
+
raise "@attributes must be ReadWriteSettings (or Hash)" unless @attributes.is_a?(ReadWriteSettings)
|
12
|
+
end
|
13
|
+
|
14
|
+
def perform_and_return_attributes
|
15
|
+
unless valid_address?
|
16
|
+
provision_address
|
17
|
+
end
|
18
|
+
export_attributes
|
19
|
+
end
|
20
|
+
|
21
|
+
# helper to export the complete nested attributes.
|
22
|
+
def export_attributes
|
23
|
+
attributes.to_nested_hash
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
def valid_address?
|
28
|
+
attributes["ip"]
|
29
|
+
end
|
30
|
+
|
31
|
+
def display_confirmation
|
32
|
+
puts "\n"
|
33
|
+
puts "Confirming: Using address #{attributes.ip}"
|
34
|
+
end
|
35
|
+
|
36
|
+
protected
|
37
|
+
def provision_address
|
38
|
+
print "Please specify network settings... "
|
39
|
+
attributes["ip"] = hl.ask("Public IP: ").to_s unless attributes.exists?("ip")
|
40
|
+
puts attributes.ip
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
Cyoi::Cli::Address.register_address_cli("vsphere", Cyoi::Cli::Addresses::AddressCliVsphere)
|
@@ -0,0 +1,57 @@
|
|
1
|
+
class Cyoi::Cli::KeyPair; end
|
2
|
+
class Cyoi::Cli::KeyPair::KeyPairCliVsphere
|
3
|
+
attr_reader :provider_client
|
4
|
+
attr_reader :attributes
|
5
|
+
attr_reader :hl
|
6
|
+
|
7
|
+
def initialize(provider_client, attributes, highline)
|
8
|
+
@provider_client = provider_client
|
9
|
+
@hl = highline
|
10
|
+
@attributes = attributes.is_a?(Hash) ? ReadWriteSettings.new(attributes) : attributes
|
11
|
+
raise "@attributes must be ReadWriteSettings (or Hash)" unless @attributes.is_a?(ReadWriteSettings)
|
12
|
+
raise "@attributes.name must be set" unless @attributes["name"]
|
13
|
+
end
|
14
|
+
|
15
|
+
def perform_and_return_attributes
|
16
|
+
unless valid?
|
17
|
+
#destroy_existing_key_pair
|
18
|
+
provision_key_pair
|
19
|
+
end
|
20
|
+
export_attributes
|
21
|
+
end
|
22
|
+
|
23
|
+
# helper to export the complete nested attributes.
|
24
|
+
def export_attributes
|
25
|
+
attributes.to_nested_hash
|
26
|
+
end
|
27
|
+
|
28
|
+
def valid?
|
29
|
+
attributes["name"] && attributes["fingerprint"] && attributes["private_key"]
|
30
|
+
# provider_client.valid_key_pair_fingerprint?(key_pair_name, attributes.fingerprint)
|
31
|
+
end
|
32
|
+
|
33
|
+
def display_confirmation
|
34
|
+
puts "\n"
|
35
|
+
puts "Confirming: Using key pair #{key_pair_name}"
|
36
|
+
end
|
37
|
+
|
38
|
+
def key_pair_name
|
39
|
+
attributes.name
|
40
|
+
end
|
41
|
+
|
42
|
+
protected
|
43
|
+
def destroy_existing_key_pair
|
44
|
+
provider_client.delete_key_pair_if_exists(key_pair_name)
|
45
|
+
end
|
46
|
+
|
47
|
+
# provisions key pair from OpenStack and returns fog object KeyPair
|
48
|
+
def provision_key_pair
|
49
|
+
#if key_pair = provider_client.create_key_pair(key_pair_name)
|
50
|
+
# FIXME: Create a dummy keypair for now...
|
51
|
+
attributes["fingerprint"] = "Dummy Fingerprint!"
|
52
|
+
attributes["private_key"] = "Dummy Private Key!"
|
53
|
+
#end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
Cyoi::Cli::KeyPair.register_key_pair_cli("vsphere", Cyoi::Cli::KeyPair::KeyPairCliVsphere)
|
@@ -0,0 +1,94 @@
|
|
1
|
+
require "cyoi/cli/providers/provider_cli"
|
2
|
+
class Cyoi::Cli::Providers::ProviderCliVsphere < Cyoi::Cli::Providers::ProviderCli
|
3
|
+
def perform_and_return_attributes
|
4
|
+
unless valid_infrastructure?
|
5
|
+
puts "\nUsing provider vSphere\n"
|
6
|
+
setup_credentials
|
7
|
+
setup_networking
|
8
|
+
setup_resources
|
9
|
+
setup_ntp
|
10
|
+
setup_vcenter
|
11
|
+
end
|
12
|
+
export_attributes
|
13
|
+
end
|
14
|
+
|
15
|
+
def setup_credentials
|
16
|
+
puts "\n"
|
17
|
+
attributes.set_default("credentials", {})
|
18
|
+
credentials = attributes.credentials
|
19
|
+
credentials["vsphere_username"] = hl.ask("Username: ").to_s unless credentials.exists?("vsphere_username")
|
20
|
+
credentials["vsphere_password"] = hl.ask("Password: ").to_s unless credentials.exists?("vsphere_password")
|
21
|
+
credentials["vsphere_server"] = hl.ask("Server: ").to_s unless credentials.exists?("vsphere_server")
|
22
|
+
credentials["vsphere_expected_pubkey_hash"] = h1.ask("Expected public key hash: ").to_s unless credentials.exists?("vsphere_expected_pubkey_hash")
|
23
|
+
end
|
24
|
+
|
25
|
+
def setup_networking
|
26
|
+
puts "\n"
|
27
|
+
attributes.set_default("network", {})
|
28
|
+
network = attributes.network
|
29
|
+
network["netmask"] = hl.ask("Netmask: ").to_s unless network.exists?("netmask")
|
30
|
+
network["gateway"] = hl.ask("Gateway: ").to_s unless network.exists?("gateway")
|
31
|
+
network["dns"] = hl.ask("DNS Server: ").to_s unless network.exists?("dns")
|
32
|
+
network["name"] = hl.ask("vCenter Port Group: ").to_s unless network.exists?("name")
|
33
|
+
end
|
34
|
+
|
35
|
+
def setup_resources
|
36
|
+
puts "\n"
|
37
|
+
attributes.set_default("resources", {})
|
38
|
+
resources = attributes.resources
|
39
|
+
resources["persistent_disk"] = hl.ask("Size of Persistent Volume (MB): ", Integer) unless resources.exists?("persistent_disk")
|
40
|
+
resources["ram"] = hl.ask("MicroBOSH Memory (MB): ", Integer) unless resources.exists?("ram")
|
41
|
+
resources["disk"] = hl.ask("MicroBOSH Local Disk (MB): ", Integer) unless resources.exists?("disk")
|
42
|
+
resources["cpu"] = hl.ask("MicroBOSH vCPUs: ", Integer) unless resources.exists?("cpu")
|
43
|
+
end
|
44
|
+
|
45
|
+
def setup_ntp
|
46
|
+
puts "\n"
|
47
|
+
attributes["ntps"] = hl.ask("NTP Server: ").to_s unless attributes.exists?("ntps")
|
48
|
+
end
|
49
|
+
|
50
|
+
def setup_vcenter
|
51
|
+
puts "\n"
|
52
|
+
attributes.set_default("datacenter", {})
|
53
|
+
datacenter = attributes.datacenter
|
54
|
+
datacenter["name"] = hl.ask("Datacenter: ").to_s unless datacenter.exists?("name")
|
55
|
+
datacenter["vm_folder"] = hl.ask("VM Folder: ").to_s unless datacenter.exists?("vm_folder")
|
56
|
+
datacenter["template_folder"] = hl.ask("Template Folder: ").to_s unless datacenter.exists?("template_folder")
|
57
|
+
datacenter["disk_path"] = hl.ask("Disk Path: ").to_s unless datacenter.exists?("disk_path")
|
58
|
+
datacenter["datastore_pattern"] = hl.ask("Datastore Pattern: ").to_s unless datacenter.exists?("datastore_pattern")
|
59
|
+
datacenter["persistent_datastore_pattern"] = hl.ask("Persistent Datastore Pattern: ").to_s unless datacenter.exists?("persistent_datastore_pattern")
|
60
|
+
datacenter["allow_mixed_datastores"] = hl.agree("Allow mixed datastores? (y/n): ") unless datacenter.exists?("allow_mixed_datastores")
|
61
|
+
datacenter["clusters"] = hl.ask("Clusters: ").to_s unless datacenter.exists?("clusters")
|
62
|
+
end
|
63
|
+
|
64
|
+
def valid_infrastructure?
|
65
|
+
attributes.exists?("credentials.vsphere_username") &&
|
66
|
+
attributes.exists?("credentials.vsphere_password") &&
|
67
|
+
attributes.exists?("credentials.vsphere_server") &&
|
68
|
+
attributes.exists?("credentials.vsphere_expected_pubkey_hash") &&
|
69
|
+
attributes.exists?("network.netmask") &&
|
70
|
+
attributes.exists?("network.gateway") &&
|
71
|
+
attributes.exists?("network.dns") &&
|
72
|
+
attributes.exists?("network.name") &&
|
73
|
+
attributes.exists?("ntps") &&
|
74
|
+
attributes.exists?("datacenter.name") &&
|
75
|
+
attributes.exists?("datacenter.vm_folder") &&
|
76
|
+
attributes.exists?("datacenter.template_folder") &&
|
77
|
+
attributes.exists?("datacenter.disk_path") &&
|
78
|
+
attributes.exists?("datacenter.datastore_pattern") &&
|
79
|
+
attributes.exists?("datacenter.persistent_datastore_pattern") &&
|
80
|
+
attributes.exists?("datacenter.allow_mixed_datastores") &&
|
81
|
+
attributes.exists?("datacenter.clusters") &&
|
82
|
+
attributes.exists?("resources.persistent_disk") &&
|
83
|
+
attributes.exists?("resources.ram") &&
|
84
|
+
attributes.exists?("resources.disk") &&
|
85
|
+
attributes.exists?("resources.cpu")
|
86
|
+
end
|
87
|
+
|
88
|
+
def display_confirmation
|
89
|
+
puts "\n"
|
90
|
+
puts "Confirming: Using vSphere"
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
Cyoi::Cli::Provider.register_provider_cli("vsphere", Cyoi::Cli::Providers::ProviderCliVsphere)
|
data/lib/cyoi/providers.rb
CHANGED
@@ -21,6 +21,12 @@ module Cyoi::Providers
|
|
21
21
|
require "cyoi/providers/clients/openstack_provider_client"
|
22
22
|
Cyoi::Providers::Clients::OpenStackProviderClient.new(attributes)
|
23
23
|
end
|
24
|
+
when :vsphere
|
25
|
+
@vsphere_provider_client ||= begin
|
26
|
+
puts "vsphere!"
|
27
|
+
require "cyoi/providers/clients/vsphere_provider_client"
|
28
|
+
Cyoi::Providers::Clients::VsphereProviderClient.new(attributes)
|
29
|
+
end
|
24
30
|
else
|
25
31
|
nil
|
26
32
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Cyoi; module Providers; module Clients; end; end; end
|
2
|
+
|
3
|
+
require "cyoi/providers/clients/fog_provider_client"
|
4
|
+
|
5
|
+
class Cyoi::Providers::Clients::VsphereProviderClient < Cyoi::Providers::Clients::FogProviderClient
|
6
|
+
|
7
|
+
# Construct a Fog::Compute object
|
8
|
+
# Uses +attributes+ which normally originates from +settings.provider+
|
9
|
+
def setup_fog_connection
|
10
|
+
configuration = Fog.symbolize_credentials(attributes.credentials)
|
11
|
+
configuration[:provider] = "vSphere"
|
12
|
+
@fog_compute = Fog::Compute.new(configuration)
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
data/lib/cyoi/version.rb
CHANGED
@@ -23,6 +23,7 @@ describe "cyoi provider aws" do
|
|
23
23
|
assert_passing_with(<<-OUT)
|
24
24
|
1. AWS
|
25
25
|
2. OpenStack
|
26
|
+
3. vSphere
|
26
27
|
Choose your infrastructure:
|
27
28
|
Using provider AWS
|
28
29
|
|
@@ -63,7 +64,7 @@ Auto-detected infrastructure API credentials at ~/.fog (override with $FOG)
|
|
63
64
|
3. AWS (starkandwayne)
|
64
65
|
4. OpenStack (personal)
|
65
66
|
5. Alternate credentials
|
66
|
-
Choose an auto-detected infrastructure:
|
67
|
+
Choose an auto-detected infrastructure:
|
67
68
|
Using provider AWS
|
68
69
|
|
69
70
|
|
@@ -81,4 +82,4 @@ Confirming: Using AWS/ap-southeast-2
|
|
81
82
|
|
82
83
|
settings.provider.region.should == "ap-southeast-2"
|
83
84
|
end
|
84
|
-
end
|
85
|
+
end
|
@@ -27,6 +27,7 @@ describe "cyoi provider openstack" do
|
|
27
27
|
assert_passing_with(<<-OUT)
|
28
28
|
1. AWS
|
29
29
|
2. OpenStack
|
30
|
+
3. vSphere
|
30
31
|
Choose your infrastructure:
|
31
32
|
Using provider OpenStack
|
32
33
|
Username: Password: Tenant: Authorization Token URL: OpenStack Region (optional):
|
@@ -38,7 +39,7 @@ Confirming: Using OpenStack (user: USERNAME)
|
|
38
39
|
"provider" => {
|
39
40
|
"name" => "openstack",
|
40
41
|
"credentials"=>{
|
41
|
-
"openstack_username"=>"USERNAME", "openstack_api_key"=>"PASSWORD",
|
42
|
+
"openstack_username"=>"USERNAME", "openstack_api_key"=>"PASSWORD",
|
42
43
|
"openstack_tenant"=>"TENANT", "openstack_auth_url"=>"TOKENURL/tokens",
|
43
44
|
"openstack_region"=>""
|
44
45
|
},
|
@@ -58,6 +59,7 @@ Confirming: Using OpenStack (user: USERNAME)
|
|
58
59
|
assert_passing_with(<<-OUT)
|
59
60
|
1. AWS
|
60
61
|
2. OpenStack
|
62
|
+
3. vSphere
|
61
63
|
Choose your infrastructure:
|
62
64
|
Using provider OpenStack
|
63
65
|
Username: Password: Tenant: Authorization Token URL: OpenStack Region (optional):
|
@@ -79,10 +81,10 @@ Auto-detected infrastructure API credentials at ~/.fog (override with $FOG)
|
|
79
81
|
3. AWS (starkandwayne)
|
80
82
|
4. OpenStack (personal)
|
81
83
|
5. Alternate credentials
|
82
|
-
Choose an auto-detected infrastructure:
|
84
|
+
Choose an auto-detected infrastructure:
|
83
85
|
Using provider OpenStack
|
84
86
|
OpenStack Region (optional):
|
85
87
|
Confirming: Using OpenStack (user: USERNAME)
|
86
88
|
OUT
|
87
89
|
end
|
88
|
-
end
|
90
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cyoi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dr Nic Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-11-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fog
|
@@ -142,19 +142,23 @@ files:
|
|
142
142
|
- lib/cyoi/cli/provider.rb
|
143
143
|
- lib/cyoi/cli/provider_addresses/address_cli_aws.rb
|
144
144
|
- lib/cyoi/cli/provider_addresses/address_cli_openstack.rb
|
145
|
+
- lib/cyoi/cli/provider_addresses/address_cli_vsphere.rb
|
145
146
|
- lib/cyoi/cli/provider_image/image_cli_aws.rb
|
146
147
|
- lib/cyoi/cli/provider_image/image_cli_base.rb
|
147
148
|
- lib/cyoi/cli/provider_image/image_cli_openstack.rb
|
148
149
|
- lib/cyoi/cli/provider_key_pair/key_pair_aws.rb
|
149
150
|
- lib/cyoi/cli/provider_key_pair/key_pair_openstack.rb
|
151
|
+
- lib/cyoi/cli/provider_key_pair/key_pair_vsphere.rb
|
150
152
|
- lib/cyoi/cli/providers/provider_cli.rb
|
151
153
|
- lib/cyoi/cli/providers/provider_cli_aws.rb
|
152
154
|
- lib/cyoi/cli/providers/provider_cli_openstack.rb
|
155
|
+
- lib/cyoi/cli/providers/provider_cli_vsphere.rb
|
153
156
|
- lib/cyoi/providers.rb
|
154
157
|
- lib/cyoi/providers/README.md
|
155
158
|
- lib/cyoi/providers/clients/aws_provider_client.rb
|
156
159
|
- lib/cyoi/providers/clients/fog_provider_client.rb
|
157
160
|
- lib/cyoi/providers/clients/openstack_provider_client.rb
|
161
|
+
- lib/cyoi/providers/clients/vsphere_provider_client.rb
|
158
162
|
- lib/cyoi/providers/constants/aws_constants.rb
|
159
163
|
- lib/cyoi/providers/constants/openstack_constants.rb
|
160
164
|
- lib/cyoi/version.rb
|