rightscale_selfservice 0.0.6 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- NDk4Mzg5NTVmNDMyMmNmNzJkYjRmMGZhODYzYWExZjBhNWM5NjlmZQ==
5
- data.tar.gz: !binary |-
6
- ZjMyYTE1ODk3OWNlNjMxMGNjODFjZWE3MDU1MjA1ZDhjMmNlYWMwNw==
2
+ SHA1:
3
+ metadata.gz: 6a27c81874af64515d925677e91207745fce71bd
4
+ data.tar.gz: 43a671aa1c541a3d4f4464de7c12ed98141a87a8
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- ZDJjMTAwNTQyYWZhZmZiMDhiZjhmMDE2MWRiOWY4MjBlMjQyMjk0NTk1NWJl
10
- NTg4ZTFlOGIzNWRmMzI0MWQ5N2RkZjgwOTBiYWI1M2EyZTIwMWRjYzEwYjU5
11
- OTcyZDAxYzNhMDgyNGMyN2RlMzQ2MGNhMjc0Y2UzMmQ1YmJhMWE=
12
- data.tar.gz: !binary |-
13
- NTczMjBmOTUyNDBjZTAxODgyNWVjOGYzYmEzNDI5OWU3MWI5ZTEyNjQzNDRk
14
- YmUxNDc5ZDdiNzQ1ZDIxZDc5ZGYxMDBkMWQwNjMzYmNhNGVkNTFiZmIwYzA2
15
- OThiZTAxNzc3MDgwOTkxNjZhNTZjYmViMzgwODVlZWJkM2Q2ZWM=
6
+ metadata.gz: 803f07b64839affb10a1f86af38a3dfa506239e6009d4536d7871efe7b92c0a7808a2c5ab488599b64ae42f673d0cf221d55efabd17b45082165e5dd81d6a9e5
7
+ data.tar.gz: 8151278084ae6d0c821926a3c9ee86dd65ec0b2c12380ca757563175d2360f5b0fbb3656bb92c08295fbee3c37593ec04460fbd7a889cba883de9dcffb224620
@@ -41,6 +41,7 @@ module RightScaleSelfService
41
41
  shell = Thor::Shell::Color.new
42
42
  message = "Failed to list executions\n\n#{RightScaleSelfService::Api::Client.format_error(e)}"
43
43
  logger.error(shell.set_color message, :red)
44
+ exit 1
44
45
  end
45
46
  end
46
47
 
@@ -62,6 +63,7 @@ module RightScaleSelfService
62
63
  shell = Thor::Shell::Color.new
63
64
  message = "Failed to show execution id #{id}\n\n#{RightScaleSelfService::Api::Client.format_error(e)}"
64
65
  logger.error(shell.set_color message, :red)
66
+ exit 1
65
67
  end
66
68
  end
67
69
 
@@ -42,11 +42,12 @@ module RightScaleSelfService
42
42
  shell = Thor::Shell::Color.new
43
43
  message = "Failed to create operation \"#{operation_name}\" on execution id \"#{execution_id}\"\n\n#{RightScaleSelfService::Api::Client.format_error(e)}"
44
44
  logger.error(shell.set_color message, :red)
45
+ exit 1
45
46
  end
46
47
  end
47
48
 
48
49
  desc "list", "Lists all operations, optionally filtered by --filter and/or --property"
49
- option :filter, :type => :array, :desc => "Filters to apply see (https://s3.amazonaws.com/rs_api_docs/selfservice/manager/index.html#/1.0/controller/V1::Controller::Operation/index)"
50
+ option :filter, :type => :array, :desc => "Filters to apply see (http://reference.rightscale.com/selfservice/manager/index.html#/1.0/controller/V1::Controller::Operation/index)"
50
51
  option :property, :type => :array, :desc => "When supplied, only the specified properties will be displayed. By default the entire response is supplied."
51
52
  def list()
52
53
  params = {}
@@ -68,6 +69,7 @@ module RightScaleSelfService
68
69
  shell = Thor::Shell::Color.new
69
70
  message = "Failed to list operations\n\n#{RightScaleSelfService::Api::Client.format_error(e)}"
70
71
  logger.error(shell.set_color message, :red)
72
+ exit 1
71
73
  end
72
74
  end
73
75
  end
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2014 Ryan Geyer
1
+ # Copyright (c) 2014-2016 Ryan Geyer
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining a copy of
4
4
  # this software and associated documentation files (the "Software"), to deal in
@@ -53,6 +53,7 @@ module RightScaleSelfService
53
53
  shell = Thor::Shell::Color.new
54
54
  message = "Failed to compile template\n\n#{RightScaleSelfService::Api::Client.format_error(e)}"
55
55
  logger.error(shell.set_color message, :red)
56
+ exit 1
56
57
  end
57
58
  end
58
59
 
@@ -65,9 +66,16 @@ module RightScaleSelfService
65
66
  template = RightScaleSelfService::Utilities::Template.preprocess(source_filepath)
66
67
  client = get_api_client()
67
68
 
68
- matches = template.match(/^name\s*"(?<name>.*)"/)
69
- tmp_file = matches["name"].gsub("/","-").gsub(" ","-")
70
- name = matches["name"]
69
+ matches = template.match(/^name\s*['"](?<name>.*)['"]/)
70
+ if matches && matches.names.include?("name")
71
+ tmp_file = matches["name"].gsub("/","-").gsub(" ","-")
72
+ name = matches["name"]
73
+ else
74
+ shell = Thor::Shell::Color.new
75
+ message = "Unable to find the \"name\" property of the CAT. Make sure you have added the necessary header to your CAT file."
76
+ logger.error(shell.set_color message, :red)
77
+ return
78
+ end
71
79
 
72
80
  logger.info("Fetching a list of existing templates to see if \"#{name}\" exists...")
73
81
 
@@ -94,6 +102,7 @@ module RightScaleSelfService
94
102
  shell = Thor::Shell::Color.new
95
103
  message = "Failed to update or create template\n\n#{RightScaleSelfService::Api::Client.format_error(e)}"
96
104
  logger.error(shell.set_color message, :red)
105
+ exit 1
97
106
  ensure
98
107
  tmpfile.close!()
99
108
  end
@@ -113,25 +122,31 @@ module RightScaleSelfService
113
122
  response = client.designer.template.publish(publish_params)
114
123
  logger.info("Successfully published template.")
115
124
  rescue RestClient::ExceptionWithResponse => e
116
- if e.http_code == 409 && @options["override"]
117
- logger.warn("Template id \"#{template_id}\" has already been published, but --override was set so we'll try to publish again with the overridden_application_href parameter.")
118
- begin
119
- app_response = client.catalog.application.index()
120
- applications = JSON.parse(app_response.body)
121
- matching_apps = applications.select{|a| a["template_info"]["href"] == template_href}
122
- if matching_apps == 0
123
- logger.error(shell.set_color "Unable to find the published application for template id \"#{template_id}\"")
124
- else
125
- publish_params[:overridden_application_href] = matching_apps.first["href"]
126
- retry
125
+ if e.http_code == 409
126
+ if @options["override"]
127
+ logger.warn("Template id \"#{template_id}\" has already been published, but --override was set so we'll try to publish again with the overridden_application_href parameter.")
128
+ begin
129
+ app_response = client.catalog.application.index()
130
+ applications = JSON.parse(app_response.body)
131
+ matching_apps = applications.select{|a| a["template_info"]["href"] == template_href}
132
+ if matching_apps == 0
133
+ logger.error(shell.set_color "Unable to find the published application for template id \"#{template_id}\"")
134
+ else
135
+ publish_params[:overridden_application_href] = matching_apps.first["href"]
136
+ retry
137
+ end
138
+ rescue RestClient::ExceptionWithResponse => e
139
+ message = "Failed to get a list of existing published templates\n\n#{RightScaleSelfService::Api::Client.format_error(e)}"
140
+ logger.error(shell.set_color message, :red)
141
+ exit 1
127
142
  end
128
- rescue RestClient::ExceptionWithResponse => e
129
- message = "Failed to get a list of existing published templates\n\n#{RightScaleSelfService::Api::Client.format_error(e)}"
130
- logger.error(shell.set_color message, :red)
143
+ else
144
+ logger.error("Template id \"#{template_id}\" has already been published, and --override was not set so it will not be over written. If you really want to replace the published template, simply specify --override when running this command.")
131
145
  end
132
146
  else
133
147
  message = "Failed to publish template\n\n#{RightScaleSelfService::Api::Client.format_error(e)}"
134
148
  logger.error(shell.set_color message, :red)
149
+ exit 1
135
150
  end
136
151
  end
137
152
  end
@@ -153,6 +168,7 @@ module RightScaleSelfService
153
168
  shell = Thor::Shell::Color.new
154
169
  message = "Failed to list templates\n\n#{RightScaleSelfService::Api::Client.format_error(e)}"
155
170
  logger.error(shell.set_color message, :red)
171
+ exit 1
156
172
  end
157
173
  end
158
174
 
@@ -178,6 +194,7 @@ module RightScaleSelfService
178
194
  shell = Thor::Shell::Color.new
179
195
  message = "Failed to create execution from template\n\n#{RightScaleSelfService::Api::Client.format_error(e)}"
180
196
  logger.error(shell.set_color message, :red)
197
+ exit 1
181
198
  end
182
199
  end
183
200
 
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2014 Ryan Geyer
1
+ # Copyright (c) 2014-2016 Ryan Geyer
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining a copy of
4
4
  # this software and associated documentation files (the "Software"), to deal in
@@ -30,7 +30,7 @@ module RightScaleSelfService
30
30
  # @raise [Errno::ENOENT] If the file does not exist
31
31
  # @return [String] the content of the supplied file
32
32
  def self.file_to_str_and_validate(file)
33
- cat_str = File.open(File.expand_path(file), 'r') { |f| f.read }
33
+ cat_str = File.open(File.expand_path(file), 'r') { |f| f.read.force_encoding('UTF-8') }
34
34
  end
35
35
 
36
36
  # Returns a de duped hash of files to include by recursively parsing and
metadata CHANGED
@@ -1,55 +1,61 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rightscale_selfservice
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan J. Geyer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-27 00:00:00.000000000 Z
11
+ date: 2016-03-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0.19'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0.19'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rest-client
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '1.7'
34
+ - - "<"
35
+ - !ruby/object:Gem::Version
36
+ version: '1.8'
34
37
  type: :runtime
35
38
  prerelease: false
36
39
  version_requirements: !ruby/object:Gem::Requirement
37
40
  requirements:
38
- - - ~>
41
+ - - "~>"
39
42
  - !ruby/object:Gem::Version
40
43
  version: '1.7'
44
+ - - "<"
45
+ - !ruby/object:Gem::Version
46
+ version: '1.8'
41
47
  - !ruby/object:Gem::Dependency
42
48
  name: logger-better
43
49
  requirement: !ruby/object:Gem::Requirement
44
50
  requirements:
45
- - - ~>
51
+ - - "~>"
46
52
  - !ruby/object:Gem::Version
47
53
  version: '0.1'
48
54
  type: :runtime
49
55
  prerelease: false
50
56
  version_requirements: !ruby/object:Gem::Requirement
51
57
  requirements:
52
- - - ~>
58
+ - - "~>"
53
59
  - !ruby/object:Gem::Version
54
60
  version: '0.1'
55
61
  description: A rubygem with a buncha useful CLI bits for RightScale Self Service,
@@ -89,17 +95,17 @@ require_paths:
89
95
  - lib
90
96
  required_ruby_version: !ruby/object:Gem::Requirement
91
97
  requirements:
92
- - - ! '>='
98
+ - - ">="
93
99
  - !ruby/object:Gem::Version
94
100
  version: '0'
95
101
  required_rubygems_version: !ruby/object:Gem::Requirement
96
102
  requirements:
97
- - - ! '>='
103
+ - - ">="
98
104
  - !ruby/object:Gem::Version
99
105
  version: '0'
100
106
  requirements: []
101
107
  rubyforge_project:
102
- rubygems_version: 2.2.2
108
+ rubygems_version: 2.6.1
103
109
  signing_key:
104
110
  specification_version: 4
105
111
  summary: A rubygem with a buncha useful CLI bits for RightScale Self Service, including