knife-clc 0.0.1 → 0.0.2.pre
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 +4 -4
- data/README.md +62 -40
- data/lib/chef/knife/clc_ip_create.rb +1 -0
- data/lib/chef/knife/clc_server_create.rb +25 -528
- data/lib/clc/client.rb +1 -1
- data/lib/knife-clc/async/config_options.rb +18 -0
- data/lib/knife-clc/async.rb +11 -0
- data/lib/knife-clc/base/config_options.rb +26 -0
- data/lib/knife-clc/base.rb +56 -0
- data/lib/knife-clc/bootstrap/bootstrapper.rb +92 -0
- data/lib/knife-clc/bootstrap/config_options.rb +66 -0
- data/lib/knife-clc/bootstrap/connectivity_helper.rb +39 -0
- data/lib/knife-clc/bootstrap/methods/async_linux_package.rb +41 -0
- data/lib/knife-clc/bootstrap/methods/async_windows_package.rb +69 -0
- data/lib/knife-clc/bootstrap/methods/sync_linux_ssh.rb +67 -0
- data/lib/knife-clc/bootstrap/methods/sync_windows_winrm.rb +61 -0
- data/lib/knife-clc/bootstrap/subcommand_loader.rb +18 -0
- data/lib/knife-clc/bootstrap/validator.rb +149 -0
- data/lib/knife-clc/bootstrap.rb +20 -0
- data/lib/knife-clc/cloud_extensions/cloud_adapter.rb +35 -0
- data/lib/knife-clc/cloud_extensions.rb +11 -0
- data/lib/knife-clc/ip_assignment/config_options.rb +29 -0
- data/lib/knife-clc/ip_assignment/ip_assigner.rb +41 -0
- data/lib/knife-clc/ip_assignment/mapper.rb +20 -0
- data/lib/knife-clc/ip_assignment/validator.rb +74 -0
- data/lib/knife-clc/ip_assignment.rb +20 -0
- data/lib/knife-clc/server_launch/config_options.rb +145 -0
- data/lib/knife-clc/server_launch/mapper.rb +40 -0
- data/lib/knife-clc/server_launch/server_launcher.rb +40 -0
- data/lib/knife-clc/server_launch/validator.rb +100 -0
- data/lib/knife-clc/server_launch.rb +21 -0
- data/lib/knife-clc/version.rb +1 -1
- metadata +44 -4
@@ -0,0 +1,35 @@
|
|
1
|
+
module Knife
|
2
|
+
module Clc
|
3
|
+
module CloudExtensions
|
4
|
+
class CloudAdapter < SimpleDelegator
|
5
|
+
attr_reader :connection
|
6
|
+
|
7
|
+
def initialize(params)
|
8
|
+
@connection = params.fetch(:connection)
|
9
|
+
super(@connection)
|
10
|
+
end
|
11
|
+
|
12
|
+
def get_server_credentials(server)
|
13
|
+
creds_link = server['links'].find { |link| link['rel'] == 'credentials' }
|
14
|
+
connection.follow(creds_link) if creds_link
|
15
|
+
end
|
16
|
+
|
17
|
+
def ensure_server_powered_on(server)
|
18
|
+
return unless server['details']['powerState'] == 'stopped'
|
19
|
+
links = connection.power_on_server(server['id'])
|
20
|
+
connection.wait_for(links['operation']['id'])
|
21
|
+
end
|
22
|
+
|
23
|
+
def get_private_ip(server)
|
24
|
+
private_ips = server['details']['ipAddresses'].map { |addr| addr['internal'] }.compact
|
25
|
+
private_ips.first
|
26
|
+
end
|
27
|
+
|
28
|
+
def get_public_ip(server)
|
29
|
+
public_ips = server['details']['ipAddresses'].map { |addr| addr['public'] }.compact
|
30
|
+
public_ips.first
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Knife
|
2
|
+
module Clc
|
3
|
+
module IpAssignment
|
4
|
+
class ConfigOptions
|
5
|
+
def self.attach(command_class)
|
6
|
+
command_class.class_eval do
|
7
|
+
option :clc_allowed_protocols,
|
8
|
+
:long => '--allow PROTOCOL:FROM[-TO]',
|
9
|
+
:description => 'Assigns public IP with permissions for specified protocol',
|
10
|
+
:on => :head,
|
11
|
+
:proc => ->(param) do
|
12
|
+
Chef::Config[:knife][:clc_allowed_protocols] ||= []
|
13
|
+
Chef::Config[:knife][:clc_allowed_protocols] << param
|
14
|
+
end
|
15
|
+
|
16
|
+
option :clc_sources,
|
17
|
+
:long => '--source CIDR',
|
18
|
+
:description => 'The source IP address range allowed to access the new public IP address',
|
19
|
+
:on => :head,
|
20
|
+
:proc => ->(param) do
|
21
|
+
Chef::Config[:knife][:clc_sources] ||= []
|
22
|
+
Chef::Config[:knife][:clc_sources] << param
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require_relative 'validator'
|
2
|
+
require_relative 'mapper'
|
3
|
+
|
4
|
+
module Knife
|
5
|
+
module Clc
|
6
|
+
module IpAssignment
|
7
|
+
class IpAssigner
|
8
|
+
attr_reader :connection, :config, :errors
|
9
|
+
|
10
|
+
def initialize(params)
|
11
|
+
@connection = params.fetch(:connection)
|
12
|
+
@config = params.fetch(:config)
|
13
|
+
@errors = params.fetch(:errors)
|
14
|
+
end
|
15
|
+
|
16
|
+
# TODO: Params ordering dependency
|
17
|
+
def execute(server_id)
|
18
|
+
connection.create_ip_address(server_id, ip_params)
|
19
|
+
end
|
20
|
+
|
21
|
+
def prepare
|
22
|
+
validator.validate
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def ip_params
|
28
|
+
mapper.prepare_ip_params
|
29
|
+
end
|
30
|
+
|
31
|
+
def validator
|
32
|
+
@validator ||= Validator.new(:config => config, :errors => errors)
|
33
|
+
end
|
34
|
+
|
35
|
+
def mapper
|
36
|
+
@mapper ||= Mapper.new(:config => config, :errors => errors)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Knife
|
2
|
+
module Clc
|
3
|
+
module IpAssignment
|
4
|
+
class Mapper
|
5
|
+
attr_reader :config
|
6
|
+
|
7
|
+
def initialize(params)
|
8
|
+
@config = params.fetch(:config)
|
9
|
+
end
|
10
|
+
|
11
|
+
def prepare_ip_params
|
12
|
+
{
|
13
|
+
'ports' => config[:clc_allowed_protocols],
|
14
|
+
'sourceRestrictions' => config[:clc_sources]
|
15
|
+
}.delete_if { |_, value| value.nil? || value.empty? }
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
module Knife
|
2
|
+
module Clc
|
3
|
+
module IpAssignment
|
4
|
+
class Validator
|
5
|
+
attr_reader :config, :errors
|
6
|
+
|
7
|
+
def initialize(params)
|
8
|
+
@config = params.fetch(:config)
|
9
|
+
@errors = params.fetch(:errors)
|
10
|
+
end
|
11
|
+
|
12
|
+
def validate
|
13
|
+
parse_protocol_permissions
|
14
|
+
parse_sources
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def parse_protocol_permissions
|
20
|
+
permissions = config[:clc_allowed_protocols]
|
21
|
+
|
22
|
+
return unless permissions && permissions.any?
|
23
|
+
|
24
|
+
permissions.map! do |param|
|
25
|
+
protocol, port_range = param.split(':', 2)
|
26
|
+
|
27
|
+
case protocol.downcase
|
28
|
+
when 'ssh', 'sftp' then { 'protocol' => 'tcp', 'port' => 22 }
|
29
|
+
when 'rdp' then { 'protocol' => 'tcp', 'port' => 3389 }
|
30
|
+
when 'icmp' then { 'protocol' => 'icmp' }
|
31
|
+
when 'http' then [{ 'protocol' => 'tcp', 'port' => 80 }, { 'protocol' => 'tcp', 'port' => 8080 }]
|
32
|
+
when 'https' then { 'protocol' => 'tcp', 'port' => 443 }
|
33
|
+
when 'ftp' then { 'protocol' => 'tcp', 'port' => 21 }
|
34
|
+
when 'ftps' then { 'protocol' => 'tcp', 'port' => 990 }
|
35
|
+
when 'winrm' then [{ 'protocol' => 'tcp', 'port' => 5985 }, { 'protocol' => 'tcp', 'port' => 5986 }]
|
36
|
+
when 'udp', 'tcp'
|
37
|
+
unless port_range
|
38
|
+
errors << "No ports specified for #{param}"
|
39
|
+
else
|
40
|
+
ports = port_range.split('-').map do |port_string|
|
41
|
+
Integer(port_string) rescue nil
|
42
|
+
end
|
43
|
+
|
44
|
+
if ports.any?(&:nil?) || ports.size > 2 || ports.size < 1
|
45
|
+
errors << "Malformed port range for #{param}"
|
46
|
+
end
|
47
|
+
|
48
|
+
{
|
49
|
+
'protocol' => protocol.downcase,
|
50
|
+
'port' => ports[0],
|
51
|
+
'portTo' => ports[1]
|
52
|
+
}.keep_if { |_, value| value }
|
53
|
+
end
|
54
|
+
else
|
55
|
+
errors << "Unsupported protocol for #{param}"
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
permissions.flatten!
|
60
|
+
end
|
61
|
+
|
62
|
+
def parse_sources
|
63
|
+
sources = config[:clc_sources]
|
64
|
+
|
65
|
+
return unless sources && sources.any?
|
66
|
+
|
67
|
+
sources.map! do |cidr|
|
68
|
+
{ 'cidr' => cidr }
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require_relative 'ip_assignment/config_options'
|
2
|
+
require_relative 'ip_assignment/ip_assigner'
|
3
|
+
|
4
|
+
module Knife
|
5
|
+
module Clc
|
6
|
+
module IpAssignment
|
7
|
+
def self.included(command_class)
|
8
|
+
ConfigOptions.attach(command_class)
|
9
|
+
end
|
10
|
+
|
11
|
+
def ip_assigner
|
12
|
+
@ip_assigner ||= IpAssigner.new(
|
13
|
+
:connection => connection,
|
14
|
+
:config => config,
|
15
|
+
:errors => errors
|
16
|
+
)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,145 @@
|
|
1
|
+
module Knife
|
2
|
+
module Clc
|
3
|
+
module ServerLaunch
|
4
|
+
class ConfigOptions
|
5
|
+
def self.attach(command_class)
|
6
|
+
command_class.class_eval do
|
7
|
+
option :clc_name,
|
8
|
+
:long => '--name NAME',
|
9
|
+
:description => 'Name of the server to create',
|
10
|
+
:on => :head
|
11
|
+
|
12
|
+
option :clc_description,
|
13
|
+
:long => '--description DESCRIPTION',
|
14
|
+
:description => 'User-defined description of this server',
|
15
|
+
:on => :head
|
16
|
+
|
17
|
+
option :clc_group,
|
18
|
+
:long => '--group ID',
|
19
|
+
:description => 'ID of the parent group',
|
20
|
+
:on => :head
|
21
|
+
|
22
|
+
option :clc_source_server,
|
23
|
+
:long => '--source-server ID',
|
24
|
+
:description => 'ID of the server to use a source. May be the ID of a template, or when cloning, an existing server ID',
|
25
|
+
:on => :head
|
26
|
+
|
27
|
+
option :clc_managed,
|
28
|
+
:long => '--managed',
|
29
|
+
:boolean => true,
|
30
|
+
:description => 'Whether to create the server as managed or not',
|
31
|
+
:on => :head
|
32
|
+
|
33
|
+
option :clc_managed_backup,
|
34
|
+
:long => '--managed-backup',
|
35
|
+
:boolean => true,
|
36
|
+
:description => 'Whether to add managed backup to the server',
|
37
|
+
:on => :head
|
38
|
+
|
39
|
+
option :clc_primary_dns,
|
40
|
+
:long => '--primary-dns ADDRESS',
|
41
|
+
:description => 'Primary DNS to set on the server',
|
42
|
+
:on => :head
|
43
|
+
|
44
|
+
option :clc_secondary_dns,
|
45
|
+
:long => '--secondary-dns ADDRESS',
|
46
|
+
:description => 'Secondary DNS to set on the server',
|
47
|
+
:on => :head
|
48
|
+
|
49
|
+
option :clc_network,
|
50
|
+
:long => '--network ID',
|
51
|
+
:description => 'ID of the network to which to deploy the server',
|
52
|
+
:on => :head
|
53
|
+
|
54
|
+
option :clc_ip,
|
55
|
+
:long => '--ip ADDRESS',
|
56
|
+
:description => 'IP address to assign to the server',
|
57
|
+
:on => :head
|
58
|
+
|
59
|
+
option :clc_server_password,
|
60
|
+
:long => '--server-password PASSWORD',
|
61
|
+
:description => 'Password of administrator or root user on server',
|
62
|
+
:on => :head
|
63
|
+
|
64
|
+
option :clc_source_server_password,
|
65
|
+
:long => '--source-server-password PASSWORD',
|
66
|
+
:description => 'Password of the source server, used only when creating a clone from an existing server',
|
67
|
+
:on => :head
|
68
|
+
|
69
|
+
option :clc_cpu,
|
70
|
+
:long => '--cpu COUNT',
|
71
|
+
:description => 'Number of processors to configure the server with',
|
72
|
+
:on => :head
|
73
|
+
|
74
|
+
option :clc_cpu_autoscale_policy,
|
75
|
+
:long => '--cpu-autoscale-policy ID',
|
76
|
+
:description => 'ID of the vertical CPU Autoscale policy to associate the server with',
|
77
|
+
:on => :head
|
78
|
+
|
79
|
+
option :clc_memory,
|
80
|
+
:long => '--memory COUNT',
|
81
|
+
:description => 'Number of GB of memory to configure the server with',
|
82
|
+
:on => :head
|
83
|
+
|
84
|
+
option :clc_type,
|
85
|
+
:long => '--type TYPE',
|
86
|
+
:description => 'Whether to create a standard or hyperscale server',
|
87
|
+
:on => :head
|
88
|
+
|
89
|
+
option :clc_storage_type,
|
90
|
+
:long => '--storage-type TYPE',
|
91
|
+
:description => 'For standard servers, whether to use standard or premium storage',
|
92
|
+
:on => :head
|
93
|
+
|
94
|
+
option :clc_anti_affinity_policy,
|
95
|
+
:long => '--anti-affinity-policy ID',
|
96
|
+
:description => 'ID of the Anti-Affinity policy to associate the server with',
|
97
|
+
:on => :head
|
98
|
+
|
99
|
+
option :clc_custom_fields,
|
100
|
+
:long => '--custom-field KEY=VALUE',
|
101
|
+
:description => 'Custom field key-value pair',
|
102
|
+
:on => :head,
|
103
|
+
:proc => ->(param) do
|
104
|
+
Chef::Config[:knife][:clc_custom_fields] ||= []
|
105
|
+
Chef::Config[:knife][:clc_custom_fields] << param
|
106
|
+
end
|
107
|
+
|
108
|
+
option :clc_disks,
|
109
|
+
:long => '--disk PATH,SIZE,TYPE',
|
110
|
+
:description => 'Configuration for an additional server disk',
|
111
|
+
:on => :head,
|
112
|
+
:proc => ->(param) do
|
113
|
+
Chef::Config[:knife][:clc_disks] ||= []
|
114
|
+
Chef::Config[:knife][:clc_disks] << param
|
115
|
+
end
|
116
|
+
|
117
|
+
option :clc_ttl,
|
118
|
+
:long => '--ttl DATETIME',
|
119
|
+
:description => 'Date/time that the server should be deleted',
|
120
|
+
:on => :head
|
121
|
+
|
122
|
+
option :clc_packages,
|
123
|
+
:long => '--package ID,KEY_1=VALUE[,KEY_2=VALUE]',
|
124
|
+
:description => 'Package to run on the server after it has been built',
|
125
|
+
:on => :head,
|
126
|
+
:proc => ->(param) do
|
127
|
+
Chef::Config[:knife][:clc_packages] ||= []
|
128
|
+
Chef::Config[:knife][:clc_packages] << param
|
129
|
+
end
|
130
|
+
|
131
|
+
option :clc_configuration,
|
132
|
+
:long => '--configuration ID',
|
133
|
+
:description => 'Specifies the identifier for the specific configuration type of bare metal server to deploy',
|
134
|
+
:on => :head
|
135
|
+
|
136
|
+
option :clc_os_type,
|
137
|
+
:long => '--os-type TYPE',
|
138
|
+
:description => 'Specifies the OS to provision with the bare metal server',
|
139
|
+
:on => :head
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module Knife
|
2
|
+
module Clc
|
3
|
+
module ServerLaunch
|
4
|
+
class Mapper
|
5
|
+
attr_reader :config
|
6
|
+
|
7
|
+
def initialize(params)
|
8
|
+
@config = params.fetch(:config)
|
9
|
+
end
|
10
|
+
|
11
|
+
def prepare_launch_parameters
|
12
|
+
{
|
13
|
+
'name' => config[:clc_name],
|
14
|
+
'description' => config[:clc_description],
|
15
|
+
'groupId' => config[:clc_group],
|
16
|
+
'sourceServerId' => config[:clc_source_server],
|
17
|
+
'isManagedOS' => config[:clc_managed],
|
18
|
+
'isManagedBackup' => config[:clc_managed_backup],
|
19
|
+
'primaryDns' => config[:clc_primary_dns],
|
20
|
+
'secondaryDns' => config[:clc_secondary_dns],
|
21
|
+
'networkId' => config[:clc_network],
|
22
|
+
'ipAddress' => config[:clc_ip],
|
23
|
+
'password' => config[:clc_server_password],
|
24
|
+
'sourceServerPassword' => config[:clc_source_server_password],
|
25
|
+
'cpu' => config[:clc_cpu].to_i,
|
26
|
+
'cpuAutoscalePolicyId' => config[:clc_cpu_autoscale_policy],
|
27
|
+
'memoryGB' => config[:clc_memory].to_i,
|
28
|
+
'type' => config[:clc_type],
|
29
|
+
'storageType' => config[:clc_storage_type],
|
30
|
+
'antiAffinityPolicyId' => config[:clc_anti_affinity_policy],
|
31
|
+
'customFields' => config[:clc_custom_fields],
|
32
|
+
'additionalDisks' => config[:clc_disks],
|
33
|
+
'ttl' => config[:clc_ttl],
|
34
|
+
'packages' => config[:clc_packages],
|
35
|
+
}.delete_if { |_, value| !value.kind_of?(Integer) && (value.nil? || value.empty?) }
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require_relative 'validator'
|
2
|
+
require_relative 'mapper'
|
3
|
+
|
4
|
+
module Knife
|
5
|
+
module Clc
|
6
|
+
module ServerLaunch
|
7
|
+
class ServerLauncher
|
8
|
+
attr_reader :config, :connection, :errors
|
9
|
+
|
10
|
+
def initialize(params)
|
11
|
+
@config = params.fetch(:config)
|
12
|
+
@connection = params.fetch(:connection)
|
13
|
+
@errors = params.fetch(:errors)
|
14
|
+
end
|
15
|
+
|
16
|
+
def execute
|
17
|
+
connection.create_server(launch_parameters)
|
18
|
+
end
|
19
|
+
|
20
|
+
def prepare
|
21
|
+
validator.validate
|
22
|
+
end
|
23
|
+
|
24
|
+
def launch_parameters
|
25
|
+
@launch_parameters ||= mapper.prepare_launch_parameters
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def validator
|
31
|
+
@validator ||= Validator.new(:config => config, :errors => errors)
|
32
|
+
end
|
33
|
+
|
34
|
+
def mapper
|
35
|
+
@mapper ||= Mapper.new(:config => config)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,100 @@
|
|
1
|
+
module Knife
|
2
|
+
module Clc
|
3
|
+
module ServerLaunch
|
4
|
+
class Validator
|
5
|
+
attr_reader :config, :errors
|
6
|
+
|
7
|
+
def initialize(params)
|
8
|
+
@config = params.fetch(:config)
|
9
|
+
@errors = params.fetch(:errors)
|
10
|
+
end
|
11
|
+
|
12
|
+
def validate
|
13
|
+
unless config[:clc_name]
|
14
|
+
errors << 'Name is required'
|
15
|
+
end
|
16
|
+
|
17
|
+
unless config[:clc_group]
|
18
|
+
errors << 'Group ID is required'
|
19
|
+
end
|
20
|
+
|
21
|
+
unless config[:clc_source_server]
|
22
|
+
errors << 'Source server ID is required'
|
23
|
+
end
|
24
|
+
|
25
|
+
unless config[:clc_cpu]
|
26
|
+
errors << 'Number of CPUs is required'
|
27
|
+
end
|
28
|
+
|
29
|
+
unless config[:clc_memory]
|
30
|
+
errors << 'Number of memory GBs is required'
|
31
|
+
end
|
32
|
+
|
33
|
+
unless config[:clc_type]
|
34
|
+
errors << 'Type is required'
|
35
|
+
end
|
36
|
+
|
37
|
+
custom_fields = config[:clc_custom_fields]
|
38
|
+
if custom_fields && custom_fields.any?
|
39
|
+
parse_custom_fields(custom_fields)
|
40
|
+
end
|
41
|
+
|
42
|
+
disks = config[:clc_disks]
|
43
|
+
if disks && disks.any?
|
44
|
+
parse_disks(disks)
|
45
|
+
end
|
46
|
+
|
47
|
+
packages = config[:clc_packages]
|
48
|
+
if packages && packages.any?
|
49
|
+
parse_packages(packages)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
private
|
54
|
+
|
55
|
+
def parse_custom_fields(custom_fields)
|
56
|
+
custom_fields.map! do |param|
|
57
|
+
key, value = param.split('=', 2)
|
58
|
+
|
59
|
+
unless key && value
|
60
|
+
errors << "Custom field definition #{param} is malformed"
|
61
|
+
next
|
62
|
+
end
|
63
|
+
|
64
|
+
{ 'id' => key, 'value' => value }
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def parse_disks(disks)
|
69
|
+
disks.map! do |param|
|
70
|
+
path, size, type = param.split(',', 3)
|
71
|
+
|
72
|
+
unless path && size && type
|
73
|
+
errors << "Disk definition #{param} is malformed"
|
74
|
+
end
|
75
|
+
|
76
|
+
{ 'path' => path, 'sizeGB' => size, 'type' => type }
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def parse_packages(packages)
|
81
|
+
packages.map! do |param|
|
82
|
+
begin
|
83
|
+
id, raw_params = param.split(',', 2)
|
84
|
+
|
85
|
+
parsed_params = {}
|
86
|
+
raw_params.split(',').each do |raw_pair|
|
87
|
+
key, value = raw_pair.split('=', 2)
|
88
|
+
parsed_params[key] = value
|
89
|
+
end
|
90
|
+
|
91
|
+
{ 'packageId' => id, 'parameters' => parsed_params }
|
92
|
+
rescue Exception => e
|
93
|
+
errors << "Package definition #{param} is malformed"
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require_relative 'server_launch/config_options'
|
2
|
+
require_relative 'server_launch/server_launcher'
|
3
|
+
|
4
|
+
module Knife
|
5
|
+
module Clc
|
6
|
+
module ServerLaunch
|
7
|
+
def self.included(command_class)
|
8
|
+
ConfigOptions.attach(command_class)
|
9
|
+
end
|
10
|
+
|
11
|
+
def server_launcher
|
12
|
+
@server_launcher ||= ServerLauncher.new(
|
13
|
+
:config => config,
|
14
|
+
:ui => ui,
|
15
|
+
:connection => connection,
|
16
|
+
:errors => errors
|
17
|
+
)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/knife-clc/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: knife-clc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2.pre
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Sologub
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-
|
12
|
+
date: 2016-02-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: faraday
|
@@ -67,6 +67,20 @@ dependencies:
|
|
67
67
|
- - "~>"
|
68
68
|
- !ruby/object:Gem::Version
|
69
69
|
version: '12.0'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: knife-windows
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - "~>"
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: 1.2.0
|
77
|
+
type: :runtime
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - "~>"
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: 1.2.0
|
70
84
|
- !ruby/object:Gem::Dependency
|
71
85
|
name: webmock
|
72
86
|
requirement: !ruby/object:Gem::Requirement
|
@@ -222,6 +236,32 @@ files:
|
|
222
236
|
- lib/clc.rb
|
223
237
|
- lib/clc/client.rb
|
224
238
|
- lib/clc/cloud_exceptions.rb
|
239
|
+
- lib/knife-clc/async.rb
|
240
|
+
- lib/knife-clc/async/config_options.rb
|
241
|
+
- lib/knife-clc/base.rb
|
242
|
+
- lib/knife-clc/base/config_options.rb
|
243
|
+
- lib/knife-clc/bootstrap.rb
|
244
|
+
- lib/knife-clc/bootstrap/bootstrapper.rb
|
245
|
+
- lib/knife-clc/bootstrap/config_options.rb
|
246
|
+
- lib/knife-clc/bootstrap/connectivity_helper.rb
|
247
|
+
- lib/knife-clc/bootstrap/methods/async_linux_package.rb
|
248
|
+
- lib/knife-clc/bootstrap/methods/async_windows_package.rb
|
249
|
+
- lib/knife-clc/bootstrap/methods/sync_linux_ssh.rb
|
250
|
+
- lib/knife-clc/bootstrap/methods/sync_windows_winrm.rb
|
251
|
+
- lib/knife-clc/bootstrap/subcommand_loader.rb
|
252
|
+
- lib/knife-clc/bootstrap/validator.rb
|
253
|
+
- lib/knife-clc/cloud_extensions.rb
|
254
|
+
- lib/knife-clc/cloud_extensions/cloud_adapter.rb
|
255
|
+
- lib/knife-clc/ip_assignment.rb
|
256
|
+
- lib/knife-clc/ip_assignment/config_options.rb
|
257
|
+
- lib/knife-clc/ip_assignment/ip_assigner.rb
|
258
|
+
- lib/knife-clc/ip_assignment/mapper.rb
|
259
|
+
- lib/knife-clc/ip_assignment/validator.rb
|
260
|
+
- lib/knife-clc/server_launch.rb
|
261
|
+
- lib/knife-clc/server_launch/config_options.rb
|
262
|
+
- lib/knife-clc/server_launch/mapper.rb
|
263
|
+
- lib/knife-clc/server_launch/server_launcher.rb
|
264
|
+
- lib/knife-clc/server_launch/validator.rb
|
225
265
|
- lib/knife-clc/version.rb
|
226
266
|
homepage: https://github.com/CenturyLinkCloud/clc-knife
|
227
267
|
licenses:
|
@@ -238,9 +278,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
238
278
|
version: 2.0.0
|
239
279
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
240
280
|
requirements:
|
241
|
-
- - "
|
281
|
+
- - ">"
|
242
282
|
- !ruby/object:Gem::Version
|
243
|
-
version:
|
283
|
+
version: 1.3.1
|
244
284
|
requirements: []
|
245
285
|
rubyforge_project:
|
246
286
|
rubygems_version: 2.4.6
|