epc 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +1 -0
- data/Gemfile +22 -0
- data/Rakefile +67 -0
- data/Rakefile.gem +1 -0
- data/bin/epc +10 -0
- data/lib/epc.rb +126 -0
- data/lib/epc/client/base_client.rb +80 -0
- data/lib/epc/client/http_client.rb +19 -0
- data/lib/epc/client/json_client.rb +48 -0
- data/lib/epc/command/archive_project_command.rb +24 -0
- data/lib/epc/command/archive_solution_command.rb +21 -0
- data/lib/epc/command/attach_library_command.rb +82 -0
- data/lib/epc/command/attach_libraryset_command.rb +32 -0
- data/lib/epc/command/attach_runtime_command.rb +27 -0
- data/lib/epc/command/base_command.rb +451 -0
- data/lib/epc/command/bind_service_command.rb +35 -0
- data/lib/epc/command/build_command.rb +83 -0
- data/lib/epc/command/config/create_config_command.rb +55 -0
- data/lib/epc/command/copy_deployment_command.rb +21 -0
- data/lib/epc/command/create_command.rb +13 -0
- data/lib/epc/command/create_dependency_command.rb +43 -0
- data/lib/epc/command/define_service_command.rb +37 -0
- data/lib/epc/command/delete_config_command.rb +63 -0
- data/lib/epc/command/delete_dependency_command.rb +40 -0
- data/lib/epc/command/delete_group_command.rb +40 -0
- data/lib/epc/command/delete_library_command.rb +30 -0
- data/lib/epc/command/delete_librarylanguage_command.rb +40 -0
- data/lib/epc/command/delete_libraryset_command.rb +40 -0
- data/lib/epc/command/delete_project_command.rb +54 -0
- data/lib/epc/command/delete_role_command.rb +25 -0
- data/lib/epc/command/delete_serviceversion_command.rb +52 -0
- data/lib/epc/command/delete_solution_command.rb +39 -0
- data/lib/epc/command/delete_user_command.rb +31 -0
- data/lib/epc/command/deploy_command.rb +142 -0
- data/lib/epc/command/deployment/create_deployment_command.rb +82 -0
- data/lib/epc/command/detach_library_command.rb +35 -0
- data/lib/epc/command/detach_libraryset_command.rb +8 -0
- data/lib/epc/command/group/create_group_command.rb +21 -0
- data/lib/epc/command/info_command.rb +11 -0
- data/lib/epc/command/library/create_library_command.rb +45 -0
- data/lib/epc/command/librarylanguage/create_librarylanguage_command.rb +24 -0
- data/lib/epc/command/libraryset/create_libraryset_command.rb +54 -0
- data/lib/epc/command/list_approvals_command.rb +27 -0
- data/lib/epc/command/list_attachedlibraries_command.rb +42 -0
- data/lib/epc/command/list_boundservices_command.rb +40 -0
- data/lib/epc/command/list_config_command.rb +60 -0
- data/lib/epc/command/list_dependencies_command.rb +43 -0
- data/lib/epc/command/list_deployments_command.rb +68 -0
- data/lib/epc/command/list_groups_command.rb +19 -0
- data/lib/epc/command/list_libraries_command.rb +19 -0
- data/lib/epc/command/list_librarylanguages_command.rb +19 -0
- data/lib/epc/command/list_librarysets_command.rb +26 -0
- data/lib/epc/command/list_objectroles_command.rb +25 -0
- data/lib/epc/command/list_objecttypes_command.rb +20 -0
- data/lib/epc/command/list_permissiongroups_command.rb +20 -0
- data/lib/epc/command/list_projects_command.rb +36 -0
- data/lib/epc/command/list_projecttypes_command.rb +20 -0
- data/lib/epc/command/list_rolepermissions_command.rb +21 -0
- data/lib/epc/command/list_roles_command.rb +26 -0
- data/lib/epc/command/list_runtimes_command.rb +16 -0
- data/lib/epc/command/list_service_types_command.rb +19 -0
- data/lib/epc/command/list_servicedefinitions_command.rb +19 -0
- data/lib/epc/command/list_serviceversions_command.rb +21 -0
- data/lib/epc/command/list_solutions_command.rb +25 -0
- data/lib/epc/command/list_stages_command.rb +21 -0
- data/lib/epc/command/list_users_command.rb +26 -0
- data/lib/epc/command/list_versions_command.rb +39 -0
- data/lib/epc/command/login_command.rb +32 -0
- data/lib/epc/command/logout_command.rb +20 -0
- data/lib/epc/command/objectrole/create_objectrole_command.rb +19 -0
- data/lib/epc/command/project/create_project_command.rb +78 -0
- data/lib/epc/command/pull_command.rb +209 -0
- data/lib/epc/command/push_command.rb +194 -0
- data/lib/epc/command/refresh_solution_command.rb +71 -0
- data/lib/epc/command/renew_command.rb +19 -0
- data/lib/epc/command/request_passwordchange_command.rb +23 -0
- data/lib/epc/command/role/create_role_command.rb +17 -0
- data/lib/epc/command/serviceversion/create_serviceversion_command.rb +33 -0
- data/lib/epc/command/show_deployment_command.rb +57 -0
- data/lib/epc/command/show_group_command.rb +35 -0
- data/lib/epc/command/show_libraryset_command.rb +54 -0
- data/lib/epc/command/show_project_command.rb +74 -0
- data/lib/epc/command/show_projecttype_command.rb +18 -0
- data/lib/epc/command/show_role_command.rb +46 -0
- data/lib/epc/command/show_solution_command.rb +54 -0
- data/lib/epc/command/show_user_command.rb +42 -0
- data/lib/epc/command/solution/create_solution_command.rb +34 -0
- data/lib/epc/command/solution/list_solutions_command.rb +25 -0
- data/lib/epc/command/solution/update_solution_command.rb +43 -0
- data/lib/epc/command/submit_deployment_command.rb +19 -0
- data/lib/epc/command/target_command.rb +26 -0
- data/lib/epc/command/unarchive_project_command.rb +23 -0
- data/lib/epc/command/unarchive_solution_command.rb +21 -0
- data/lib/epc/command/unbind_service_command.rb +42 -0
- data/lib/epc/command/undefine_service_command.rb +33 -0
- data/lib/epc/command/undeploy_command.rb +106 -0
- data/lib/epc/command/update_config_command.rb +62 -0
- data/lib/epc/command/update_deploymentproject_command.rb +54 -0
- data/lib/epc/command/update_group_command.rb +43 -0
- data/lib/epc/command/update_librarylanguage_command.rb +28 -0
- data/lib/epc/command/update_libraryset_command.rb +80 -0
- data/lib/epc/command/update_project_command.rb +49 -0
- data/lib/epc/command/update_role_command.rb +47 -0
- data/lib/epc/command/update_rolepermissions_command.rb +83 -0
- data/lib/epc/command/update_solution_command.rb +45 -0
- data/lib/epc/command/update_user_command.rb +57 -0
- data/lib/epc/command/user/create_user_command.rb +27 -0
- data/lib/epc/command/vote_deployment_command.rb +29 -0
- data/lib/epc/config.rb +245 -0
- data/lib/epc/error/basic_error.rb +6 -0
- data/lib/epc/error/fatal_error.rb +6 -0
- data/lib/epc/error/input_error.rb +6 -0
- data/lib/epc/error/internal_error.rb +6 -0
- data/lib/epc/help.rb +292 -0
- data/lib/epc/persistent_attributes.rb +18 -0
- data/lib/epc/runner.rb +177 -0
- data/lib/epc/tabular_outputter.rb +161 -0
- data/lib/epc/version.rb +3 -0
- data/lib/fixnum.rb +9 -0
- data/lib/object.rb +13 -0
- data/test/command/archive_project_command_test.rb +41 -0
- data/test/command/archive_solution_command_test.rb +40 -0
- data/test/command/attach_library_command_test.rb +124 -0
- data/test/command/attach_libraryset_command_test.rb +49 -0
- data/test/command/attach_runtime_command_test.rb +44 -0
- data/test/command/base_command_test.rb +276 -0
- data/test/command/bind_service_command_test.rb +46 -0
- data/test/command/build_command_test.rb +103 -0
- data/test/command/copy_deployment_command_test.rb +38 -0
- data/test/command/create_config_command_test.rb +124 -0
- data/test/command/create_dependency_command_test.rb +55 -0
- data/test/command/create_deployment_command_test.rb +136 -0
- data/test/command/create_group_command_test.rb +34 -0
- data/test/command/create_library_command_test.rb +61 -0
- data/test/command/create_librarylanguage_command_test.rb +51 -0
- data/test/command/create_libraryset_command_test.rb +81 -0
- data/test/command/create_objectrole_command_test.rb +37 -0
- data/test/command/create_project_command_test.rb +102 -0
- data/test/command/create_role_command_test.rb +31 -0
- data/test/command/create_serviceversion_command_test.rb +60 -0
- data/test/command/create_solution_command_test.rb +70 -0
- data/test/command/create_user_command_test.rb +54 -0
- data/test/command/define_service_command_test.rb +55 -0
- data/test/command/delete_config_command_test.rb +82 -0
- data/test/command/delete_dependency_command_test.rb +50 -0
- data/test/command/delete_group_command_test.rb +56 -0
- data/test/command/delete_library_command_test.rb +43 -0
- data/test/command/delete_librarylanguage_command_test.rb +55 -0
- data/test/command/delete_libraryset_command_test.rb +55 -0
- data/test/command/delete_project_command_test.rb +76 -0
- data/test/command/delete_role_command_test.rb +41 -0
- data/test/command/delete_serviceversion_command_test.rb +53 -0
- data/test/command/delete_solution_command_test.rb +79 -0
- data/test/command/delete_user_command_test.rb +56 -0
- data/test/command/deploy_command_test.rb +185 -0
- data/test/command/detach_library_command_test.rb +53 -0
- data/test/command/info_command_test.rb +17 -0
- data/test/command/list_approvals_command_test.rb +41 -0
- data/test/command/list_boundservices_command_test.rb +46 -0
- data/test/command/list_config_command_test.rb +72 -0
- data/test/command/list_dependencies_command_test.rb +46 -0
- data/test/command/list_deployments_command_test.rb +112 -0
- data/test/command/list_deploymentstages_command_test.rb +44 -0
- data/test/command/list_libraries_command_test.rb +42 -0
- data/test/command/list_librarylanguages_command_test.rb +34 -0
- data/test/command/list_librarysets_command_test.rb +33 -0
- data/test/command/list_objectroles_command_test.rb +41 -0
- data/test/command/list_objecttypes_command_test.rb +25 -0
- data/test/command/list_permissiongroups_command_test.rb +25 -0
- data/test/command/list_projects_command_test.rb +63 -0
- data/test/command/list_projecttypes_command_test.rb +39 -0
- data/test/command/list_rolepermissions_command_test.rb +39 -0
- data/test/command/list_roles_command_test.rb +46 -0
- data/test/command/list_runtimes_command_test.rb +30 -0
- data/test/command/list_service_types_command_test.rb +44 -0
- data/test/command/list_servicedefinitions_command_test.rb +44 -0
- data/test/command/list_serviceversions_command_test.rb +47 -0
- data/test/command/list_solutions_command_test.rb +48 -0
- data/test/command/list_users_command_test.rb +33 -0
- data/test/command/login_command_test.rb +83 -0
- data/test/command/logout_command_test.rb +30 -0
- data/test/command/pull_command_test.rb +229 -0
- data/test/command/push_command_test.rb +246 -0
- data/test/command/refresh_solution_command_test.rb +35 -0
- data/test/command/renew_command_test.rb +43 -0
- data/test/command/request_passwordchange_command_test.rb +31 -0
- data/test/command/show_group_command_test.rb +50 -0
- data/test/command/show_libraryset_command_test.rb +51 -0
- data/test/command/show_project_command_test.rb +57 -0
- data/test/command/show_projecttype_command_test.rb +46 -0
- data/test/command/show_role_command_test.rb +37 -0
- data/test/command/show_solution_command_test.rb +59 -0
- data/test/command/show_user_command_test.rb +50 -0
- data/test/command/submit_deployment_command_test.rb +37 -0
- data/test/command/target_command_test.rb +58 -0
- data/test/command/unarchive_project_command_test.rb +45 -0
- data/test/command/unarchive_solution_command_test.rb +43 -0
- data/test/command/unbind_service_command_test.rb +48 -0
- data/test/command/undefine_service_command_test.rb +49 -0
- data/test/command/update_config_command_test.rb +74 -0
- data/test/command/update_deploymentproject_command_test.rb +77 -0
- data/test/command/update_group_command_test.rb +69 -0
- data/test/command/update_librarylanguage_command_test.rb +43 -0
- data/test/command/update_libraryset_command_test.rb +113 -0
- data/test/command/update_project_command_test.rb +56 -0
- data/test/command/update_role_command_test.rb +42 -0
- data/test/command/update_rolepermissions_command_test.rb +54 -0
- data/test/command/update_solution_command_test.rb +58 -0
- data/test/command/update_user_command_test.rb +76 -0
- data/test/command/vote_deployment_command_test.rb +33 -0
- data/test/config_test.rb +70 -0
- data/test/successful_test.rb +21 -0
- data/test/test_files/pom.xml +273 -0
- data/test/test_helper.rb +25 -0
- metadata +470 -0
@@ -0,0 +1,40 @@
|
|
1
|
+
module EPC::Command
|
2
|
+
class DeleteLibrarylanguageCommand < BaseCommand
|
3
|
+
|
4
|
+
def execute(language = nil)
|
5
|
+
if language.nil?
|
6
|
+
say("You need to specify a language id/name")
|
7
|
+
say(EPC::Help::COMMAND_USAGES[:delete_librarylanguage])
|
8
|
+
return 1
|
9
|
+
end
|
10
|
+
|
11
|
+
proceed = ask_yn("Are you sure you want to delete the [#{language}] language? [Yn] ")
|
12
|
+
if proceed.upcase == "N"
|
13
|
+
return 1
|
14
|
+
end
|
15
|
+
|
16
|
+
|
17
|
+
if numeric?(language)
|
18
|
+
language_id = language.to_i
|
19
|
+
else
|
20
|
+
language_id = get_resource_id(EPC::Config::LIBRARY_LANGUAGES_PATH, :name, language)
|
21
|
+
end
|
22
|
+
|
23
|
+
if language_id.nil?
|
24
|
+
say("Language could not be determined")
|
25
|
+
return 1
|
26
|
+
end
|
27
|
+
|
28
|
+
status, response, headers = client.delete(EPC::Config::LIBRARY_LANGUAGES_PATH + "/#{language_id}")
|
29
|
+
|
30
|
+
if status.successful?
|
31
|
+
say("Language deleted")
|
32
|
+
else
|
33
|
+
say("Request failed: [#{response[:message]}]")
|
34
|
+
end
|
35
|
+
|
36
|
+
return status
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module EPC::Command
|
2
|
+
class DeleteLibrarysetCommand < BaseCommand
|
3
|
+
|
4
|
+
def execute(set = nil)
|
5
|
+
if set.nil?
|
6
|
+
say("You need to specify a set id/name")
|
7
|
+
say(EPC::Help::COMMAND_USAGES[:delete_libraryset])
|
8
|
+
return 1
|
9
|
+
end
|
10
|
+
|
11
|
+
proceed = ask_yn("Are you sure you want to delete the [#{set}] set? [Yn] ")
|
12
|
+
if proceed.upcase == "N"
|
13
|
+
return 1
|
14
|
+
end
|
15
|
+
|
16
|
+
|
17
|
+
if numeric?(set)
|
18
|
+
set_id = set.to_i
|
19
|
+
else
|
20
|
+
set_id = get_resource_id(EPC::Config::LIBRARY_SETS_PATH, :name, set)
|
21
|
+
end
|
22
|
+
|
23
|
+
if set_id.nil?
|
24
|
+
say("Set could not be determined")
|
25
|
+
return 1
|
26
|
+
end
|
27
|
+
|
28
|
+
status, response, headers = client.delete(EPC::Config::LIBRARY_SETS_PATH + "/#{set_id}")
|
29
|
+
|
30
|
+
if status.successful?
|
31
|
+
say("Set deleted")
|
32
|
+
else
|
33
|
+
say("Request failed: [#{response[:message]}]")
|
34
|
+
end
|
35
|
+
|
36
|
+
return status
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
module EPC::Command
|
2
|
+
class DeleteProjectCommand < BaseCommand
|
3
|
+
def execute(project_name = nil)
|
4
|
+
path = "."
|
5
|
+
path = File.expand_path(path)
|
6
|
+
|
7
|
+
solution_name = @options[:solution_name]
|
8
|
+
|
9
|
+
solution_id, solution_name = infer_solution_context(solution_name, path, :get_solution_name => true)
|
10
|
+
project_id, project_name = infer_project_context(project_name, path, solution_id, {:get_project_name => true})
|
11
|
+
|
12
|
+
if project_id.nil?
|
13
|
+
say("Project name could not be inferred")
|
14
|
+
say(EPC::Help::COMMAND_USAGES[:delete_project])
|
15
|
+
return 1
|
16
|
+
end
|
17
|
+
|
18
|
+
question = "You are deleting the project [#{project_id}"
|
19
|
+
if project_name.nil?
|
20
|
+
question += "] Correct? [Yn] "
|
21
|
+
else
|
22
|
+
question += " - #{project_name}].Correct? [Yn] "
|
23
|
+
end
|
24
|
+
|
25
|
+
unless @options[:force]
|
26
|
+
proceed = ask_yn(question)
|
27
|
+
if proceed.upcase == 'N'
|
28
|
+
return 1
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
status, response, message = client.delete(EPC::Config::PROJECTS_PATH + "/#{project_id}")
|
33
|
+
if status.successful?
|
34
|
+
remove_project_metadata(path, project_name) if EPC::Config.is_project_dir?(path) || EPC::Config.is_solution_dir?(path)
|
35
|
+
say("Project deleted.")
|
36
|
+
else
|
37
|
+
say("Project could not be deleted. Delete failed with: [#{response[:message]}]")
|
38
|
+
end
|
39
|
+
return status
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
def remove_project_metadata(path, project_name)
|
46
|
+
if EPC::Config.is_solution_dir?(path)
|
47
|
+
metadata_file = File.join( path, project_name, ".epc_project")
|
48
|
+
else
|
49
|
+
metadata_file = File.join(path, ".epc_project")
|
50
|
+
end
|
51
|
+
File.delete(metadata_file) if FileTest.exist?(metadata_file)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module EPC::Command
|
2
|
+
class DeleteRoleCommand < BaseCommand
|
3
|
+
required_arguments_count 1, :message => "You must specify the role id/name"
|
4
|
+
|
5
|
+
def execute(role = nil)
|
6
|
+
|
7
|
+
proceed = ask_yn("Are you sure you want to delete the [#{role}] role? [Yn] ")
|
8
|
+
if proceed.upcase == "N"
|
9
|
+
return 1
|
10
|
+
end
|
11
|
+
|
12
|
+
role_id = retrieve_system_role_identifier(role)
|
13
|
+
|
14
|
+
status, response, headers = client.delete(EPC::Config::ROLES_PATH + "/#{role_id}/system/true")
|
15
|
+
|
16
|
+
if status.successful?
|
17
|
+
say("Role deleted")
|
18
|
+
else
|
19
|
+
say("Request failed: [#{response[:message]}]")
|
20
|
+
end
|
21
|
+
|
22
|
+
return status
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module EPC::Command
|
2
|
+
class DeleteServiceversionCommand < BaseCommand
|
3
|
+
|
4
|
+
def execute(service_version = nil, definition_name = nil)
|
5
|
+
if service_version.nil?
|
6
|
+
say("You must specify a service version identifier")
|
7
|
+
say(EPC::Help::COMMAND_USAGES[:delete_serviceversion])
|
8
|
+
return 1
|
9
|
+
end
|
10
|
+
|
11
|
+
proceed = ask_yn("Are you sure you want to delete the [#{service_version}] service_version. Correct? [Yn] ")
|
12
|
+
if proceed.upcase == 'N'
|
13
|
+
return 1
|
14
|
+
end
|
15
|
+
|
16
|
+
if numeric?(service_version)
|
17
|
+
service_version_id = service_version.to_i
|
18
|
+
else
|
19
|
+
if definition_name.nil?
|
20
|
+
say("You must specify the definition name")
|
21
|
+
say(EPC::Help::COMMAND_USAGES[:delete_serviceversion])
|
22
|
+
return 1
|
23
|
+
end
|
24
|
+
|
25
|
+
|
26
|
+
status, response, headers = client.get(EPC::Config::SERVICE_VERSIONS_PATH)
|
27
|
+
|
28
|
+
if numeric?(definition_name)
|
29
|
+
service_version_id = response.detect{|version| version[:label] == service_version && version[:service_definition_id] == definition_name.to_i }[:id] rescue nil
|
30
|
+
else
|
31
|
+
service_version_id = response.detect{|version| version[:label] == service_version && version[:service_definition_name] == definition_name }[:id] rescue nil
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
if service_version_id.nil? || service_version_id == 0
|
37
|
+
say("Service version not found.")
|
38
|
+
return 1
|
39
|
+
end
|
40
|
+
|
41
|
+
status, response, headers = client.delete(EPC::Config::SERVICE_VERSIONS_PATH + "/#{service_version_id}")
|
42
|
+
|
43
|
+
if status.successful?
|
44
|
+
say("Service version deleted.")
|
45
|
+
else
|
46
|
+
say("Request failed: [#{response[:message]}]")
|
47
|
+
end
|
48
|
+
return status
|
49
|
+
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module EPC::Command
|
2
|
+
class DeleteSolutionCommand < BaseCommand
|
3
|
+
def execute(solution_name = nil)
|
4
|
+
path = "."
|
5
|
+
path = File.expand_path(path)
|
6
|
+
|
7
|
+
|
8
|
+
solution_id, solution_name = infer_solution_context(solution_name, path, :get_solution_name => true)
|
9
|
+
|
10
|
+
if solution_id.nil?
|
11
|
+
say("Solution could not be inferred")
|
12
|
+
return 1
|
13
|
+
end
|
14
|
+
|
15
|
+
proceed = ask_yn("Are you sure you want to delete [#{solution_id} - #{solution_name}]. Correct? [Yn] ")
|
16
|
+
if proceed.upcase == 'N'
|
17
|
+
return 1
|
18
|
+
end
|
19
|
+
|
20
|
+
status, response, message = client.delete(EPC::Config::SOLUTIONS_PATH + "/#{solution_id}")
|
21
|
+
if status.successful?
|
22
|
+
remove_solution_metadata(project_solution_path(path)) if EPC::Config.is_solution_dir?(path) || EPC::Config.is_project_dir?(path)
|
23
|
+
say("Solution deleted.")
|
24
|
+
else
|
25
|
+
say("Solution could not be deleted. Delete failed with: [#{response[:message]}]")
|
26
|
+
end
|
27
|
+
return status
|
28
|
+
end
|
29
|
+
|
30
|
+
def remove_solution_metadata(solution_path)
|
31
|
+
dirs = Dir.glob(solution_path + "/**/")
|
32
|
+
dirs.each do |dir|
|
33
|
+
file = dir + "/.epc_project"
|
34
|
+
File.delete(file) if FileTest.exist?(file)
|
35
|
+
end
|
36
|
+
File.delete(solution_path + "/.epc_solution") if FileTest.exist?(solution_path + "/.epc_solution")
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module EPC::Command
|
2
|
+
class DeleteUserCommand < BaseCommand
|
3
|
+
def execute(user = nil)
|
4
|
+
|
5
|
+
raise FatalError, "You need to specify a user id/email" if user.nil?
|
6
|
+
|
7
|
+
proceed = ask_yn("Are you sure you want to delete the [#{user}] user? [Yn] ")
|
8
|
+
if proceed.upcase == "N"
|
9
|
+
return 1
|
10
|
+
end
|
11
|
+
|
12
|
+
if numeric?(user)
|
13
|
+
user_id = user.to_i
|
14
|
+
else
|
15
|
+
user_id = get_resource_id(EPC::Config::USERS_PATH, :email, user)
|
16
|
+
end
|
17
|
+
|
18
|
+
raise FatalError, "User could not be determined" if user_id.blank? || user_id == 0
|
19
|
+
|
20
|
+
status, response, headers = client.delete(EPC::Config::USERS_PATH + "/#{user_id}")
|
21
|
+
|
22
|
+
if status == 200
|
23
|
+
say("User deleted")
|
24
|
+
else
|
25
|
+
say("Request failed: [#{response[:message]}]")
|
26
|
+
end
|
27
|
+
|
28
|
+
return status
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,142 @@
|
|
1
|
+
module EPC::Command
|
2
|
+
class DeployCommand < BaseCommand
|
3
|
+
SLEEP_TIME = 1
|
4
|
+
|
5
|
+
# Numerators are in secs
|
6
|
+
TICKER_TICKS = 25/SLEEP_TIME
|
7
|
+
GIVEUP_TICKS = 120/SLEEP_TIME
|
8
|
+
|
9
|
+
def execute(stage = nil)
|
10
|
+
path = "."
|
11
|
+
path = File.expand_path(path)
|
12
|
+
|
13
|
+
if !( EPC::Config.is_solution_dir?(path) || EPC::Config.is_project_dir?(path)) && @options[:deployment_id].nil?
|
14
|
+
say("This is not a solution directory.")
|
15
|
+
return 1
|
16
|
+
end
|
17
|
+
|
18
|
+
if @options[:no_poll].present? && @options[:timeout].present?
|
19
|
+
raise InputError, "You cannot specify both --nopoll and --timeout options at the same time"
|
20
|
+
end
|
21
|
+
|
22
|
+
@timeout = GIVEUP_TICKS
|
23
|
+
|
24
|
+
solution_id, solution_name = infer_solution_context(nil, path)
|
25
|
+
|
26
|
+
|
27
|
+
if @options[:deployment_id].nil?
|
28
|
+
proceed = ask_yn("You are deploying the [#{solution_name}] solution. Correct? [Yn]: ")
|
29
|
+
return 1 if proceed.upcase == 'N'
|
30
|
+
end
|
31
|
+
|
32
|
+
if @options[:use_local].present? && @options[:use_local]
|
33
|
+
@options[:skip_build] = true
|
34
|
+
result, versions = EPC::Command::PushCommand.new(client, @options).execute_internal
|
35
|
+
return result if result != 0
|
36
|
+
b_versions = (versions.map{|v| "#{v.keys.first}=#{v.values.first}"})
|
37
|
+
result = EPC::Command::BuildCommand.new(client, @options).execute(*b_versions)
|
38
|
+
return result unless result.successful? || result == 0
|
39
|
+
end
|
40
|
+
|
41
|
+
deployment_id = @options[:deployment_id]
|
42
|
+
|
43
|
+
deployment_id = create_deployment(solution_name, stage) if stage.present?
|
44
|
+
deployment_id = create_deployment(solution_name, stage) if deployment_id.nil?
|
45
|
+
|
46
|
+
raise FatalError, "Could not find/create deployment id." if deployment_id.nil? || deployment_id == -1
|
47
|
+
|
48
|
+
parse_timeout_value
|
49
|
+
|
50
|
+
begin
|
51
|
+
say("Deploying #{deployment_id}")
|
52
|
+
status, response = deploy(deployment_id)
|
53
|
+
if @options[:no_poll].present?
|
54
|
+
say("Request submitted")
|
55
|
+
return status
|
56
|
+
end
|
57
|
+
say("Deploying - ")
|
58
|
+
shown, deployment_status = poll_for_deployment_statuses(deployment_id)
|
59
|
+
if shown
|
60
|
+
display_statuses(deployment_status, response[:deployed_projects])
|
61
|
+
end
|
62
|
+
rescue Exception => ex
|
63
|
+
say("Deploy failed [#{ex.to_s}].")
|
64
|
+
return 1
|
65
|
+
end
|
66
|
+
return status
|
67
|
+
end
|
68
|
+
|
69
|
+
private
|
70
|
+
|
71
|
+
def create_deployment(solution_name, stage_name = nil)
|
72
|
+
command = EPC::Command::CreateDeploymentCommand.new(client, {:solution_name => solution_name, :skip_prompts => @options[:skip_prompts]})
|
73
|
+
deployment_id = command.execute_internal(stage_name)
|
74
|
+
return deployment_id
|
75
|
+
end
|
76
|
+
|
77
|
+
def deploy(id)
|
78
|
+
status, response, headers = client.put("#{EPC::Config::DEPLOYMENTS_PATH}/#{id}/deploy")
|
79
|
+
if status.successful?
|
80
|
+
return status, response
|
81
|
+
else
|
82
|
+
raise response[:message]
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def show_deployment(id)
|
87
|
+
status, response, headers = client.get("#{EPC::Config::DEPLOYMENTS_PATH}/#{id}/status")
|
88
|
+
if status.successful?
|
89
|
+
return status, nil, response[:status]
|
90
|
+
else
|
91
|
+
return status, response, nil
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
def poll_for_deployment_statuses(id)
|
96
|
+
@timeout = GIVEUP_TICKS if @timeout.blank?
|
97
|
+
count = 0
|
98
|
+
failed = false
|
99
|
+
|
100
|
+
while count <= @timeout
|
101
|
+
# unless count > TICKER_TICKS
|
102
|
+
STDOUT.print('.')
|
103
|
+
STDOUT.flush
|
104
|
+
# end
|
105
|
+
sleep(SLEEP_TIME)
|
106
|
+
|
107
|
+
status, code, deployment_status = show_deployment(id)
|
108
|
+
if status.successful? || (deployment_status == 404 && code == 901)
|
109
|
+
count += 1
|
110
|
+
next unless deployment_status == "STARTED" || deployment_status == "STOPPED" || deployment_status == "UNDEPLOYED" || deployment_status == "ERROR"
|
111
|
+
break
|
112
|
+
else
|
113
|
+
say("Poller failure [HTTP Error(#{status}): API error code (#{code})]")
|
114
|
+
say("Poller failed to get the deployment statuses. Aborting.")
|
115
|
+
failed = true
|
116
|
+
break
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
if deployment_status && deployment_status.present?
|
121
|
+
[true, deployment_status]
|
122
|
+
elsif failed
|
123
|
+
[false, nil]
|
124
|
+
else
|
125
|
+
if count > @timeout
|
126
|
+
say("\nServer is taking too long to update the deployment statuses. Please contact the AgileMethods support team.")
|
127
|
+
end
|
128
|
+
[false, nil]
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
def display_statuses(deployment_status, deployed_projects)
|
133
|
+
say("\nStatus = #{deployment_status}\n")
|
134
|
+
deployed_projects.each do |project|
|
135
|
+
say("#{project[:project_name]} -> #{project[:uris].join(",")}\n")
|
136
|
+
end
|
137
|
+
|
138
|
+
end
|
139
|
+
|
140
|
+
|
141
|
+
end
|
142
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
module EPC::Command
|
2
|
+
class CreateDeploymentCommand < BaseCommand
|
3
|
+
def execute(*params)
|
4
|
+
|
5
|
+
target_type, target_id = params[0].split(":") rescue [nil, nil]
|
6
|
+
stage_name = params[1]
|
7
|
+
|
8
|
+
path = File.expand_path(".")
|
9
|
+
|
10
|
+
stage_name = "Development" if stage_name.nil?
|
11
|
+
solution_name = @options[:solution_name]
|
12
|
+
|
13
|
+
solution_id, solution_name = infer_solution_context(target_id, path, {:get_solution_name => true})
|
14
|
+
|
15
|
+
raise FatalError, "Solution name could not be inferred from directory structure. Either run this command from a solution directory, or specify the solution name with the -s option." if solution_name.nil?
|
16
|
+
|
17
|
+
proceed = ask_yn("You are creating a deployment for the [#{solution_name}] solution with the [#{stage_name}] stage. Correct? [Yn]: ")
|
18
|
+
if proceed.upcase == 'N'
|
19
|
+
return 1
|
20
|
+
end
|
21
|
+
|
22
|
+
versions, instances = {}, {}
|
23
|
+
versions, instances = parse_projects(@options[:project_name]) unless blank?(@options[:project_name])
|
24
|
+
|
25
|
+
begin
|
26
|
+
status, @id = create_deployment(solution_name, stage_name, versions, instances)
|
27
|
+
return status unless status.successful?
|
28
|
+
rescue Exception => ex
|
29
|
+
say("Create deployment failed [Exception Caught (#{ex.class.name}): #{ex.to_s}].")
|
30
|
+
return 1
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
if @options[:replaces].present?
|
35
|
+
status, response, headers = client.put(EPC::Config::DEPLOYMENTS_PATH + "/#{@id}", {:stage_name => "no_change", :replaces_id => @options[:replaces], :versions => "no_change"})
|
36
|
+
if status.failure?
|
37
|
+
say("Replacement request failed: [#{response[:message]}]")
|
38
|
+
else
|
39
|
+
say("Replacement request successful")
|
40
|
+
end
|
41
|
+
return status
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
def execute_internal(stage_name = nil)
|
47
|
+
execute(stage_name)
|
48
|
+
return @id
|
49
|
+
end
|
50
|
+
|
51
|
+
private
|
52
|
+
|
53
|
+
def create_deployment(solution_name, stage_name, versions = nil, instances = nil)
|
54
|
+
params = {:solution_name => solution_name, :stage_name => stage_name}
|
55
|
+
params[:versions] = versions unless blank?(versions)
|
56
|
+
params[:instances] = instances unless blank?(instances)
|
57
|
+
status, response, headers = client.post("#{EPC::Config::DEPLOYMENTS_PATH}", params)
|
58
|
+
if status.successful?
|
59
|
+
say("Successfully created deployment [#{response[:id]}] with [#{target_url}]")
|
60
|
+
return status, response[:id]
|
61
|
+
else
|
62
|
+
say("Deployment creation failed [#{response[:message]}]. Aborting.")
|
63
|
+
return status, nil
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def parse_projects(data)
|
68
|
+
return [], [] if data.blank?
|
69
|
+
versions = []
|
70
|
+
instances = []
|
71
|
+
projects_data = data.split("|")
|
72
|
+
projects_data.each do |project_data|
|
73
|
+
project_id, ver, inst = project_data.split(":")
|
74
|
+
next if blank?(project_id)
|
75
|
+
versions << {:project_id => project_id, :version => ver} unless blank?(ver)
|
76
|
+
instances << {:project_id => project_id, :instances => inst} unless blank?(inst)
|
77
|
+
end
|
78
|
+
|
79
|
+
return versions, instances
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|