dtk-client 0.5.13 → 0.5.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/dtk-client.gemspec +1 -1
- data/lib/command_helpers/service_importer.rb +1 -1
- data/lib/commands/common/thor/access_control.rb +54 -0
- data/lib/commands/common/thor/assembly_workspace.rb +1 -1
- data/lib/commands/thor/component_module.rb +59 -41
- data/lib/commands/thor/dtk.rb +6 -1
- data/lib/commands/thor/provider.rb +1 -1
- data/lib/commands/thor/service.rb +9 -5
- data/lib/commands/thor/service_module.rb +58 -1
- data/lib/commands/thor/target.rb +21 -0
- data/lib/core.rb +2 -0
- data/lib/domain/git_adapter.rb +1 -1
- data/lib/dtk-client/version.rb +1 -1
- data/lib/shell/context.rb +2 -2
- data/lib/util/common_util.rb +20 -0
- data/lib/util/os_util.rb +8 -3
- data/lib/util/permission_util.rb +14 -0
- metadata +7 -3
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ODg5ZmJhZjg4YWIxZGY3YmQ5OWY5OTE4NDFiYmFmOWMzNWQ2ODk3NQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
OTQ3MGVkMDQ1NzY2YWJmNmNiZjJmZjFkMmVlYTA1Yjg4MzU5MzEzNg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ODdkYWU3NGJlZWFjNDgyOWJhODZkY2I2ZmFlNWMzYzYyODAwNzY4NDAxMjk4
|
10
|
+
MWFkMzc3ODdlYjJkZTI3ZWUxZGE5ZWVmZTk4NmZiODU0NGYzNWFjNzBmMTUx
|
11
|
+
MzRhZjJjNmIzODRhNmE1NjhkZTE5YjM4NjM1NzFmMWMzNGJkNjI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MDVmOTQ4MDZiNjVjOWQxODg5M2Y4YzFiODMzY2VmN2Q1YzZlYWIxMDk5MjNl
|
14
|
+
YjhmNTRkNzRmMjQ2NGQ3NjcyOWIwZDNhNjVjZDVmNjQ4NmI4YmNlNzIzNzU4
|
15
|
+
MGE0YTk2MzI0MDYwMDFiODUxOTQzODlhYzkzMDIyOWZhMzQzMzE=
|
data/dtk-client.gemspec
CHANGED
@@ -4,7 +4,7 @@ require File.expand_path('../lib/dtk-client/version', __FILE__)
|
|
4
4
|
Gem::Specification.new do |gem|
|
5
5
|
gem.authors = ["Rich PELAVIN"]
|
6
6
|
gem.email = ["rich@reactor8.com"]
|
7
|
-
gem.description = %q{
|
7
|
+
gem.description = %q{The DTK Client is a command line tool to interact with your DTK Server and DTK Service Catalog instance(s).}
|
8
8
|
gem.summary = %q{DTK CLI client for DTK server interaction.}
|
9
9
|
gem.homepage = "https://github.com/rich-reactor8/dtk-client"
|
10
10
|
gem.licenses = ["GPL-3.0"]
|
@@ -24,7 +24,7 @@ module DTK::Client
|
|
24
24
|
|
25
25
|
unless does_not_exist.empty?
|
26
26
|
module_names = does_not_exist.collect{|x| "#{x['namespace']}/#{x['name']}"}
|
27
|
-
OsUtil.print("
|
27
|
+
OsUtil.print("You do no have access to component modules '#{module_names}' required by service module, or they do not exist on repo manager and will not be imported!", :yellow)
|
28
28
|
return false unless Console.confirmation_prompt("Do you want to continue with import of available component modules and service module"+'?')
|
29
29
|
end
|
30
30
|
|
@@ -0,0 +1,54 @@
|
|
1
|
+
module DTK::Client
|
2
|
+
module AccessControlMixin
|
3
|
+
|
4
|
+
def chmod_aux(module_id, permission_string, namespace = nil)
|
5
|
+
permission_selector = PermissionUtil.validate_permissions!(permission_string.downcase)
|
6
|
+
post_body = {
|
7
|
+
:module_id => module_id,
|
8
|
+
:permission_selector => permission_selector,
|
9
|
+
:rsa_pub_key => SSHUtil.rsa_pub_key_content(),
|
10
|
+
:remote_module_namespace => namespace
|
11
|
+
}
|
12
|
+
post rest_url("#{resolve_module_type}/remote_chmod"), post_body
|
13
|
+
end
|
14
|
+
|
15
|
+
def chown_aux(module_id, remote_user, namespace = nil)
|
16
|
+
post_body = {
|
17
|
+
:module_id => module_id,
|
18
|
+
:remote_user => remote_user,
|
19
|
+
:rsa_pub_key => SSHUtil.rsa_pub_key_content(),
|
20
|
+
:remote_module_namespace => namespace
|
21
|
+
}
|
22
|
+
post rest_url("#{resolve_module_type}/remote_chown"), post_body
|
23
|
+
end
|
24
|
+
|
25
|
+
def collaboration_aux(action, module_id, users, groups, namespace = nil)
|
26
|
+
raise DtkValidationError, "You must provide --users or --groups to this command" if users.nil? && groups.nil?
|
27
|
+
post_body = {
|
28
|
+
:module_id => module_id,
|
29
|
+
:users => users,
|
30
|
+
:groups => groups,
|
31
|
+
:action => action,
|
32
|
+
:remote_module_namespace => namespace,
|
33
|
+
:rsa_pub_key => SSHUtil.rsa_pub_key_content()
|
34
|
+
}
|
35
|
+
post rest_url("#{resolve_module_type}/remote_collaboration"), post_body
|
36
|
+
end
|
37
|
+
|
38
|
+
def collaboration_list_aux(module_id, namespace = nil)
|
39
|
+
post_body = {
|
40
|
+
:module_id => module_id,
|
41
|
+
:remote_module_namespace => namespace,
|
42
|
+
:rsa_pub_key => SSHUtil.rsa_pub_key_content()
|
43
|
+
}
|
44
|
+
post rest_url("#{resolve_module_type}/list_remote_collaboration"), post_body
|
45
|
+
end
|
46
|
+
|
47
|
+
private
|
48
|
+
|
49
|
+
def resolve_module_type
|
50
|
+
self.class == DTK::Client::ComponentModule ? 'component_module' : 'service_module'
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
end
|
@@ -569,7 +569,7 @@ module DTK::Client
|
|
569
569
|
post_body.merge!(:value => value) if value
|
570
570
|
post_body.merge!(:required => true) if options.required?
|
571
571
|
post_body.merge!(:dynamic => true) if options.dynamic?
|
572
|
-
if datatype = options
|
572
|
+
if datatype = options['type']
|
573
573
|
post_body.merge!(:datatype => datatype)
|
574
574
|
end
|
575
575
|
post rest_url("assembly/set_attributes"), post_body
|
@@ -3,6 +3,7 @@ dtk_require_common_commands('thor/list_diffs')
|
|
3
3
|
dtk_require_common_commands('thor/push_to_remote')
|
4
4
|
dtk_require_common_commands('thor/pull_from_remote')
|
5
5
|
dtk_require_common_commands('thor/push_clone_changes')
|
6
|
+
dtk_require_common_commands('thor/access_control')
|
6
7
|
dtk_require_common_commands('thor/edit')
|
7
8
|
dtk_require_common_commands('thor/reparse')
|
8
9
|
dtk_require_common_commands('thor/purge_clone')
|
@@ -71,6 +72,7 @@ module DTK::Client
|
|
71
72
|
include PurgeCloneMixin
|
72
73
|
include ListDiffsMixin
|
73
74
|
include ServiceImporter
|
75
|
+
include AccessControlMixin
|
74
76
|
|
75
77
|
def get_module_name(module_id)
|
76
78
|
get_name_from_id_helper(module_id)
|
@@ -539,47 +541,6 @@ TODO: might deprecate
|
|
539
541
|
return response
|
540
542
|
end
|
541
543
|
|
542
|
-
# commented out for now -> changed to push but leaving commented out if run into some issues with push
|
543
|
-
# # desc "COMPONENT-MODULE-NAME/ID push-to-dtkn [-n NAMESPACE] [-v VERSION]", "Push local copy of component module to remote repository."
|
544
|
-
# # version_method_option
|
545
|
-
# desc "COMPONENT-MODULE-NAME/ID push-to-dtkn [-n NAMESPACE]", "Push local copy of component module to remote repository."
|
546
|
-
# method_option "namespace",:aliases => "-n",
|
547
|
-
# :type => :string,
|
548
|
-
# :banner => "NAMESPACE",
|
549
|
-
# :desc => "Remote namespace"
|
550
|
-
# def push_to_dtkn(context_params)
|
551
|
-
# component_module_id, component_module_name = context_params.retrieve_arguments([:component_module_id!, :component_module_name!],method_argument_names)
|
552
|
-
# version = options["version"]
|
553
|
-
|
554
|
-
# if component_module_name.to_s =~ /^[0-9]+$/
|
555
|
-
# component_module_id = component_module_name
|
556
|
-
# component_module_name = get_module_name(component_module_id)
|
557
|
-
# end
|
558
|
-
|
559
|
-
# modules_path = OsUtil.module_clone_location()
|
560
|
-
# module_location = "#{modules_path}/#{component_module_name}#{version && "-#{version}"}"
|
561
|
-
|
562
|
-
# unless File.directory?(module_location)
|
563
|
-
# if Console.confirmation_prompt("Unable to push to remote because module '#{component_module_name}#{version && "-#{version}"}' has not been cloned. Would you like to clone module now"+'?')
|
564
|
-
# response = clone_aux(:component_module,component_module_id,version,false)
|
565
|
-
|
566
|
-
# if(response.nil? || response.ok?)
|
567
|
-
# reparse_aux(module_location)
|
568
|
-
# push_to_remote_aux(:component_module, component_module_id, component_module_name, options["namespace"], version) if Console.confirmation_prompt("Would you like to push changes to remote"+'?')
|
569
|
-
# end
|
570
|
-
|
571
|
-
# return response
|
572
|
-
# else
|
573
|
-
# # user choose not to clone needed module
|
574
|
-
# return
|
575
|
-
# end
|
576
|
-
# end
|
577
|
-
|
578
|
-
# reparse_aux(module_location)
|
579
|
-
# push_to_remote_aux(:component_module, component_module_id, component_module_name, options["namespace"], version)
|
580
|
-
# end
|
581
|
-
|
582
|
-
# desc "COMPONENT-MODULE-NAME/ID pull-from-dtkn [-n NAMESPACE] [-v VERSION]", "Update local component module from remote repository."
|
583
544
|
desc "COMPONENT-MODULE-NAME/ID pull-dtkn [-n NAMESPACE]", "Update local component module from remote repository."
|
584
545
|
method_option "namespace",:aliases => "-n",
|
585
546
|
:type => :string,
|
@@ -615,8 +576,65 @@ TODO: might deprecate
|
|
615
576
|
raise DtkValidationError, "You have to provide valid catalog to pull changes from! Valid catalogs: #{PullCatalogs}"
|
616
577
|
end
|
617
578
|
end
|
579
|
+
|
618
580
|
PullCatalogs = ["dtkn"]
|
619
581
|
|
582
|
+
desc "COMPONENT-MODULE-NAME/ID chown REMOTE-USER", "Set remote module owner"
|
583
|
+
method_option "namespace", :aliases => "-n", :type => :string, :banner => "NAMESPACE", :desc => "Remote namespace"
|
584
|
+
def chown(context_params)
|
585
|
+
component_module_id, remote_user = context_params.retrieve_arguments([:component_module_id!,:option_1!],method_argument_names)
|
586
|
+
chown_aux(component_module_id, remote_user, options.namespace)
|
587
|
+
end
|
588
|
+
|
589
|
+
desc "COMPONENT-MODULE-NAME/ID chmod PERMISSION-SELECTOR", "Update remote permissions e.g. ug+rw , user and group get RW permissions"
|
590
|
+
method_option "namespace", :aliases => "-n", :type => :string, :banner => "NAMESPACE", :desc => "Remote namespace"
|
591
|
+
def chmod(context_params)
|
592
|
+
component_module_id, permission_selector = context_params.retrieve_arguments([:component_module_id!,:option_1!],method_argument_names)
|
593
|
+
chmod_aux(component_module_id, permission_selector, options.namespace)
|
594
|
+
end
|
595
|
+
|
596
|
+
desc "COMPONENT-MODULE-NAME/ID make-public", "Make this module public"
|
597
|
+
method_option "namespace", :aliases => "-n", :type => :string, :banner => "NAMESPACE", :desc => "Remote namespace"
|
598
|
+
def make_public(context_params)
|
599
|
+
component_module_id = context_params.retrieve_arguments([:component_module_id!],method_argument_names)
|
600
|
+
chmod_aux(component_module_id, "o+r", options.namespace)
|
601
|
+
end
|
602
|
+
|
603
|
+
desc "COMPONENT-MODULE-NAME/ID make-private", "Make this module private"
|
604
|
+
method_option "namespace", :aliases => "-n", :type => :string, :banner => "NAMESPACE", :desc => "Remote namespace"
|
605
|
+
def make_private(context_params)
|
606
|
+
component_module_id = context_params.retrieve_arguments([:component_module_id!],method_argument_names)
|
607
|
+
chmod_aux(component_module_id, "o-rwd", options.namespace)
|
608
|
+
end
|
609
|
+
|
610
|
+
desc "COMPONENT-MODULE-NAME/ID add-collaborators", "Add collabrators users or groups comma seperated (--users or --groups)"
|
611
|
+
method_option "namespace", :aliases => "-n", :type => :string, :banner => "NAMESPACE", :desc => "Remote namespace"
|
612
|
+
method_option "users",:aliases => "-u", :type => :string, :banner => "USERS", :desc => "User collabrators"
|
613
|
+
method_option "groups",:aliases => "-g", :type => :string, :banner => "GROUPS", :desc => "Group collabrators"
|
614
|
+
def add_collaborators(context_params)
|
615
|
+
component_module_id = context_params.retrieve_arguments([:component_module_id!],method_argument_names)
|
616
|
+
collaboration_aux(:add, component_module_id, options.users, options.groups, options.namespace)
|
617
|
+
end
|
618
|
+
|
619
|
+
desc "COMPONENT-MODULE-NAME/ID remove-collaborators", "Remove collabrators users or groups comma seperated (--users or --groups)"
|
620
|
+
method_option "namespace",:aliases => "-n",:type => :string, :banner => "NAMESPACE", :desc => "Remote namespace"
|
621
|
+
method_option "users",:aliases => "-u", :type => :string, :banner => "USERS", :desc => "User collabrators"
|
622
|
+
method_option "groups",:aliases => "-g", :type => :string, :banner => "GROUPS", :desc => "Group collabrators"
|
623
|
+
def remove_collaborators(context_params)
|
624
|
+
component_module_id = context_params.retrieve_arguments([:component_module_id!],method_argument_names)
|
625
|
+
collaboration_aux(:remove, component_module_id, options.users, options.groups, options.namespace)
|
626
|
+
end
|
627
|
+
|
628
|
+
desc "COMPONENT-MODULE-NAME/ID list-collaborators", "List collaborators for given module"
|
629
|
+
method_option "namespace",:aliases => "-n",:type => :string, :banner => "NAMESPACE", :desc => "Remote namespace"
|
630
|
+
def list_collaborators(context_params)
|
631
|
+
component_module_id = context_params.retrieve_arguments([:component_module_id!],method_argument_names)
|
632
|
+
response = collaboration_list_aux(component_module_id, options.namespace)
|
633
|
+
response.render_table(:module_collaborators)
|
634
|
+
response
|
635
|
+
end
|
636
|
+
|
637
|
+
|
620
638
|
#### end: commands to interact with remote repo ###
|
621
639
|
|
622
640
|
#### commands to manage workspace and versioning ###
|
data/lib/commands/thor/dtk.rb
CHANGED
@@ -6,13 +6,18 @@ module DTK::Client
|
|
6
6
|
|
7
7
|
# entities that are not available on root but later in n-context
|
8
8
|
def self.additional_entities()
|
9
|
-
['
|
9
|
+
['component','attribute','utils','node','task','component-template','assembly']
|
10
10
|
end
|
11
11
|
|
12
12
|
desc "workspace","Sandbox for development and testing"
|
13
13
|
def workspace
|
14
14
|
# API descriptor, SYM_LINK!
|
15
15
|
end
|
16
|
+
|
17
|
+
desc "target","Targets"
|
18
|
+
def target
|
19
|
+
# API descriptor, SYM_LINK!
|
20
|
+
end
|
16
21
|
|
17
22
|
|
18
23
|
# NOTE
|
@@ -25,7 +25,7 @@ module DTK::Client
|
|
25
25
|
:identifier_only => {
|
26
26
|
:target => [
|
27
27
|
['list-nodes',"list-nodes","# Lists node instances in given targets."],
|
28
|
-
['list-
|
28
|
+
['list-services',"list-services","# Lists assembly instances in given targets."]
|
29
29
|
]
|
30
30
|
}
|
31
31
|
})
|
@@ -439,7 +439,8 @@ TODO: will put in dot release and will rename to 'extend'
|
|
439
439
|
# post rest_url("assembly/list_smoketests"), post_body
|
440
440
|
#end
|
441
441
|
|
442
|
-
desc "SERVICE-NAME/ID grant-access SYS-USER NAME [PATH-TO-PUB-KEY]", "Grant access to given service and its nodes"
|
442
|
+
desc "SERVICE-NAME/ID grant-access SYS-USER NAME [PATH-TO-PUB-KEY] [--nodes NODE-NAMES]", "Grant access to given service and its nodes"
|
443
|
+
method_option :nodes, :type => :string, :default => nil
|
443
444
|
def grant_access(context_params)
|
444
445
|
service_id, system_user, rsa_key_name, path_to_rsa_pub_key = context_params.retrieve_arguments([:service_id!,:option_1!, :option_2!, :option_3],method_argument_names)
|
445
446
|
|
@@ -451,7 +452,8 @@ TODO: will put in dot release and will rename to 'extend'
|
|
451
452
|
:system_user => system_user,
|
452
453
|
:rsa_pub_name => rsa_key_name,
|
453
454
|
:rsa_pub_key => rsa_pub_key_content,
|
454
|
-
:assembly_id => service_id
|
455
|
+
:assembly_id => service_id,
|
456
|
+
:target_nodes => options.nodes
|
455
457
|
}
|
456
458
|
|
457
459
|
return response unless response.ok?
|
@@ -463,15 +465,17 @@ TODO: will put in dot release and will rename to 'extend'
|
|
463
465
|
nil
|
464
466
|
end
|
465
467
|
|
466
|
-
desc "SERVICE-NAME/ID revoke-access SYS-USER NAME", "Revoke access to given service and its nodes"
|
468
|
+
desc "SERVICE-NAME/ID revoke-access SYS-USER NAME [--nodes NODE-NAMES]", "Revoke access to given service and its nodes"
|
469
|
+
method_option :nodes, :type => :string, :default => nil
|
467
470
|
def revoke_access(context_params)
|
468
471
|
service_id, system_user, rsa_key_name = context_params.retrieve_arguments([:service_id!,:option_1!, :option_2!],method_argument_names)
|
469
|
-
|
472
|
+
|
470
473
|
response = post_file rest_url("assembly/initiate_ssh_pub_access"), {
|
471
474
|
:agent_action => :revoke_access,
|
472
475
|
:system_user => system_user,
|
473
476
|
:rsa_pub_name => rsa_key_name,
|
474
|
-
:assembly_id => service_id
|
477
|
+
:assembly_id => service_id,
|
478
|
+
:target_nodes => options.nodes
|
475
479
|
}
|
476
480
|
|
477
481
|
return response unless response.ok?
|
@@ -5,6 +5,7 @@ dtk_require_common_commands('thor/clone')
|
|
5
5
|
dtk_require_common_commands('thor/push_to_remote')
|
6
6
|
dtk_require_common_commands('thor/pull_from_remote')
|
7
7
|
dtk_require_common_commands('thor/push_clone_changes')
|
8
|
+
dtk_require_common_commands('thor/access_control')
|
8
9
|
dtk_require_common_commands('thor/edit')
|
9
10
|
dtk_require_common_commands('thor/reparse')
|
10
11
|
dtk_require_from_base("dtk_logger")
|
@@ -27,6 +28,7 @@ module DTK::Client
|
|
27
28
|
include ReparseMixin
|
28
29
|
include ServiceImporter
|
29
30
|
include PurgeCloneMixin
|
31
|
+
include AccessControlMixin
|
30
32
|
|
31
33
|
def get_service_module_name(service_module_id)
|
32
34
|
get_name_from_id_helper(service_module_id)
|
@@ -107,7 +109,7 @@ module DTK::Client
|
|
107
109
|
|
108
110
|
desc "SERVICE-MODULE-NAME/ID list-component-modules","List component modules associated with service module."
|
109
111
|
method_option :remote, :type => :boolean, :default => false
|
110
|
-
def
|
112
|
+
def list_component_modules(context_params)
|
111
113
|
context_params.method_arguments = ["modules"]
|
112
114
|
list(context_params)
|
113
115
|
end
|
@@ -387,6 +389,61 @@ module DTK::Client
|
|
387
389
|
end
|
388
390
|
PullCatalogs = ["dtkn"]
|
389
391
|
|
392
|
+
desc "SERVICE-MODULE-NAME/ID chown REMOTE-USER", "Set remote module owner"
|
393
|
+
method_option "namespace", :aliases => "-n", :type => :string, :banner => "NAMESPACE", :desc => "Remote namespace"
|
394
|
+
def chown(context_params)
|
395
|
+
service_module_id, remote_user = context_params.retrieve_arguments([:service_module_id!,:option_1!],method_argument_names)
|
396
|
+
chown_aux(service_module_id, remote_user, options.namespace)
|
397
|
+
end
|
398
|
+
|
399
|
+
desc "SERVICE-MODULE-NAME/ID chmod PERMISSION-SELECTOR", "Update remote permissions e.g. ug+rw , user and group get RW permissions"
|
400
|
+
method_option "namespace", :aliases => "-n", :type => :string, :banner => "NAMESPACE", :desc => "Remote namespace"
|
401
|
+
def chmod(context_params)
|
402
|
+
service_module_id, permission_selector = context_params.retrieve_arguments([:service_module_id!,:option_1!],method_argument_names)
|
403
|
+
chmod_aux(service_module_id, permission_selector, options.namespace)
|
404
|
+
end
|
405
|
+
|
406
|
+
desc "SERVICE-MODULE-NAME/ID make-public", "Make this module public"
|
407
|
+
method_option "namespace", :aliases => "-n", :type => :string, :banner => "NAMESPACE", :desc => "Remote namespace"
|
408
|
+
def make_public(context_params)
|
409
|
+
service_module_id = context_params.retrieve_arguments([:service_module_id!],method_argument_names)
|
410
|
+
chmod_aux(service_module_id, "o+r", options.namespace)
|
411
|
+
end
|
412
|
+
|
413
|
+
desc "SERVICE-MODULE-NAME/ID make-private", "Make this module private"
|
414
|
+
method_option "namespace", :aliases => "-n", :type => :string, :banner => "NAMESPACE", :desc => "Remote namespace"
|
415
|
+
def make_private(context_params)
|
416
|
+
service_module_id = context_params.retrieve_arguments([:service_module_id!],method_argument_names)
|
417
|
+
chmod_aux(service_module_id, "o-rwd", options.namespace)
|
418
|
+
end
|
419
|
+
|
420
|
+
desc "SERVICE-MODULE-NAME/ID add-collaborators", "Add collabrators users or groups comma seperated (--users or --groups)"
|
421
|
+
method_option "namespace", :aliases => "-n", :type => :string, :banner => "NAMESPACE", :desc => "Remote namespace"
|
422
|
+
method_option "users",:aliases => "-u", :type => :string, :banner => "USERS", :desc => "User collabrators"
|
423
|
+
method_option "groups",:aliases => "-g", :type => :string, :banner => "GROUPS", :desc => "Group collabrators"
|
424
|
+
def add_collaborators(context_params)
|
425
|
+
service_module_id = context_params.retrieve_arguments([:service_module_id!],method_argument_names)
|
426
|
+
collaboration_aux(:add, service_module_id, options.users, options.groups, options.namespace)
|
427
|
+
end
|
428
|
+
|
429
|
+
desc "SERVICE-MODULE-NAME/ID remove-collaborators", "Remove collabrators users or groups comma seperated (--users or --groups)"
|
430
|
+
method_option "namespace",:aliases => "-n",:type => :string, :banner => "NAMESPACE", :desc => "Remote namespace"
|
431
|
+
method_option "users",:aliases => "-u", :type => :string, :banner => "USERS", :desc => "User collabrators"
|
432
|
+
method_option "groups",:aliases => "-g", :type => :string, :banner => "GROUPS", :desc => "Group collabrators"
|
433
|
+
def remove_collaborators(context_params)
|
434
|
+
service_module_id = context_params.retrieve_arguments([:service_module_id!],method_argument_names)
|
435
|
+
collaboration_aux(:remove, service_module_id, options.users, options.groups, options.namespace)
|
436
|
+
end
|
437
|
+
|
438
|
+
desc "SERVICE-MODULE-NAME/ID list-collaborators", "List collaborators for given module"
|
439
|
+
method_option "namespace",:aliases => "-n",:type => :string, :banner => "NAMESPACE", :desc => "Remote namespace"
|
440
|
+
def list_collaborators(context_params)
|
441
|
+
service_module_id = context_params.retrieve_arguments([:service_module_id!],method_argument_names)
|
442
|
+
response = collaboration_list_aux(component_module_id, options.namespace)
|
443
|
+
response.render_table(:module_collaborators)
|
444
|
+
response
|
445
|
+
end
|
446
|
+
|
390
447
|
##
|
391
448
|
#
|
392
449
|
# internal_trigger: this flag means that other method (internal) has trigger this.
|
data/lib/commands/thor/target.rb
CHANGED
@@ -15,6 +15,27 @@ module DTK::Client
|
|
15
15
|
list_targets(context_params)
|
16
16
|
end
|
17
17
|
|
18
|
+
desc "TARGET-NAME/ID import-nodes","Reads from inventory dsl and populates the node instance objects in the dtk server."
|
19
|
+
def import_nodes(context_params)
|
20
|
+
target_id = context_params.retrieve_arguments([:target_id!],method_argument_names)
|
21
|
+
|
22
|
+
post_body = {
|
23
|
+
:target_id => target_id
|
24
|
+
}
|
25
|
+
|
26
|
+
response = post rest_url("target/import_nodes"), post_body
|
27
|
+
return response unless response.ok?
|
28
|
+
|
29
|
+
if response.data.empty?
|
30
|
+
OsUtil.print("No new nodes to import!", :yellow)
|
31
|
+
else
|
32
|
+
OsUtil.print("Successfully imported nodes:", :yellow)
|
33
|
+
response.data.each do |node|
|
34
|
+
OsUtil.print("#{node}", :yellow)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
18
39
|
desc "TARGET-NAME/ID list-services","Lists service instances in given targets."
|
19
40
|
def list_services(context_params)
|
20
41
|
context_params.method_arguments = ["assemblies"]
|
data/lib/core.rb
CHANGED
@@ -12,6 +12,8 @@ require 'pp'
|
|
12
12
|
dtk_require_from_base('domain/response')
|
13
13
|
dtk_require_from_base('util/os_util')
|
14
14
|
dtk_require_from_base('util/ssh_util')
|
15
|
+
dtk_require_from_base('util/common_util')
|
16
|
+
dtk_require_from_base('util/permission_util')
|
15
17
|
dtk_require("config/configuration")
|
16
18
|
|
17
19
|
def top_level_execute(entity_name, method_name, context_params=nil, options_args=nil, shell_execute=false)
|
data/lib/domain/git_adapter.rb
CHANGED
data/lib/dtk-client/version.rb
CHANGED
data/lib/shell/context.rb
CHANGED
@@ -879,8 +879,8 @@ module DTK
|
|
879
879
|
end
|
880
880
|
end
|
881
881
|
|
882
|
-
# remove thor_options
|
883
|
-
args = args
|
882
|
+
# remove thor_options but only once
|
883
|
+
args = Client::CommonUtil.substract_array_once(args, options_param_args, true) unless options_param_args.nil?
|
884
884
|
|
885
885
|
return args, options_param_args, invalid_options
|
886
886
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module DTK
|
2
|
+
module Client
|
3
|
+
module CommonUtil
|
4
|
+
class << self
|
5
|
+
def substract_array_once(array1, array2, substract_from_back = false)
|
6
|
+
# we substract from reverse if flag set
|
7
|
+
array1 = array1.reverse if substract_from_back
|
8
|
+
|
9
|
+
array2.each do |element|
|
10
|
+
if index = array1.index(element)
|
11
|
+
array1.delete_at(index)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
substract_from_back ? array1.reverse : array1
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/util/os_util.rb
CHANGED
@@ -243,9 +243,14 @@ module DTK
|
|
243
243
|
load File.expand_path('../../lib/shell/domain.rb', File.dirname(__FILE__))
|
244
244
|
load File.expand_path('../../lib/domain/git_adapter.rb', File.dirname(__FILE__))
|
245
245
|
load File.expand_path('../../lib/command_helpers/git_repo.rb', File.dirname(__FILE__))
|
246
|
-
|
247
|
-
|
248
|
-
|
246
|
+
paths = []
|
247
|
+
paths << File.expand_path('../../lib/commands/thor/*.rb', File.dirname(__FILE__))
|
248
|
+
paths << File.expand_path('../../lib/commands/common/thor/*.rb', File.dirname(__FILE__))
|
249
|
+
|
250
|
+
paths.each do |path|
|
251
|
+
Dir[path].each do |thor_class_file|
|
252
|
+
load thor_class_file
|
253
|
+
end
|
249
254
|
end
|
250
255
|
end
|
251
256
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module DTK
|
2
|
+
module Client
|
3
|
+
module PermissionUtil
|
4
|
+
class << self
|
5
|
+
def validate_permissions!(permission_string)
|
6
|
+
# matches example: u-rw, ugo+r, go+w
|
7
|
+
match = permission_string.match(/^[ugo]+[+\-][rwd]+$/)
|
8
|
+
raise DTK::Client::DtkValidationError, "Provided permission expression ('#{permission_string}') is not valid" unless match
|
9
|
+
permission_string
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dtk-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rich PELAVIN
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-05-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -178,7 +178,8 @@ dependencies:
|
|
178
178
|
- - '='
|
179
179
|
- !ruby/object:Gem::Version
|
180
180
|
version: 1.1.0
|
181
|
-
description:
|
181
|
+
description: The DTK Client is a command line tool to interact with your DTK Server
|
182
|
+
and DTK Service Catalog instance(s).
|
182
183
|
email:
|
183
184
|
- rich@reactor8.com
|
184
185
|
executables:
|
@@ -203,6 +204,7 @@ files:
|
|
203
204
|
- lib/command_helpers/service_importer.rb
|
204
205
|
- lib/command_helpers/service_link.rb
|
205
206
|
- lib/commands.rb
|
207
|
+
- lib/commands/common/thor/access_control.rb
|
206
208
|
- lib/commands/common/thor/action_result_handler.rb
|
207
209
|
- lib/commands/common/thor/assembly_workspace.rb
|
208
210
|
- lib/commands/common/thor/clone.rb
|
@@ -270,9 +272,11 @@ files:
|
|
270
272
|
- lib/shell/interactive_wizard.rb
|
271
273
|
- lib/shell/parse_monkey_patch.rb
|
272
274
|
- lib/shell/status_monitor.rb
|
275
|
+
- lib/util/common_util.rb
|
273
276
|
- lib/util/console.rb
|
274
277
|
- lib/util/dtk_puppet.rb
|
275
278
|
- lib/util/os_util.rb
|
279
|
+
- lib/util/permission_util.rb
|
276
280
|
- lib/util/ssh_util.rb
|
277
281
|
- lib/view_processor.rb
|
278
282
|
- lib/view_processor/augmented_simple_list.rb
|