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,54 @@
|
|
1
|
+
require 'time'
|
2
|
+
module EPC::Command
|
3
|
+
class ShowSolutionCommand < BaseCommand
|
4
|
+
|
5
|
+
def execute(solution_name = nil)
|
6
|
+
path = File.expand_path(".")
|
7
|
+
|
8
|
+
solution_id, solution_name = infer_solution_context(solution_name, path, {:get_solution_name => true})
|
9
|
+
|
10
|
+
raise InputError, "Solution not found" if solution_id.nil?
|
11
|
+
|
12
|
+
status, response, message = client.get(EPC::Config::SOLUTIONS_PATH + "/#{solution_id}?include=config_values,projects,deployments,deployment_configs")
|
13
|
+
if status.failure?
|
14
|
+
say("Request failed: [#{response[:message]}]")
|
15
|
+
return status
|
16
|
+
end
|
17
|
+
|
18
|
+
|
19
|
+
response[:build_date] = Time.parse(response[:build_date]).strftime("%m/%d/%Y %I:%M%p") rescue nil
|
20
|
+
response[:updated_at] = Time.parse(response[:updated_at]).strftime("%m/%d/%Y %I:%M%p") rescue nil
|
21
|
+
solution_table = EPC::TabularOutputter.new([response], [:id, :name, :updated_at, :build_date, :build_status])
|
22
|
+
response[:projects].each do |project|
|
23
|
+
unless project[:last_build_status].nil?
|
24
|
+
project[:last_build_status] = nil if project[:last_build_status] == "N/A" # temp hack
|
25
|
+
project[:last_build_status] = (project[:last_build_status] ? "BUILT" : "FAILED" rescue nil) unless project[:last_build_status].nil?
|
26
|
+
end
|
27
|
+
end if response[:projects].present?
|
28
|
+
projects_table = EPC::TabularOutputter.new(response[:projects], {:id => "ID", :name => "NAME", :current_version_number => "VERSION", :last_build_status => "BUILD_STATUS", :last_build_errors => "ERRORS"})
|
29
|
+
|
30
|
+
response[:deployments].each do |dep|
|
31
|
+
dep[:updated_at] = Time.parse(dep[:updated_at]).strftime("%m/%d/%Y %I:%M%p")
|
32
|
+
dep[:deployment_stage_name] = dep[:deployment_stage][:name] unless dep[:deployment_stage].nil?
|
33
|
+
end if response[:deployments].present?
|
34
|
+
deployments_table = EPC::TabularOutputter.new(response[:deployments], {:id => "ID", :deployment_stage_name => "STAGE", :status => "STATUS", :updated_at => "LAST UPDATE"})
|
35
|
+
config_values_table = EPC::TabularOutputter.new(response[:config_values], [:name, :value, :require, :value_type])
|
36
|
+
|
37
|
+
say("\nSolution details:")
|
38
|
+
say(solution_table.print)
|
39
|
+
|
40
|
+
unless response[:projects].nil? || response[:projects].empty?
|
41
|
+
say("\nProjects:")
|
42
|
+
say(projects_table.print)
|
43
|
+
end
|
44
|
+
|
45
|
+
unless response[:deployments].nil? || response[:deployments].empty?
|
46
|
+
say("\nDeployments:")
|
47
|
+
say(deployments_table.print)
|
48
|
+
end
|
49
|
+
|
50
|
+
return status
|
51
|
+
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module EPC::Command
|
2
|
+
class ShowUserCommand < BaseCommand
|
3
|
+
|
4
|
+
def execute(user = nil)
|
5
|
+
if user.nil?
|
6
|
+
say("You need to specify a user id/email")
|
7
|
+
say(EPC::Help::COMMAND_USAGES[:show_user])
|
8
|
+
return 1
|
9
|
+
end
|
10
|
+
|
11
|
+
if numeric?(user)
|
12
|
+
user_id = user.to_i
|
13
|
+
else
|
14
|
+
user_id = get_resource_id(EPC::Config::USERS_PATH, :email, user)
|
15
|
+
end
|
16
|
+
|
17
|
+
if user_id.nil? || user_id == 0
|
18
|
+
say("User could not be found")
|
19
|
+
return 1
|
20
|
+
end
|
21
|
+
|
22
|
+
status, response, headers = client.get(EPC::Config::USERS_PATH + "/#{user_id}?include=user_groups")
|
23
|
+
|
24
|
+
if status != 200
|
25
|
+
say("Request failed: [#{response[:message]}]")
|
26
|
+
return status
|
27
|
+
end
|
28
|
+
|
29
|
+
user_table = EPC::TabularOutputter.new([response], [:id, :name, :email])
|
30
|
+
groups_table = EPC::TabularOutputter.new(response[:user_groups], [:id, :name])
|
31
|
+
|
32
|
+
say(user_table.print)
|
33
|
+
|
34
|
+
if response[:user_groups].present?
|
35
|
+
say("\nUser Groups: ")
|
36
|
+
say(groups_table.print)
|
37
|
+
end
|
38
|
+
|
39
|
+
return status
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module EPC::Command
|
2
|
+
class CreateSolutionCommand < BaseCommand
|
3
|
+
required_arguments_count 2, :message => "You must enter a solution name to run this command"
|
4
|
+
|
5
|
+
def execute(*params)
|
6
|
+
name = params[1]
|
7
|
+
|
8
|
+
begin
|
9
|
+
status, response, headers = client.post("#{EPC::Config::SOLUTIONS_PATH}", { :name => name })
|
10
|
+
if status.successful?
|
11
|
+
|
12
|
+
if @options[:nodir]
|
13
|
+
say("Successfully created the solution with [#{target_url}].")
|
14
|
+
else
|
15
|
+
result = mkdir(name)
|
16
|
+
if result == :ok
|
17
|
+
EPC::Config.add_solution(name, response[:id])
|
18
|
+
say("Successfully created the solution with [#{target_url}] and created your local directory.")
|
19
|
+
else
|
20
|
+
say("Successfully created the solution with [#{target_url}], but FAILED to create your local directory.")
|
21
|
+
return 1
|
22
|
+
end
|
23
|
+
end
|
24
|
+
else
|
25
|
+
say("Solution creation failed [#{response[:message]}].")
|
26
|
+
end
|
27
|
+
return status
|
28
|
+
rescue Exception => ex
|
29
|
+
say("Solution creation failed [#{ex}].")
|
30
|
+
return 1
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'time'
|
2
|
+
module EPC::Command
|
3
|
+
class ListSolutionsCommand < BaseCommand
|
4
|
+
|
5
|
+
def execute(*args)
|
6
|
+
status, response, headers = client.get(EPC::Config::SOLUTIONS_PATH)
|
7
|
+
|
8
|
+
if status.failure?
|
9
|
+
say("Request failed: [#{response[:message]}]")
|
10
|
+
elsif response.empty?
|
11
|
+
say("You have no solutions created. You can create them with epc create solution.")
|
12
|
+
else
|
13
|
+
response.each do |resp|
|
14
|
+
resp[:created_at] = Time.parse(resp[:created_at]).strftime("%m/%d/%Y %I:%M%p")
|
15
|
+
resp[:creator_id] = resp[:created_by][:id] rescue nil
|
16
|
+
resp[:creator_name] = resp[:created_by][:name] rescue nil
|
17
|
+
end
|
18
|
+
solutions_table = EPC::TabularOutputter.new(response, [:id, :name, :build_status, :created_at, :creator_id, :creator_name])
|
19
|
+
say(solutions_table.print)
|
20
|
+
end
|
21
|
+
return status
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module EPC::Command
|
2
|
+
class UpdateSolutionCommand < BaseCommand
|
3
|
+
UPDATABLE_ATTRIBUTES = ["name"]
|
4
|
+
|
5
|
+
def execute(*args)
|
6
|
+
path = File.expand_path(".")
|
7
|
+
path = project_solution_path(path)
|
8
|
+
|
9
|
+
solution_id, solution_name = infer_solution_context(@options[:solution_name], path)
|
10
|
+
|
11
|
+
raise FatalError, "Solution could not be determined" if solution_id.nil?
|
12
|
+
|
13
|
+
args_hash = {}
|
14
|
+
args.each do |arg|
|
15
|
+
key, val = arg.split("=")
|
16
|
+
args_hash[key] = val
|
17
|
+
end
|
18
|
+
|
19
|
+
if @options[:file].present?
|
20
|
+
args_hash = EPC::Config.read_content_as_json(@options[:file]).merge(args_hash)
|
21
|
+
end
|
22
|
+
|
23
|
+
args_hash.each do |attr, val|
|
24
|
+
unless UPDATABLE_ATTRIBUTES.include?(attr)
|
25
|
+
args_hash.delete(attr)
|
26
|
+
say("Cannot update #{attr}. Updatable attributes are: #{UPDATABLE_ATTRIBUTES.join(',')}")
|
27
|
+
next
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
if args_hash.present?
|
33
|
+
status, response, message = client.put(EPC::Config::SOLUTIONS_PATH + "/#{solution_id}", args_hash)
|
34
|
+
if status.failure?
|
35
|
+
say("Update failed with: [#{response['message']}]")
|
36
|
+
else
|
37
|
+
say("Update succesful")
|
38
|
+
end
|
39
|
+
return status
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module EPC::Command
|
2
|
+
class SubmitDeploymentCommand < BaseCommand
|
3
|
+
def execute(deployment_id = nil)
|
4
|
+
if deployment_id.nil?
|
5
|
+
say("You must specify a deployment id")
|
6
|
+
say(EPC::Help::COMMAND_USAGES[:submit_deployment])
|
7
|
+
return 1
|
8
|
+
end
|
9
|
+
|
10
|
+
status, response, headers = client.put(EPC::Config::DEPLOYMENTS_PATH + "/#{deployment_id}/submit")
|
11
|
+
if status.successful?
|
12
|
+
say("Deployment submitted for approval")
|
13
|
+
else
|
14
|
+
say("Request failed: [#{response[:message]}]")
|
15
|
+
end
|
16
|
+
return status
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module EPC::Command
|
2
|
+
class TargetCommand < BaseCommand
|
3
|
+
dont_require_login
|
4
|
+
|
5
|
+
def execute(target_url = nil)
|
6
|
+
if blank?(target_url)
|
7
|
+
say("TARGET: " + EPC::Config.target_url)
|
8
|
+
return 1
|
9
|
+
end
|
10
|
+
|
11
|
+
target_url = "http://#{target_url}" unless target_url =~ /^https?/
|
12
|
+
target_url = target_url.gsub(/\/+$/, '')
|
13
|
+
|
14
|
+
begin
|
15
|
+
URI.parse(target_url)
|
16
|
+
status, response, headers = client.get(target_url + "/api/v1/tokens/status", true)
|
17
|
+
raise Exception if status.failure?
|
18
|
+
EPC::Config.store_target_url(target_url)
|
19
|
+
say("Successfully targeted to [#{target_url}]")
|
20
|
+
rescue => ex
|
21
|
+
say("The URL you entered [#{target_url}] is not valid. Please try again.")
|
22
|
+
end
|
23
|
+
return status
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module EPC::Command
|
2
|
+
class UnarchiveProjectCommand < BaseCommand
|
3
|
+
def execute(project_name = nil)
|
4
|
+
path = File.expand_path(".")
|
5
|
+
|
6
|
+
solution_name = @options[:solution_name]
|
7
|
+
|
8
|
+
solution_id, solution_name = infer_solution_context(solution_name, path, {:get_solution_name => true})
|
9
|
+
project_id, project_name = infer_project_context(project_name, path, solution_id, {:get_solution_name => true})
|
10
|
+
|
11
|
+
raise FatalError, "Project could not be inferred." if project_id.nil?
|
12
|
+
|
13
|
+
status, response, message = client.put(EPC::Config::PROJECTS_PATH + "/#{project_id}", {:archived => false})
|
14
|
+
if status.successful?
|
15
|
+
say("Project has been unarchived.")
|
16
|
+
else
|
17
|
+
say("Project could not be unarchived. Request failed with: [#{response[:message]}]")
|
18
|
+
end
|
19
|
+
return status
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module EPC::Command
|
2
|
+
class UnarchiveSolutionCommand < BaseCommand
|
3
|
+
def execute(solution_name = nil)
|
4
|
+
path = "."
|
5
|
+
path = File.expand_path(path)
|
6
|
+
|
7
|
+
solution_id, solution_name = infer_solution_context(solution_name, path, {:get_solution_name => true})
|
8
|
+
|
9
|
+
raise FatalError, "Solution could not be inferred" if solution_id.nil?
|
10
|
+
|
11
|
+
status, response, message = client.put(EPC::Config::SOLUTIONS_PATH + "/#{solution_id}", {:archived => false, :name => solution_name})
|
12
|
+
if status.successful?
|
13
|
+
say("Solution has been unarchived.")
|
14
|
+
else
|
15
|
+
say("Solution could not be unarchived. Request failed with: [#{response[:message]}]")
|
16
|
+
end
|
17
|
+
return status
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module EPC::Command
|
2
|
+
class UnbindServiceCommand < BaseCommand
|
3
|
+
|
4
|
+
def execute(version = nil)
|
5
|
+
if version.nil?
|
6
|
+
say("You must specify the service version to be unbound.")
|
7
|
+
say(EPC::Help::COMMAND_USAGES[:unbind_service])
|
8
|
+
return 1
|
9
|
+
end
|
10
|
+
|
11
|
+
path = File.expand_path(".")
|
12
|
+
|
13
|
+
solution_name = @options[:solution_name]
|
14
|
+
project_name = @options[:project_name]
|
15
|
+
|
16
|
+
solution_id, solution_name = infer_solution_context(solution_name, path)
|
17
|
+
project_id, project_name = infer_project_context(project_name, path, solution_id)
|
18
|
+
|
19
|
+
if numeric?(version)
|
20
|
+
service_version_id = version.to_i
|
21
|
+
else
|
22
|
+
service_version_id = get_resource_id(EPC::Config::SERVICE_VERSIONS_PATH, :label, version)
|
23
|
+
end
|
24
|
+
|
25
|
+
if service_version_id.nil? || project_id.nil?
|
26
|
+
say("Project or service incorrectly specified.")
|
27
|
+
say(EPC::Help::COMMAND_USAGES[:unbind_service])
|
28
|
+
return 1
|
29
|
+
end
|
30
|
+
|
31
|
+
status, response, headers = client.delete(EPC::Config::PROJECTS_PATH + "/#{project_id}/remove_service_version/#{service_version_id}")
|
32
|
+
|
33
|
+
if status.successful?
|
34
|
+
say("Service version unbound.")
|
35
|
+
else
|
36
|
+
say("Request failed: [#{response[:message]}]")
|
37
|
+
end
|
38
|
+
return status
|
39
|
+
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module EPC::Command
|
2
|
+
class UndefineServiceCommand < BaseCommand
|
3
|
+
|
4
|
+
def execute(service_name = nil)
|
5
|
+
if service_name.nil?
|
6
|
+
say("You must specify a name for the service")
|
7
|
+
say(EPC::Help::COMMAND_USAGES[:undefine_service])
|
8
|
+
return 1
|
9
|
+
end
|
10
|
+
|
11
|
+
if numeric?(service_name)
|
12
|
+
service_id = service_name.to_i
|
13
|
+
else
|
14
|
+
service_id = get_resource_id(EPC::Config::SERVICE_DEFINITIONS_PATH, :name, service_name)
|
15
|
+
end
|
16
|
+
|
17
|
+
if service_id.nil? || service_id == 0
|
18
|
+
say("#{service_name} service could not be found.")
|
19
|
+
return 1
|
20
|
+
end
|
21
|
+
|
22
|
+
status, response, headers = client.delete(EPC::Config::SERVICE_DEFINITIONS_PATH + "/#{service_id}")
|
23
|
+
|
24
|
+
if status.failure?
|
25
|
+
say("Service removal failed with: [#{response['message']}]")
|
26
|
+
else
|
27
|
+
say("#{service_name} has been undefined.")
|
28
|
+
end
|
29
|
+
return status
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
@@ -0,0 +1,106 @@
|
|
1
|
+
module EPC::Command
|
2
|
+
class UndeployCommand < BaseCommand
|
3
|
+
SLEEP_TIME = 1
|
4
|
+
|
5
|
+
# Numerators are in secs
|
6
|
+
TICKER_TICKS = 25/SLEEP_TIME
|
7
|
+
GIVEUP_TICKS = 120/SLEEP_TIME
|
8
|
+
def execute(deployment_id = nil)
|
9
|
+
path = File.expand_path(".")
|
10
|
+
|
11
|
+
solution_name = @options[:solution_name]
|
12
|
+
|
13
|
+
if deployment_id.nil?
|
14
|
+
solution_id, solution_name = infer_solution_context(solution_name, path)
|
15
|
+
if solution_id.nil? || solution_name.empty?
|
16
|
+
say("Solution could not be inferred")
|
17
|
+
say(EPC::Help::COMMAND_USAGES[:undeploy])
|
18
|
+
return 1
|
19
|
+
end
|
20
|
+
|
21
|
+
cmd = ListDeploymentsCommand.new(client, {:solution_name => solution_id, :status => "STARTED"}).execute
|
22
|
+
return 1 if cmd == 1
|
23
|
+
deployment_id = ask("Enter deployment id: ", Integer)
|
24
|
+
end
|
25
|
+
|
26
|
+
if deployment_id.nil?
|
27
|
+
say("You must specify a deployment id")
|
28
|
+
say(EPC::Help::COMMAND_USAGES[:undeploy])
|
29
|
+
return 1
|
30
|
+
end
|
31
|
+
|
32
|
+
begin
|
33
|
+
say("Undeploying #{deployment_id}")
|
34
|
+
undeploy(deployment_id)
|
35
|
+
say("Undeploying - ")
|
36
|
+
shown, deployment_status = poll_for_deployment_statuses(deployment_id)
|
37
|
+
if shown
|
38
|
+
display_statuses(deployment_status)
|
39
|
+
end
|
40
|
+
rescue Exception => ex
|
41
|
+
say("Undeploy failed [#{ex.to_s}].")
|
42
|
+
end
|
43
|
+
return @status
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
private
|
48
|
+
|
49
|
+
def undeploy(id)
|
50
|
+
status, response, headers = client.put("#{EPC::Config::DEPLOYMENTS_PATH}/#{id}/undeploy")
|
51
|
+
@status = status
|
52
|
+
raise Exception, response[:message] if status.failure?
|
53
|
+
end
|
54
|
+
|
55
|
+
def show_deployment(id)
|
56
|
+
status, response, headers = client.get("#{EPC::Config::DEPLOYMENTS_PATH}/#{id}/status")
|
57
|
+
@status=status
|
58
|
+
if status.successful?
|
59
|
+
return status, nil, response[:status]
|
60
|
+
else
|
61
|
+
return status, response[:error_code], nil
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def poll_for_deployment_statuses(id)
|
66
|
+
count = 0
|
67
|
+
failed = false
|
68
|
+
|
69
|
+
while count <= GIVEUP_TICKS
|
70
|
+
unless count > TICKER_TICKS
|
71
|
+
STDOUT.print('.')
|
72
|
+
STDOUT.flush
|
73
|
+
end
|
74
|
+
sleep(SLEEP_TIME)
|
75
|
+
|
76
|
+
status, code, deployment_status = show_deployment(id)
|
77
|
+
if status.successful? || (deployment_status == 404 && code == 901)
|
78
|
+
count += 1
|
79
|
+
next unless deployment_status == "STOPPED" || deployment_status == "UNDEPLOYED"
|
80
|
+
break
|
81
|
+
else
|
82
|
+
say("Poller failure [HTTP Error(#{status}): API error code (#{code})]")
|
83
|
+
say("Poller failed to get the deployment statuses. Aborting.")
|
84
|
+
failed = true
|
85
|
+
break
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
if deployment_status && !deployment_status.empty?
|
90
|
+
[true, deployment_status]
|
91
|
+
elsif failed
|
92
|
+
[false, nil]
|
93
|
+
else
|
94
|
+
if count > GIVEUP_TICKS
|
95
|
+
say("\nServer is taking too long to update the deployment statuses. Please contact the AgileMethods support team.")
|
96
|
+
end
|
97
|
+
[false, nil]
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
def display_statuses(deployment_status)
|
102
|
+
say("\nStatus = #{deployment_status}\n")
|
103
|
+
end
|
104
|
+
|
105
|
+
end
|
106
|
+
end
|