dtk-client 0.5.14 → 0.5.15
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 +5 -13
- data/lib/commands/common/thor/assembly_workspace.rb +95 -0
- data/lib/commands/common/thor/common.rb +7 -4
- data/lib/commands/common/thor/edit.rb +1 -1
- data/lib/commands/common/thor/inventory_parser.rb +78 -0
- data/lib/commands/common/thor/pull_from_remote.rb +14 -10
- data/lib/commands/common/thor/push_to_remote.rb +0 -21
- data/lib/commands/thor/account.rb +2 -2
- data/lib/commands/thor/component_module.rb +45 -42
- data/lib/commands/thor/library.rb +2 -1
- data/lib/commands/thor/provider.rb +42 -36
- data/lib/commands/thor/service.rb +39 -30
- data/lib/commands/thor/service_module.rb +59 -60
- data/lib/commands/thor/target.rb +85 -15
- data/lib/commands/thor/workspace.rb +1 -1
- data/lib/config/disk_cacher.rb +4 -1
- data/lib/configurator.rb +1 -8
- data/lib/core.rb +4 -2
- data/lib/domain/response.rb +13 -2
- data/lib/dtk-client/version.rb +1 -1
- data/lib/dtk_logger.rb +4 -4
- data/lib/shell/context.rb +96 -77
- data/lib/shell/help_monkey_patch.rb +19 -17
- data/lib/util/os_util.rb +12 -12
- data/lib/util/remote_dependency_util.rb +36 -0
- data/lib/util/ssh_util.rb +2 -1
- data/spec/component_module_spec.rb +34 -0
- data/spec/dtk_spec.rb +1 -1
- data/spec/node_template_spec.rb +0 -1
- data/spec/service_module_spec.rb +38 -0
- data/spec/service_spec.rb +20 -11
- metadata +12 -16
- data/spec/assembly_spec.rb +0 -50
- data/spec/assembly_template_spec.rb +0 -51
- data/spec/component_template_spec.rb +0 -40
- data/spec/module_spec.rb +0 -35
- data/spec/node_spec.rb +0 -43
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
OTQ3MGVkMDQ1NzY2YWJmNmNiZjJmZjFkMmVlYTA1Yjg4MzU5MzEzNg==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 988f4e6645da4af4e3907fe6ed38d8f457cd5d9c
|
4
|
+
data.tar.gz: ec2260330f913cf07d40f3ed455c8bb28003db04
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
MWFkMzc3ODdlYjJkZTI3ZWUxZGE5ZWVmZTk4NmZiODU0NGYzNWFjNzBmMTUx
|
11
|
-
MzRhZjJjNmIzODRhNmE1NjhkZTE5YjM4NjM1NzFmMWMzNGJkNjI=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
MDVmOTQ4MDZiNjVjOWQxODg5M2Y4YzFiODMzY2VmN2Q1YzZlYWIxMDk5MjNl
|
14
|
-
YjhmNTRkNzRmMjQ2NGQ3NjcyOWIwZDNhNjVjZDVmNjQ4NmI4YmNlNzIzNzU4
|
15
|
-
MGE0YTk2MzI0MDYwMDFiODUxOTQzODlhYzkzMDIyOWZhMzQzMzE=
|
6
|
+
metadata.gz: 96f830afde5b005ffa1f1998f4cb206dcda17a1e1c227f44405110976ae9cbc5d181a3094ab7f9d744b178fa9de8184f32cfa750f56cc02ad83ba972c3b219f5
|
7
|
+
data.tar.gz: 880b7ab10bbba7a5c2d9e33a43a9cc0a5056c48c92b15659cf5de44649bdea9659ca3795f6f26789deb00b88bcd4f1bed4395ba12c8f49a9e52b30982b23d14e
|
@@ -817,6 +817,101 @@ module DTK::Client
|
|
817
817
|
end
|
818
818
|
end
|
819
819
|
|
820
|
+
def execute_tests_v2_aux(context_params)
|
821
|
+
assembly_or_workspace_id,node_id = context_params.retrieve_arguments([REQ_ASSEMBLY_OR_WS_ID,:node_id],method_argument_names)
|
822
|
+
|
823
|
+
execute_test_tries = 30
|
824
|
+
execute_test_sleep = 1
|
825
|
+
|
826
|
+
if !options['timeout'].nil?
|
827
|
+
begin
|
828
|
+
execute_test_tries = Integer(options['timeout'])
|
829
|
+
rescue
|
830
|
+
raise DTK::Client::DtkValidationError, "Timeout value is not valid"
|
831
|
+
end
|
832
|
+
end
|
833
|
+
|
834
|
+
#Get list of components on particular node
|
835
|
+
post_body = {
|
836
|
+
:assembly_id => assembly_or_workspace_id,
|
837
|
+
:node_id => node_id,
|
838
|
+
:subtype => "instance",
|
839
|
+
:about => "components"
|
840
|
+
}
|
841
|
+
|
842
|
+
response = post(rest_url("assembly/info_about"),post_body)
|
843
|
+
|
844
|
+
components = []
|
845
|
+
if !response['data'].nil?
|
846
|
+
response['data'].each do |c|
|
847
|
+
components << c['display_name']
|
848
|
+
end
|
849
|
+
end
|
850
|
+
|
851
|
+
#Filter out request per specific component
|
852
|
+
#Filter works for two types of component notation provided: node/component and component
|
853
|
+
if !options["component"].nil?
|
854
|
+
components.reject! do |c|
|
855
|
+
if options["component"].include? "/"
|
856
|
+
c != options["component"]
|
857
|
+
else
|
858
|
+
c.split("/").last != options["component"]
|
859
|
+
end
|
860
|
+
end
|
861
|
+
end
|
862
|
+
components = nil if components.empty?
|
863
|
+
|
864
|
+
post_body = {
|
865
|
+
:assembly_id => assembly_or_workspace_id,
|
866
|
+
:node_id => node_id,
|
867
|
+
:components => components
|
868
|
+
}
|
869
|
+
|
870
|
+
response = post(rest_url("assembly/initiate_execute_tests_v2"),post_body)
|
871
|
+
|
872
|
+
raise DTK::Client::DtkValidationError, response.data(:errors).first if response.data(:errors)
|
873
|
+
return response unless response.ok?
|
874
|
+
|
875
|
+
action_results_id = response.data(:action_results_id)
|
876
|
+
end_loop, response, count, ret_only_if_complete = false, nil, 0, true
|
877
|
+
|
878
|
+
until end_loop do
|
879
|
+
post_body = {
|
880
|
+
:action_results_id => action_results_id,
|
881
|
+
:return_only_if_complete => ret_only_if_complete,
|
882
|
+
:disable_post_processing => false,
|
883
|
+
:sort_key => "module_name"
|
884
|
+
}
|
885
|
+
response = post(rest_url("assembly/get_action_results"),post_body)
|
886
|
+
count += 1
|
887
|
+
if count > execute_test_tries or response.data(:is_complete)
|
888
|
+
error_msg = ""
|
889
|
+
response.data(:results).each do |k,v|
|
890
|
+
unless v.nil?
|
891
|
+
error_msg << v['test_error'] if v.to_s.include?('test_error')
|
892
|
+
end
|
893
|
+
end
|
894
|
+
raise DTK::Client::DtkError, "Error while executing test script:\n" + error_msg + "Please fix test script with edit-component-module command and try again." unless error_msg.empty?
|
895
|
+
end_loop = true
|
896
|
+
else
|
897
|
+
#last time in loop return whetever is there
|
898
|
+
if count == execute_test_tries
|
899
|
+
ret_only_if_complete = false
|
900
|
+
end
|
901
|
+
sleep execute_test_sleep
|
902
|
+
end
|
903
|
+
end
|
904
|
+
|
905
|
+
if (response.data(:results).empty? && options['timeout'].nil?)
|
906
|
+
raise DTK::Client::DtkValidationError, "Could not finish execution of tests in default timeframe (#{execute_test_tries} seconds). Try again with passing --timeout TIMEOUT parameter"
|
907
|
+
elsif (response.data(:results).empty? && !options['timeout'].nil?)
|
908
|
+
raise DTK::Client::DtkValidationError, "Could not finish execution of tests in set timeframe (#{execute_test_tries} seconds). Try again with increasing --timeout TIMEOUT parameter"
|
909
|
+
else
|
910
|
+
response.set_data(*response.data(:results))
|
911
|
+
response.render_table(:execute_tests_data_v2)
|
912
|
+
end
|
913
|
+
end
|
914
|
+
|
820
915
|
def get_ps_aux(context_params)
|
821
916
|
get_ps_tries = 6
|
822
917
|
get_ps_sleep = 0.5
|
@@ -2,7 +2,7 @@ module DTK::Client
|
|
2
2
|
module CommonMixin
|
3
3
|
private
|
4
4
|
#returns module_name,repo_url,branch,not_ok_response( only if error)
|
5
|
-
def workspace_branch_info(module_type,module_id,version,opts={})
|
5
|
+
def workspace_branch_info(module_type, module_id, version, opts={})
|
6
6
|
if info = opts[:workspace_branch_info]
|
7
7
|
[info[:module_name],info[:repo_url],info[:branch]]
|
8
8
|
else
|
@@ -16,7 +16,7 @@ module DTK::Client
|
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
-
def get_workspace_branch_info_post_body(module_type,module_id,version_explicit,opts={})
|
19
|
+
def get_workspace_branch_info_post_body(module_type, module_id, version_explicit, opts={})
|
20
20
|
id_field = "#{module_type}_id"
|
21
21
|
post_body = {
|
22
22
|
id_field => module_id
|
@@ -31,7 +31,7 @@ module DTK::Client
|
|
31
31
|
post_body
|
32
32
|
end
|
33
33
|
|
34
|
-
def get_remote_module_info_aux(module_type,module_id,remote_namespace,version=nil)
|
34
|
+
def get_remote_module_info_aux(module_type, module_id, remote_namespace, version=nil, module_refs_content=nil)
|
35
35
|
id_field = "#{module_type}_id"
|
36
36
|
rsa_pub_value = SSHUtil.rsa_pub_key_content()
|
37
37
|
|
@@ -43,8 +43,11 @@ module DTK::Client
|
|
43
43
|
}
|
44
44
|
post_body.merge!(:version => version) if version
|
45
45
|
post_body.merge!(:remote_namespace => remote_namespace) if remote_namespace
|
46
|
+
post_body.merge!(:module_ref_content => module_refs_content) if module_refs_content && !module_refs_content.empty?
|
46
47
|
|
47
|
-
post(rest_url("#{module_type}/get_remote_module_info"),post_body)
|
48
|
+
response = post(rest_url("#{module_type}/get_remote_module_info"),post_body)
|
49
|
+
RemoteDependencyUtil.print_dependency_warnings(response)
|
50
|
+
response
|
48
51
|
end
|
49
52
|
|
50
53
|
end
|
@@ -80,7 +80,7 @@ module DTK::Client
|
|
80
80
|
if file_to_edit
|
81
81
|
"Would you like to commit changes to the file?"
|
82
82
|
else
|
83
|
-
"Would you like to commit
|
83
|
+
"Would you like to commit ALL the changes?"
|
84
84
|
end
|
85
85
|
confirmed_ok = Console.confirmation_prompt(confirm_msg)
|
86
86
|
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
dtk_require_from_base('configurator')
|
2
|
+
module DTK::Client
|
3
|
+
module InventoryParserMixin
|
4
|
+
private
|
5
|
+
|
6
|
+
def parse_inventory_file(file_path)
|
7
|
+
ssh_creds_path = ::DTK::Client::Configurator::NODE_SSH_CREDENTIALS
|
8
|
+
ssh_creds_data = parse_ssh_credentials_file(ssh_creds_path)
|
9
|
+
|
10
|
+
hash = validate_inventory_data(file_path)
|
11
|
+
|
12
|
+
ret = Hash.new
|
13
|
+
defaults = hash["defaults"]
|
14
|
+
|
15
|
+
hash["nodes"].each do |node_name, data|
|
16
|
+
display_name = data["name"]||node_name
|
17
|
+
ssh_credentials = data["ssh_credentials"]||defaults["ssh_credentials"]
|
18
|
+
|
19
|
+
raise DtkValidationError, "Credentials for '#{ssh_credentials}' does not exist in credentials file '#{ssh_creds_path}'" unless ssh_creds_data.include?(ssh_credentials)
|
20
|
+
|
21
|
+
ref = "physical--#{display_name}"
|
22
|
+
ret[ref] = {
|
23
|
+
:display_name => display_name,
|
24
|
+
:os_type => data["os_type"]||defaults["os_type"],
|
25
|
+
:managed => false,
|
26
|
+
:external_ref => {:type => "physical", :routable_host_address => node_name, :ssh_credentials => ssh_creds_data["#{ssh_credentials}"]}
|
27
|
+
}
|
28
|
+
end
|
29
|
+
|
30
|
+
ret
|
31
|
+
end
|
32
|
+
|
33
|
+
def parse_ssh_credentials_file(file_path)
|
34
|
+
begin
|
35
|
+
data = YAML.load_file(file_path)
|
36
|
+
rescue SyntaxError => e
|
37
|
+
raise DSLParsing::YAMLParsing.new("YAML parsing error #{e.message} in file", file_path)
|
38
|
+
end
|
39
|
+
|
40
|
+
data.each do |k,v|
|
41
|
+
raise DtkValidationError, "File: '#{file_path}'. Ssh credentials '#{k}' missing required field 'ssh_user'." unless v['ssh_user']
|
42
|
+
raise DtkValidationError, "File: '#{file_path}'. Ssh credentials '#{k}' should contain 'ssh_password' or 'sudo_password'." unless (v['ssh_password'] || v['sudo_password'])
|
43
|
+
end
|
44
|
+
|
45
|
+
data
|
46
|
+
end
|
47
|
+
|
48
|
+
def validate_inventory_data(file_path)
|
49
|
+
begin
|
50
|
+
data = YAML.load_file(file_path)
|
51
|
+
rescue SyntaxError => e
|
52
|
+
raise DSLParsing::YAMLParsing.new("YAML parsing error #{e.message} in file", file_path)
|
53
|
+
end
|
54
|
+
|
55
|
+
defaults = data['defaults']||[]
|
56
|
+
nodes = data['nodes']||[]
|
57
|
+
|
58
|
+
nodes.each do |k,v|
|
59
|
+
os_type = v['os_type']||defaults['os_type']
|
60
|
+
ssh_credentials = v['ssh_credentials']||defaults['ssh_credentials']
|
61
|
+
|
62
|
+
# os_type is required field and should be set through node specific fields or used from defaults
|
63
|
+
raise DtkValidationError, "Missing required field 'os_type' for node '#{k}'." unless os_type
|
64
|
+
|
65
|
+
# ssh_credentials is required field and should be set through node specific fields or used from defaults
|
66
|
+
raise DtkValidationError, "Missing required field 'ssh_credentials' for node '#{k}'." unless ssh_credentials
|
67
|
+
|
68
|
+
# currently we support 'ubuntu', 'centos, 'redhat' and 'debian' as os types and should be set through node specific field
|
69
|
+
# or used from defaults
|
70
|
+
raise DtkValidationError, "Os_type '#{os_type}' is not valid for node '#{k}'. Valid os types: #{ValidOsTypes}." unless ValidOsTypes.include?(os_type)
|
71
|
+
end
|
72
|
+
|
73
|
+
data
|
74
|
+
end
|
75
|
+
ValidOsTypes = ['ubuntu', 'centos', 'redhat', 'debian']
|
76
|
+
|
77
|
+
end
|
78
|
+
end
|
@@ -15,7 +15,7 @@ module DTK::Client
|
|
15
15
|
:remote_namespace? => remote_namespace,
|
16
16
|
:rsa_pub_key? => rsa_pub_key
|
17
17
|
)
|
18
|
-
response = post(rest_url("#{module_type}/get_remote_module_info"),post_body)
|
18
|
+
response = post(rest_url("#{module_type}/get_remote_module_info"),post_body)
|
19
19
|
return response unless response.ok?
|
20
20
|
module_name = response.data(:module_name)
|
21
21
|
remote_params = response.data_hash_form(:remote_repo_url,:remote_repo,:remote_branch)
|
@@ -23,7 +23,7 @@ module DTK::Client
|
|
23
23
|
|
24
24
|
# check and import component module dependencies before importing service itself
|
25
25
|
if (module_type == :service_module)
|
26
|
-
import_module_component_dependencies(module_id,remote_namespace)
|
26
|
+
import_module_component_dependencies(module_id,remote_namespace)
|
27
27
|
end
|
28
28
|
# check whether a local module exists to determine whether pull from local clone or try to pull from server
|
29
29
|
if Helper(:git_repo).local_clone_exists?(module_type,module_name,version)
|
@@ -44,12 +44,13 @@ module DTK::Client
|
|
44
44
|
def import_module_component_dependencies(module_id,remote_namespace=nil)
|
45
45
|
post_body = PostBody.new(
|
46
46
|
:service_module_id => module_id,
|
47
|
-
:remote_namespace? => remote_namespace
|
47
|
+
:remote_namespace? => remote_namespace,
|
48
|
+
:rsa_pub_key => SSHUtil.rsa_pub_key_content()
|
48
49
|
)
|
49
50
|
response = post(rest_url("service_module/resolve_pull_from_remote"),post_body)
|
50
51
|
|
51
52
|
print "Resolving dependencies please wait ... "
|
52
|
-
|
53
|
+
|
53
54
|
if (response.ok? && !(missing_components = response.data(:missing_modules)).empty?)
|
54
55
|
puts " New dependencies found, Installing."
|
55
56
|
|
@@ -58,9 +59,12 @@ module DTK::Client
|
|
58
59
|
else
|
59
60
|
puts 'Done.'
|
60
61
|
end
|
62
|
+
|
63
|
+
RemoteDependencyUtil.print_dependency_warnings(response)
|
64
|
+
nil
|
61
65
|
end
|
62
66
|
|
63
|
-
module PullFromRemote
|
67
|
+
module PullFromRemote
|
64
68
|
extend CommandBase
|
65
69
|
def self.perform_locally(cmd_obj,module_type,module_id,module_name,remote_params)
|
66
70
|
opts = remote_params
|
@@ -71,8 +75,8 @@ module DTK::Client
|
|
71
75
|
end
|
72
76
|
|
73
77
|
return response
|
74
|
-
|
75
|
-
# removing this for now, because we will use push-clone-changes as part of pull-from-remote command
|
78
|
+
|
79
|
+
# removing this for now, because we will use push-clone-changes as part of pull-from-remote command
|
76
80
|
# post_body = {
|
77
81
|
# id_field(module_type) => module_id,
|
78
82
|
# :commit_sha => response.data[:commit_sha],
|
@@ -91,12 +95,12 @@ module DTK::Client
|
|
91
95
|
}
|
92
96
|
post_body.merge!(:version => remote_params[:version]) if remote_params[:version]
|
93
97
|
response = post rest_url("#{module_type}/pull_from_remote"), post_body
|
94
|
-
|
95
|
-
|
98
|
+
|
99
|
+
|
96
100
|
puts "You have successfully pulled code on server instance." if response.ok?
|
97
101
|
response
|
98
102
|
end
|
99
|
-
|
103
|
+
|
100
104
|
def self.id_field(module_type)
|
101
105
|
"#{module_type}_id"
|
102
106
|
end
|
@@ -2,28 +2,7 @@ dtk_require_common_commands('thor/common')
|
|
2
2
|
module DTK::Client
|
3
3
|
module PushToRemoteMixin
|
4
4
|
|
5
|
-
##
|
6
|
-
#
|
7
|
-
# module_type: will be :component_module or :service_module
|
8
|
-
# def push_to_remote_aux(module_type,module_id, module_name,remote_namespace,version=nil)
|
9
5
|
def push_to_remote_aux(remote_module_info, module_type)
|
10
|
-
# commented out, because we perform this check before calling 'push_to_remote_aux' from service-module/component-module
|
11
|
-
# id_field = "#{module_type}_id"
|
12
|
-
|
13
|
-
# rsa_pub_value = SSHUtil.rsa_pub_key_content()
|
14
|
-
|
15
|
-
# post_body = {
|
16
|
-
# id_field => module_id,
|
17
|
-
# :rsa_pub_key => rsa_pub_value,
|
18
|
-
# :access_rights => "rw",
|
19
|
-
# :action => "push"
|
20
|
-
# }
|
21
|
-
# post_body.merge!(:version => version) if version
|
22
|
-
# post_body.merge!(:remote_namespace => remote_namespace) if remote_namespace
|
23
|
-
|
24
|
-
# response = post(rest_url("#{module_type}/get_remote_module_info"),post_body)
|
25
|
-
# return response unless response.ok?
|
26
|
-
|
27
6
|
returned_module_name = remote_module_info.data(:module_name)
|
28
7
|
version = remote_module_info.data(:version)
|
29
8
|
|
@@ -69,7 +69,7 @@ module DTK::Client
|
|
69
69
|
desc "set-password", "Change password for your dtk user account"
|
70
70
|
def set_password(context_params)
|
71
71
|
old_pass_prompt, old_pass, new_pass_prompt, confirm_pass_prompt = nil
|
72
|
-
cred_file = ::DTK::Client::Configurator
|
72
|
+
cred_file = ::DTK::Client::Configurator::CRED_FILE
|
73
73
|
old_pass = parse_key_value_file(cred_file)[:password]
|
74
74
|
username = parse_key_value_file(cred_file)[:username]
|
75
75
|
|
@@ -105,7 +105,7 @@ module DTK::Client
|
|
105
105
|
|
106
106
|
desc "list-ssh-keys", "Show list of key pairs that your account profile has saved"
|
107
107
|
def list_ssh_keys(context_params)
|
108
|
-
username = parse_key_value_file(::DTK::Client::Configurator
|
108
|
+
username = parse_key_value_file(::DTK::Client::Configurator::CRED_FILE)[:username]
|
109
109
|
post_body = {:username => username}
|
110
110
|
|
111
111
|
response = post rest_url("account/list_ssh_keys"), post_body
|