partial client merge
This commit is contained in:
parent
32b0d71693
commit
097bb265e3
@ -24,41 +24,27 @@ class DeployEnvEc2 < DeployEnv
|
||||
end
|
||||
|
||||
def set_subnets d
|
||||
if self.networks.nil?
|
||||
get_networks
|
||||
end
|
||||
unless self.options[:subnets].nil?
|
||||
self.options[:subnets] = [ self.options[:subnets][0] ]
|
||||
end
|
||||
vpc_id = nil
|
||||
set_parameter d, :subnets do
|
||||
if self.networks.any?
|
||||
num = choose_number_from_list(I18n.t("handler.project.create.subnet.ec2"), self.networks, self.networks_table, -1)
|
||||
vpc_id = self.networks[num]["vpcId"] unless num == -1
|
||||
num == -1 ? [] : [ self.networks[num]["subnetId"] ]
|
||||
networks, networks_table = fetcher.fetch_with_table('network', self.provider)
|
||||
if networks.any?
|
||||
num = choose_number_from_list(I18n.t("handler.project.create.subnet.ec2"), networks, networks_table, -1)
|
||||
vpc_id = networks[num]["vpcId"] unless num == -1
|
||||
num == -1 ? [] : [ networks[num]["subnetId"] ]
|
||||
else
|
||||
[]
|
||||
end
|
||||
end
|
||||
return vpc_id
|
||||
end
|
||||
|
||||
def get_groups vpcId
|
||||
g = Group.new(@host, self.options)
|
||||
g.auth = self.auth
|
||||
p = ["group", "list", provider]
|
||||
p.push vpcId if !vpcId.nil?
|
||||
self.groups = g.list_handler(p)
|
||||
self.groups_table = g.table
|
||||
vpc_id
|
||||
end
|
||||
|
||||
def set_groups d, vpc_id
|
||||
if self.groups.nil?
|
||||
get_groups(vpc_id)
|
||||
end
|
||||
set_parameter d, :groups do
|
||||
list = groups.keys
|
||||
choose_indexes_from_list(I18n.t("options.project.create.groups"), list, self.groups_table, "default", list.index("default")).map{|i| list[i]}
|
||||
groups = resources_selector.select_available_groups(provider: self.provider, vpc_id: vpc_id)
|
||||
groups.map{|t| t['id']}
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@ -3,6 +3,7 @@ require "devops-client/handler/deploy_envs/deploy_env"
|
||||
class DeployEnvOpenstack < DeployEnv
|
||||
|
||||
NAME = "openstack"
|
||||
attr_accessor :networks, :networks_table
|
||||
|
||||
def initialize host, options, auth
|
||||
@host = host
|
||||
@ -24,33 +25,19 @@ class DeployEnvOpenstack < DeployEnv
|
||||
end
|
||||
|
||||
def set_subnets d
|
||||
networks, tn = nil, nil
|
||||
if self.networks.nil?
|
||||
get_networks
|
||||
end
|
||||
set_parameter d, :subnets do
|
||||
s = []
|
||||
begin
|
||||
s = choose_indexes_from_list(I18n.t("handler.project.create.subnet.openstack"), self.networks, self.networks_table).map{|i| self.networks[i]["name"]}
|
||||
s = resources_selector.select_available_network(table_title: I18n.t("handler.project.create.subnet.openstack"), provider: self.provider)
|
||||
end while s.empty?
|
||||
s
|
||||
end
|
||||
end
|
||||
|
||||
def get_groups
|
||||
g = Group.new(@host, self.options)
|
||||
g.auth = self.auth
|
||||
self.groups = g.list_handler(["group", "list", self.provider])
|
||||
self.groups_table = g.table
|
||||
end
|
||||
|
||||
def set_groups d
|
||||
if self.groups.nil?
|
||||
get_groups
|
||||
end
|
||||
set_parameter d, :groups do
|
||||
list = groups.keys
|
||||
choose_indexes_from_list(I18n.t("options.project.create.groups"), list, self.groups_table, "default", list.index("default")).map{|i| list[i]}
|
||||
groups = resources_selector.select_available_groups(provider: self.provider)
|
||||
groups.map{|t| t['id']}
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@ -95,4 +95,8 @@ protected
|
||||
end
|
||||
end
|
||||
|
||||
def current_command
|
||||
ARGV[1].to_sym if ARGV[1]
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@ -13,7 +13,6 @@ class Key < Handler
|
||||
end
|
||||
|
||||
def handle
|
||||
current_command = ARGV[1].to_sym
|
||||
@options, @args = @options_parser.parse_options_for!(current_command)
|
||||
case current_command
|
||||
when :list
|
||||
|
||||
@ -13,7 +13,6 @@ class Server < Handler
|
||||
end
|
||||
|
||||
def handle
|
||||
current_command = ARGV[1].to_sym
|
||||
@options, @args = @options_parser.parse_options_for!(current_command)
|
||||
case current_command
|
||||
when :list
|
||||
|
||||
Loading…
Reference in New Issue
Block a user