ops_manager_cli 0.7.1 → 0.7.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8992b156cebae9e672d078b6da9b8657a650b093
4
- data.tar.gz: 70fab26214ffab2248756aa0e281fb287acd0e5e
3
+ metadata.gz: ee5a9bff7eaf8b7173c9e4e4b5d2bfa95cad310e
4
+ data.tar.gz: 9f167f4715184828677892aabbfcf6f2bf0c2bce
5
5
  SHA512:
6
- metadata.gz: c2e769b03f59448e5e415f141d2dac8d6009ae272c748c20aabb98b8c6ea6b70d38ada89d20c335e13daafe79fbb9ec9a44be775a7ca3750d69396a20459606e
7
- data.tar.gz: 3ef3595a66344221983bdde63e1c770a3422453286656bdf572f2d8b4f66c6e8a4e01ed8549e2bd4672246c4f508e3d789fcee5542fd5f67acc69f138f07d201
6
+ metadata.gz: e435c487df21a31cd91e5b2eb1f96faa8e55b11470f4b156d821de0829ef45e084c117ba009e9aa69be64e29c05014b63a18643ea21b3040c5200837d0af6d93
7
+ data.tar.gz: 295e443dd6b68eb53ef2f882cc8169e4dc8cc6d7deafe59c90b72ce31674d6875d01c593914c957f287044d3a7056039ee0bfd9ca8331d100ebbcde6dca492c0
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.2.3
1
+ 2.4.1
data/CHANGELOG.md CHANGED
@@ -1,5 +1,101 @@
1
1
  # Change Log
2
2
 
3
+
4
+ ## [v0.7.14](https://github.com/compozed/ops_manager_cli/tree/v0.7.14 (2019-01-21)
5
+ [Full Changelog](https://github.com/compozed/ops_manager_cli/compare/v0.7.13...v0.7.14)
6
+
7
+ AWS appliance deployments no longer require the `ami_mapping_file`. Instead you must do
8
+ the mapping lookup (if needed) prior to calling opsman, and pass it an explicit `image_id`
9
+ option, pointing `ops_manager_cli` at a custom AMI. This allows it to easily support deploying
10
+ OpsManager using an encrypted AMI.
11
+
12
+ ## [v0.7.13](https://github.com/compozed/ops_manager_cli/tree/v0.7.13 (2019-01-08)
13
+ [Full Changelog](https://github.com/compozed/ops_manager_cli/compare/v0.7.12...v0.7.13)
14
+
15
+ Fixes a bug when upgrading an opsmanager VM that has Xenial stemcells on it
16
+
17
+ ## [v0.7.12]://github.com/compozed/ops_manager_cli/tree/v0.7.12) (2018-10-29)
18
+ [Full Changelog](https://github.com/compozed/ops_manager_cli/compare/v0.7.11...v0.7.12)
19
+
20
+ - Adds support for deploying multiple tiles (but not all) at once. This is useful for
21
+ scenarios like deploying PAS at the same time as Isolation Segments or Windows Runtime
22
+ tiles. Instead of specifying `single_tile_deployment` in your config, specify `selected_deployments`,
23
+ with its value being a list of all product guids to deploy:
24
+
25
+ ```
26
+ selected_deployments:
27
+ - product-guid-1234
28
+ - other-product-5678
29
+ ```
30
+
31
+
32
+ ## [v0.7.11]://github.com/compozed/ops_manager_cli/tree/v0.7.11) (2018-10-16)
33
+ [Full Changelog](https://github.com/compozed/ops_manager_cli/compare/v0.7.10...v0.7.11)
34
+
35
+ - Hides VM extensions from get-director-template and get-product-template commands, so
36
+ that they can be managed via the `resource_config` + `vm_extensions` apis in Ops Manager
37
+ separately.
38
+
39
+ ## [v0.7.10]://github.com/compozed/ops_manager_cli/tree/v0.7.10) (2018-10-8)
40
+ [Full Changelog](https://github.com/compozed/ops_manager_cli/compare/v0.7.9...v0.7.10)
41
+
42
+ - Fixes a bug uploading stemcells when using single-tile-deployments causing all tiles to
43
+ be assigned a stemcell, instead of the deployment targeted with single-tile-deployments
44
+ - Support handling CF::UAA::HTTPException when checking for existing Ops Managers
45
+ - Re-resolve bug related to deploying to AWS using instance profiles based on new Fog code
46
+
47
+ ## [v0.7.9]://github.com/compozed/ops_manager_cli/tree/v0.7.9) (2018-06-18)
48
+ [Full Changelog](https://github.com/compozed/ops_manager_cli/compare/v0.7.8...v0.7.9)
49
+
50
+ - Adds error checking when ovftool fails to deploy the OVA to VCenter.
51
+
52
+ ## [v0.7.8]://github.com/compozed/ops_manager_cli/tree/v0.7.8) (2018-06-18)
53
+ [Full Changelog](https://github.com/compozed/ops_manager_cli/compare/v0.7.6...v0.7.8)
54
+
55
+ - `ops_manager` now supports single-product deployments via the `deploy_products` key in the
56
+ Ops Manager API (requires Ops Manager 2.2+). Just add `single_tile_deploy: true` to the deploy
57
+ config file.
58
+
59
+ ## [v0.7.6](https://github.com/compozed/ops_manager_cli/tree/v0.7.6) (2018-06-18)
60
+ [Full Changelog](https://github.com/compozed/ops_manager_cli/compare/v0.7.5...v0.7.6)
61
+
62
+ **Closed issues:**
63
+
64
+ - Upgrading Product Issue - The enabled\_errands parameter is no longer supported [\#35](https://github.com/compozed/ops_manager_cli/issues/35)
65
+ - Ops Manager cannot deploy appliance when there is no Ops Manager appliance deployed [\#31](https://github.com/compozed/ops_manager_cli/issues/31)
66
+ - OpsMAnagerCli should check if there are pending changes in the current installation before performing an opsman upgrade [\#30](https://github.com/compozed/ops_manager_cli/issues/30)
67
+ - director generator does not remove fixed stemcell versions [\#18](https://github.com/compozed/ops_manager_cli/issues/18)
68
+ - Remove ovftools dependency and use rbvmomi instead to deploy appliance [\#14](https://github.com/compozed/ops_manager_cli/issues/14)
69
+
70
+ **Merged pull requests:**
71
+
72
+ - Make it work with ruby other than 2.4 [\#38](https://github.com/compozed/ops_manager_cli/pull/38) ([teancom](https://github.com/teancom))
73
+ - Remove pem values from product templates [\#37](https://github.com/compozed/ops_manager_cli/pull/37) ([suppalapati13](https://github.com/suppalapati13))
74
+
75
+ ## [v0.7.5](https://github.com/compozed/ops_manager_cli/tree/v0.7.5) (2018-01-18)
76
+ [Full Changelog](https://github.com/compozed/ops_manager_cli/compare/v0.7.4...v0.7.5)
77
+
78
+ ## [v0.7.4](https://github.com/compozed/ops_manager_cli/tree/v0.7.4) (2017-11-22)
79
+ [Full Changelog](https://github.com/compozed/ops_manager_cli/compare/v0.7.2...v0.7.4)
80
+
81
+ ## [v0.7.2](https://github.com/compozed/ops_manager_cli/tree/v0.7.2) (2017-11-03)
82
+ [Full Changelog](https://github.com/compozed/ops_manager_cli/compare/v0.7.1...v0.7.2)
83
+
84
+ ## [v0.7.1](https://github.com/compozed/ops_manager_cli/tree/v0.7.1) (2017-10-25)
85
+ [Full Changelog](https://github.com/compozed/ops_manager_cli/compare/v0.7.0...v0.7.1)
86
+
87
+ ## [v0.7.0](https://github.com/compozed/ops_manager_cli/tree/v0.7.0) (2017-10-20)
88
+ [Full Changelog](https://github.com/compozed/ops_manager_cli/compare/v0.5.4...v0.7.0)
89
+
90
+ **Closed issues:**
91
+
92
+ - OpsMAnagerCli should support new errands endpoint in versions \>= 1.10 [\#32](https://github.com/compozed/ops_manager_cli/issues/32)
93
+
94
+ **Merged pull requests:**
95
+
96
+ - Added support for ops\_manager\_cli to deploy via AWS [\#34](https://github.com/compozed/ops_manager_cli/pull/34) ([geofffranks](https://github.com/geofffranks))
97
+ - Add pending-changes CLI command [\#26](https://github.com/compozed/ops_manager_cli/pull/26) ([RMeharg](https://github.com/RMeharg))
98
+
3
99
  ## [v0.5.4](https://github.com/compozed/ops_manager_cli/tree/v0.5.4) (2017-06-27)
4
100
  [Full Changelog](https://github.com/compozed/ops_manager_cli/compare/v0.5.3...v0.5.4)
5
101
 
@@ -81,4 +177,4 @@
81
177
  ## [v0.1.1](https://github.com/compozed/ops_manager_cli/tree/v0.1.1) (2016-05-06)
82
178
 
83
179
 
84
- \* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
180
+ \* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
data/Dockerfile CHANGED
@@ -1,29 +1,38 @@
1
- FROM ruby:2.3.0
1
+ FROM ruby:2.4.1
2
2
 
3
3
  ENV GEM_NAME ops_manager_cli
4
- ENV GEM_VERSION 0.7.1
5
- ENV OVFTOOL_VERSION 4.1.0-2459827
4
+ ENV GEM_VERSION 0.7.14
5
+ ENV SPRUCE_VERSION 1.19.1
6
+ ENV JQ_VERSION 1.5
7
+ ENV OM_VERSION 0.42.0
8
+ ENV OVFTOOL_VERSION 4.3.0-7948156
6
9
  ENV OVFTOOL_INSTALLER VMware-ovftool-${OVFTOOL_VERSION}-lin.x86_64.bundle
7
10
  ARG DOWNLOAD_URL
8
11
 
12
+ # ================== Installs sshpass ===============
13
+ #RUN echo "deb http://httpredir.debian.org/debian jessie utils" >> sources.list
14
+ RUN apt-get update \
15
+ && apt-get install -y sshpass unzip \
16
+ && rm -rf /var/lib/apt/lists/*
17
+
9
18
  # ================== Installs OVF tools ==============
10
- RUN echo $DOWNLOAD_URL
11
- RUN wget -v ${DOWNLOAD_URL} \
12
- && sh ${OVFTOOL_INSTALLER} -p /usr/local --eulas-agreed --required \
13
- && rm -f ${OVFTOOL_INSTALLER}*
19
+ RUN wget -q --no-check-certificate ${DOWNLOAD_URL} \
20
+ && sh ${OVFTOOL_INSTALLER} -p /usr/local --eulas-agreed --required \
21
+ && rm -f ${OVFTOOL_INSTALLER}*
14
22
 
15
23
  # ================== Installs Spruce ==============
16
- RUN wget -v --no-check-certificate https://github.com/geofffranks/spruce/releases/download/v1.0.1/spruce_1.0.1_linux_amd64.tar.gz \
17
- && tar -xvf spruce_1.0.1_linux_amd64.tar.gz \
18
- && chmod +x /spruce_1.0.1_linux_amd64/spruce \
19
- && ln -s /spruce_1.0.1_linux_amd64/spruce /usr/bin/.
24
+ RUN wget -v -O /usr/local/bin/spruce --no-check-certificate https://github.com/geofffranks/spruce/releases/download/v${SPRUCE_VERSION}/spruce-linux-amd64 \
25
+ && chmod +x /usr/local/bin/spruce
20
26
 
21
27
  # ================== Installs JQ ==============
22
- RUN wget -v -O /usr/local/bin/jq --no-check-certificate https://github.com/stedolan/jq/releases/download/jq-1.5/jq-linux64
23
- RUN chmod +x /usr/local/bin/jq
28
+ RUN wget -q -O /usr/local/bin/jq --no-check-certificate https://github.com/stedolan/jq/releases/download/jq-${JQ_VERSION}/jq-linux64 \
29
+ && chmod +x /usr/local/bin/jq
30
+
31
+ #============ Installs Om ============
32
+ RUN wget -q -O /usr/local/bin/om --no-check-certificate https://github.com/pivotal-cf/om/releases/download/${OM_VERSION}/om-linux \
33
+ && chmod +x /usr/local/bin/om
24
34
 
25
35
  # ================== Installs ops_manager_cli gem ==============
26
36
  COPY pkg/${GEM_NAME}-${GEM_VERSION}.gem /tmp/
27
-
28
- RUN gem install /tmp/${GEM_NAME}-${GEM_VERSION}.gem
29
-
37
+ RUN echo ':ssl_verify_mode: 0' > ~/.gemrc \
38
+ && gem install /tmp/${GEM_NAME}-${GEM_VERSION}.gem
data/Rakefile CHANGED
@@ -4,7 +4,9 @@ require 'github_changelog_generator/task'
4
4
 
5
5
  RSpec::Core::RakeTask.new(:spec)
6
6
 
7
- GitHubChangelogGenerator::RakeTask.new(:changelog)
7
+ GitHubChangelogGenerator::RakeTask.new :changelog do |config|
8
+ config.max_issues = 5
9
+ end
8
10
 
9
11
  task :default => :spec
10
12
  task :release => :changelog
@@ -153,7 +153,7 @@ class OpsManager
153
153
  Net::HTTP.new(uri.host, uri.port).tap do |http|
154
154
  http.use_ssl = true
155
155
  http.verify_mode = OpenSSL::SSL::VERIFY_NONE
156
- http.read_timeout = 1200
156
+ http.read_timeout = 1800
157
157
 
158
158
  ctx = OpenSSL::SSL::SSLContext.new
159
159
  ctx.ssl_version = :TLSv1_2
@@ -47,7 +47,7 @@ class OpsManager
47
47
 
48
48
  def get_installation_assets
49
49
  opts = { write_to: "installation_assets.zip" }
50
- say_green '====> Download installation assets ...'
50
+ print_green '====> Download installation assets ...'
51
51
  res = authenticated_get("/api/v0/installation_asset_collection", opts)
52
52
  say_green 'done'
53
53
  res
@@ -107,12 +107,16 @@ class OpsManager
107
107
  end
108
108
 
109
109
  def upload_product(filepath)
110
- file = "#{filepath}"
111
- cmd = "curl -s -k \"https://#{target}/api/v0/available_products\" -F 'product[file]=@#{file}' -X POST -H 'Authorization: Bearer #{access_token}'"
112
- logger.info "running cmd: #{cmd}"
113
- body = `#{cmd}`
114
- logger.info "Upload product response: #{body}"
115
- raise OpsManager::ProductUploadError if body.include? "error"
110
+ return unless filepath
111
+ tar = UploadIO.new(filepath, 'multipart/form-data')
112
+ print_green "====> Uploading product: #{filepath} ..."
113
+ #print "====> Uploading product ...".green
114
+ opts = { "product[file]" => tar }
115
+ res = authenticated_multipart_post("/api/v0/available_products" , opts)
116
+
117
+ raise OpsManager::ProductUploadError.new(res.body) unless res.code == '200'
118
+ say_green 'done'
119
+ res
116
120
  end
117
121
 
118
122
  def get_available_products
@@ -121,17 +125,22 @@ class OpsManager
121
125
 
122
126
  def get_diagnostic_report
123
127
  authenticated_get("/api/v0/diagnostic_report")
124
- rescue Errno::ETIMEDOUT , Errno::EHOSTUNREACH, Net::HTTPFatalError, Net::OpenTimeout, HTTPClient::ConnectTimeoutError
128
+ rescue Errno::ETIMEDOUT , Errno::EHOSTUNREACH, Net::HTTPFatalError, Net::OpenTimeout, HTTPClient::ConnectTimeoutError, CF::UAA::HTTPException
125
129
  nil
126
130
  end
127
131
 
128
- def import_stemcell(filepath)
132
+ def import_stemcell(filepath, products = "all")
129
133
  return unless filepath
130
134
  tar = UploadIO.new(filepath, 'multipart/form-data')
131
135
  print_green "====> Uploading stemcell: #{filepath} ..."
136
+
132
137
  opts = { "stemcell[file]" => tar }
133
- res = nil
138
+ # if we specify specific products, don't update stemcell associations everywhere
139
+ if products != "all"
140
+ opts["stemcell[floating]"] = false
141
+ end
134
142
 
143
+ res = nil
135
144
  3.times do
136
145
  res = authenticated_multipart_post("/api/v0/stemcells", opts)
137
146
  case res.code
@@ -139,8 +148,8 @@ class OpsManager
139
148
  when '503' ; sleep(60)
140
149
  end
141
150
  end
142
-
143
151
  raise OpsManager::StemcellUploadError.new(res.body) unless res.code == '200'
152
+
144
153
  say_green 'done'
145
154
  res
146
155
  end
@@ -6,8 +6,6 @@ class OpsManager
6
6
  class AWS < Base
7
7
 
8
8
  def deploy_vm
9
- image_id = ::YAML.load_file(ami_mapping_file)[config[:opts][:region]]
10
-
11
9
  server = connection.servers.create(
12
10
  block_device_mapping: [{
13
11
  'DeviceName' => '/dev/xvda',
@@ -16,7 +14,7 @@ class OpsManager
16
14
  key_name: config[:opts][:ssh_keypair_name],
17
15
  flavor_id: config[:opts][:instance_type],
18
16
  subnet_id: config[:opts][:subnet_id],
19
- image_id: image_id,
17
+ image_id: config[:opts][:image_id],
20
18
  private_ip_address: config[:ip],
21
19
  security_group_ids: security_group_ids,
22
20
  availability_zone: config[:opts][:availability_zone],
@@ -40,7 +38,7 @@ class OpsManager
40
38
  # Create ami of stopped server
41
39
  response = connection.create_image(server.id, "#{name}-backup", "Backup of #{name}")
42
40
  image = connection.images.get( response.data[:body]['imageId'])
43
- image.wait_for { image.state == "available" }
41
+ image.wait_for(timeout=36000) { image.state == "available" }
44
42
  if image.state != "available"
45
43
  fail "Error creating backup AMI, bailing out before destroying the VM"
46
44
  end
@@ -73,8 +71,6 @@ class OpsManager
73
71
  @connection ||= Fog::Compute.new({
74
72
  provider: config[:provider],
75
73
  use_iam_profile: config[:opts][:use_iam_profile],
76
- aws_access_key_id: "",
77
- aws_secret_access_key: "",
78
74
  })
79
75
  else
80
76
  @connection ||= Fog::Compute.new({
@@ -16,7 +16,8 @@ class OpsManager
16
16
 
17
17
  private
18
18
  def vm_name
19
- @vm_name ||= "#{config[:name]}-#{config[:desired_version]}"
19
+ desired_version = OpsManager::Semver.new(config[:desired_version])
20
+ @vm_name ||= "#{config[:name]}-#{desired_version}"
20
21
  end
21
22
  end
22
23
  end
@@ -12,13 +12,21 @@ class OpsManager
12
12
 
13
13
  def deploy_vm
14
14
  print '====> Deploying ova ...'.green
15
- vcenter_target= "vi://#{vcenter_username}:#{vcenter_password}@#{config[:opts][:vcenter][:host]}/#{config[:opts][:vcenter][:datacenter]}/host/#{config[:opts][:vcenter][:cluster]}"
16
- cmd = "echo yes | ovftool --acceptAllEulas --noSSLVerify --powerOn --X:waitForIp --net:\"Network 1=#{config[:opts][:portgroup]}\" --name=#{vm_name} -ds=#{config[:opts][:datastore]} --prop:ip0=#{config[:ip]} --prop:netmask0=#{config[:opts][:netmask]} --prop:gateway=#{config[:opts][:gateway]} --prop:DNS=#{config[:opts][:dns]} --prop:ntp_servers=#{config[:opts][:ntp_servers].join(',')} --prop:admin_password=#{config[:password]} #{config[:opts][:ova_path]} #{vcenter_target}"
17
15
  logger.info "Running: #{cmd}"
18
16
  logger.info `#{cmd}`
17
+ if ! $?.success?
18
+ puts 'FAILED. Your old ops manager is offline, and a new one was not provisioned.'.red
19
+ puts 'You may want to re-run with DEBUG=true set to figure out what failed...'
20
+ raise "Failure in ovftool"
21
+ end
19
22
  puts 'done'.green
20
23
  end
21
24
 
25
+ def cmd
26
+ vcenter_target= "vi://#{vcenter_username}:#{vcenter_password}@#{config[:opts][:vcenter][:host]}/#{config[:opts][:vcenter][:datacenter]}/host/#{config[:opts][:vcenter][:cluster]}"
27
+ "echo yes | ovftool --acceptAllEulas --noSSLVerify --powerOn --X:waitForIp --net:\"Network 1=#{config[:opts][:portgroup]}\" --name=#{vm_name} -ds=#{config[:opts][:datastore]} --prop:ip0=#{config[:ip]} --prop:netmask0=#{config[:opts][:netmask]} --prop:gateway=#{config[:opts][:gateway]} --prop:DNS=#{config[:opts][:dns]} --prop:ntp_servers=#{config[:opts][:ntp_servers].join(',')} --prop:admin_password=#{config[:password]} #{config[:opts][:ova_path]} #{vcenter_target}"
28
+ end
29
+
22
30
  def stop_current_vm(name)
23
31
  print "====> Stopping vm #{name} ...".green
24
32
  dc = vim.serviceInstance.find_datacenter(config[:opts][:vcenter][:datacenter])
@@ -38,7 +38,13 @@ class OpsManager::ApplianceDeployment
38
38
  when current_version == desired_version then
39
39
  if pending_changes?
40
40
  puts "OpsManager at #{config[:ip]} version has pending changes. Applying changes...".green
41
- OpsManager::InstallationRunner.trigger!.wait_for_result
41
+ products = "all"
42
+ if config[:selected_deployments]
43
+ products = config[:selected_deployments]
44
+ elsif config[:single_tile_deploy]
45
+ products = "none"
46
+ end
47
+ OpsManager::InstallationRunner.trigger!(products).wait_for_result
42
48
  else
43
49
  puts "OpsManager at #{config[:ip]} version is already #{config[:desired_version]}. Skiping ...".green
44
50
  end
@@ -75,13 +81,26 @@ class OpsManager::ApplianceDeployment
75
81
  upload_installation_assets
76
82
  wait_for_uaa
77
83
  provision_stemcells
78
- OpsManager::InstallationRunner.trigger!.wait_for_result
84
+ products = "all"
85
+ if config[:selected_deployments]
86
+ products = config[:selected_deployments]
87
+ elsif config[:single_tile_deploy]
88
+ products = "none"
89
+ end
90
+ OpsManager::InstallationRunner.trigger!(products).wait_for_result
79
91
  end
80
92
 
81
93
  def list_current_stemcells
82
94
  JSON.parse(installation_settings).fetch('products').inject([]) do |a, p|
83
- a << p['stemcell'].fetch('version')
84
- end
95
+ product_name = "stemcells"
96
+ if p['stemcell'].fetch('os') =~ /windows/i
97
+ product_name = "stemcells-windows-server"
98
+ end
99
+ if p['stemcell'].fetch('os') =~ /ubuntu-xenial/i
100
+ product_name = "stemcells-ubuntu-xenial"
101
+ end
102
+ a << { version: p['stemcell'].fetch('version'), product: product_name }
103
+ end.uniq
85
104
  end
86
105
 
87
106
  # Finds available stemcell's pivotal network release.
@@ -89,9 +108,9 @@ class OpsManager::ApplianceDeployment
89
108
  # #
90
109
  # @param version [String] the version number, eg: '2362.17'
91
110
  # @return release_id [Integer] the pivotal netowkr release id of the found stemcell.
92
- def find_stemcell_release(version)
111
+ def find_stemcell_release(version, product_name)
93
112
  version = OpsManager::Semver.new(version)
94
- releases = stemcell_releases.collect do |r|
113
+ releases = stemcell_releases(product_name).collect do |r|
95
114
  {
96
115
  release_id: r['id'],
97
116
  version: OpsManager::Semver.new(r['version']),
@@ -109,8 +128,8 @@ class OpsManager::ApplianceDeployment
109
128
  # @param release_id [String] the version number, eg: '2362.17'
110
129
  # @param filename [Regex] the version number, eg: /vsphere/
111
130
  # @return id and name [Array] the pivotal network file ID and Filename for the matching stemcell.
112
- def find_stemcell_file(release_id, filename)
113
- files = JSON.parse(get_product_release_files('stemcells', release_id).body).fetch('product_files')
131
+ def find_stemcell_file(release_id, filename, product_name)
132
+ files = JSON.parse(get_product_release_files(product_name, release_id).body).fetch('product_files')
114
133
  file = files.select{ |r| r.fetch('aws_object_key') =~ filename }.first
115
134
  return file['id'], file['aws_object_key'].split('/')[-1]
116
135
  end
@@ -118,18 +137,21 @@ class OpsManager::ApplianceDeployment
118
137
  # Lists all the available stemcells in the current installation_settings.
119
138
  # Downloads those stemcells.
120
139
  def download_current_stemcells
121
- puts "Downloading existing stemcells ...".green
140
+ print "====> Downloading existing stemcells ...".green
141
+ puts "no stemcells found".green if list_current_stemcells.empty?
122
142
  FileUtils.mkdir_p current_stemcell_dir
123
- list_current_stemcells.each do |stemcell_version|
124
- release_id = find_stemcell_release(stemcell_version)
125
- accept_product_release_eula('stemcells', release_id )
143
+ list_current_stemcells.each do |stemcell_info|
144
+ stemcell_version = stemcell_info[:version]
145
+ product_name = stemcell_info[:product]
146
+ release_id = find_stemcell_release(stemcell_version, product_name)
147
+ accept_product_release_eula(product_name, release_id)
126
148
  stemcell_regex = /vsphere/
127
149
  if config[:provider] == "AWS"
128
150
  stemcell_regex = /aws/
129
151
  end
130
152
 
131
- file_id, file_name = find_stemcell_file(release_id, stemcell_regex)
132
- download_product_release_file('stemcells', release_id, file_id, write_to: "#{current_stemcell_dir}/#{file_name}")
153
+ file_id, file_name = find_stemcell_file(release_id, stemcell_regex, product_name)
154
+ download_product_release_file(product_name, release_id, file_id, write_to: "#{current_stemcell_dir}/#{file_name}")
133
155
  end
134
156
  end
135
157
 
@@ -211,12 +233,8 @@ class OpsManager::ApplianceDeployment
211
233
  @installation_settings ||= get_installation_settings.body
212
234
  end
213
235
 
214
- def get_stemcell_releases
215
- get_product_releases('stemcells')
216
- end
217
-
218
- def stemcell_releases
219
- @stemcell_releases ||= JSON.parse(get_stemcell_releases.body).fetch('releases')
236
+ def stemcell_releases(product_name)
237
+ JSON.parse(get_product_releases(product_name).body).fetch('releases')
220
238
  end
221
239
 
222
240
  def current_stemcell_dir
@@ -16,6 +16,7 @@ class OpsManager
16
16
  def expand_path_for!(*attrs)
17
17
  attrs.each do |attr|
18
18
  path = self[attr]
19
+ next if path.nil?
19
20
  self[attr] = if path =~ %r{^file://}
20
21
  path = Dir.glob(path.gsub!('file://','')).first
21
22
  "file://#{path}"
@@ -6,7 +6,7 @@ class OpsManager
6
6
  def initialize(config)
7
7
  super(config)
8
8
  validate_presence_of! :name, :desired_version
9
- expand_path_for! :stemcell
9
+ expand_path_for! :stemcell, :filepath
10
10
  end
11
11
  end
12
12
  end
@@ -7,10 +7,11 @@ class OpsManager
7
7
  installation_settings.delete(property_name)
8
8
  end
9
9
 
10
- %w{ director_ssl uaa_ssl uaa_credentials uaa_admin_user_credentials
11
- uaa_admin_client_credentials }.each do |property_name|
12
- product_template["products"][1].delete(property_name)
10
+ %w{ uaa_credentials uaa_admin_user_credentials uaa_admin_client_credentials }.each do |property_name|
11
+ product_template["products"].select {|p| p["identifier"] == "p-bosh"}.first.delete(property_name)
13
12
  end
13
+
14
+ installation_settings['infrastructure'].delete("vm_extensions")
14
15
 
15
16
  add_merging_strategy_for_networks
16
17
 
@@ -5,14 +5,14 @@ class OpsManager
5
5
  :get_staged_products, :get_staged_products_errands
6
6
  attr_reader :id
7
7
 
8
- def trigger!
9
- res = trigger_installation( :headers => {"Content-Type"=>"application/json"}, :body => body )
8
+ def trigger!(products = "all")
9
+ res = trigger_installation( :headers => {"Content-Type"=>"application/json"}, :body => body(products))
10
10
  @id = JSON.parse(res.body).fetch('install').fetch('id').to_i
11
11
  self
12
12
  end
13
13
 
14
- def self.trigger!
15
- new.trigger!
14
+ def self.trigger!(products = "all")
15
+ new.trigger!(products)
16
16
  end
17
17
 
18
18
  def wait_for_result
@@ -24,16 +24,28 @@ class OpsManager
24
24
  end
25
25
 
26
26
  private
27
- def body
28
- @body ||= {'errands' => errands, 'ignore_warnings' => true }.to_json
27
+ def body(products)
28
+ b = {'errands' => errands(products), 'ignore_warnings' => true }
29
+ if products != "all"
30
+ b["deploy_products"] = products
31
+ end
32
+ @body ||= b.to_json
29
33
  end
30
34
  def opsman_api
31
35
  @opsman_api ||= OpsManager::Api::Opsman.new
32
36
  end
33
37
 
34
- def errands
38
+ def errands(products)
35
39
  res = { }
36
- staged_products_guids.each do |product_guid|
40
+
41
+ if products == "none"
42
+ return res
43
+ end
44
+
45
+ if products == "all"
46
+ products = staged_products_guids
47
+ end
48
+ products.each do |product_guid|
37
49
  errands = errands_for(product_guid).keep_if { |an_errand| an_errand['post_deploy'] }
38
50
  errands.each { |e| res[product_guid] = {'run_post_deploy' => { e['name'] => true}}}
39
51
  end
@@ -7,13 +7,11 @@ class OpsManager
7
7
  end
8
8
 
9
9
  def self.logger
10
- @logger ||= Logger.new(STDOUT).tap do |l|
11
- l.level = log_level
12
- end
10
+ @logger ||= Logger.new(STDERR, level: log_level)
13
11
  end
14
12
 
15
- def self.logger=(logger)
16
- @logger = logger
13
+ def self.logger=(l)
14
+ @logger = l
17
15
  end
18
16
 
19
17
  private
@@ -26,7 +26,14 @@ class OpsManager
26
26
 
27
27
  def run
28
28
  OpsManager.target_and_login(config[:target], config[:username], config[:password])
29
- import_stemcell(config[:stemcell])
29
+ products = "all"
30
+ if config[:selected_deployments]
31
+ products = config[:selected_deployments]
32
+ elsif config[:single_tile_deploy]
33
+ products = [installation.guid]
34
+ end
35
+
36
+ import_stemcell(config[:stemcell], products)
30
37
 
31
38
  case
32
39
  when installation.nil? || forced_deployment?
@@ -43,12 +50,10 @@ class OpsManager
43
50
  end
44
51
 
45
52
  def upload
46
- print "====> Uploading product ...".green
47
53
  if ProductDeployment.exists?(config[:name], config[:desired_version])
48
- puts "product already exists".green
54
+ puts "====> Product already exists... skipping upload".green
49
55
  elsif config[:filepath]
50
56
  upload_product(config[:filepath])
51
- puts "done".green
52
57
  else
53
58
  puts "no filepath provided, skipping product upload.".green
54
59
  end
@@ -63,7 +68,14 @@ class OpsManager
63
68
  upload
64
69
  upgrade_product_installation(installation.guid, config[:desired_version])
65
70
  merge_product_installation_settings
66
- OpsManager::InstallationRunner.trigger!.wait_for_result
71
+
72
+ products = "all"
73
+ if config[:selected_deployments]
74
+ products = config[:selected_deployments]
75
+ elsif config[:single_tile_deploy]
76
+ products = [installation.guid]
77
+ end
78
+ OpsManager::InstallationRunner.trigger!(products).wait_for_result
67
79
 
68
80
  puts "====> Finish!".green
69
81
  end
@@ -79,7 +91,13 @@ class OpsManager
79
91
  upload
80
92
  add_to_installation
81
93
  merge_product_installation_settings
82
- OpsManager::InstallationRunner.trigger!.wait_for_result
94
+ products = "all"
95
+ if config[:selected_deployments]
96
+ products = config[:selected_deployments]
97
+ elsif config[:single_tile_deploy]
98
+ products = [installation.guid]
99
+ end
100
+ OpsManager::InstallationRunner.trigger!(products).wait_for_result
83
101
 
84
102
  puts "====> Finish!".green
85
103
  end
@@ -87,7 +105,7 @@ class OpsManager
87
105
 
88
106
  def merge_product_installation_settings
89
107
  get_installation_settings({write_to: '/tmp/is.yml'})
90
- puts `DEBUG=false spruce merge /tmp/is.yml #{config[:installation_settings_file]} > /tmp/new_is.yml`
108
+ puts `DEBUG=false DEFAULT_ARRAY_MERGE_KEY=identifier spruce merge /tmp/is.yml #{config[:installation_settings_file]} > /tmp/new_is.yml`
91
109
  upload_installation_settings('/tmp/new_is.yml')
92
110
  end
93
111
 
@@ -15,41 +15,42 @@ class OpsManager
15
15
  delete_from_product(property_name)
16
16
  end
17
17
 
18
- %w{ partitions vm_credentials guid }.each do |property_name|
18
+ %w{ partitions additional_vm_extensions vm_credentials guid }.each do |property_name|
19
19
  delete_from_jobs(property_name)
20
20
  end
21
21
 
22
- %w{ password secret salt private_key_pem }.each do |property_name|
22
+ %w{ password secret salt private_key_pem cert_pem }.each do |property_name|
23
23
  delete_value_from_job_properties(property_name)
24
24
  end
25
25
 
26
- %w{ secret private_key_pem }.each do |property_name|
26
+ %w{ secret private_key_pem cert_pem }.each do |property_name|
27
27
  delete_value_from_product_properties(property_name)
28
28
  end
29
29
 
30
- add_merging_strategy_for_jobs
31
- add_merging_strategy_for_job_properties
30
+ %w{ deployed }.each do |property_name|
31
+ delete_key_from_product_properties(property_name)
32
+ end
32
33
 
33
- { 'products' => [ "(( merge on identifier ))" , selected_product ] }
34
- end
34
+ %w{ deployed }.each do |property_name|
35
+ delete_key_from_job_properties(property_name)
36
+ end
35
37
 
36
- def generate_yml
37
- generate.to_yaml
38
- .gsub('"(( merge on identifier ))"', '(( merge on identifier ))')
39
- end
38
+ %w{ deployed }.each do |property_name|
39
+ delete_key_from_product_properties_options_properties(property_name)
40
+ end
40
41
 
41
- private
42
+ %w{ deployed }.each do |property_name|
43
+ delete_key_from_job_properties_records_properties(property_name)
44
+ end
42
45
 
43
- def add_merging_strategy_for_jobs
44
- selected_product['jobs'].unshift("(( merge on identifier ))")
46
+ { 'products' => [ selected_product ] }
45
47
  end
46
48
 
47
- def add_merging_strategy_for_job_properties
48
- selected_product['jobs'].each do |j|
49
- j['properties'].unshift("(( merge on identifier ))") if j['properties']
50
- end
49
+ def generate_yml
50
+ generate.to_yaml
51
51
  end
52
52
 
53
+ private
53
54
  def delete_from_product(name)
54
55
  selected_product.delete(name)
55
56
  end
@@ -81,6 +82,42 @@ class OpsManager
81
82
  end
82
83
  end
83
84
 
85
+ def delete_key_from_job_properties(name)
86
+ selected_product['jobs'].each do |j|
87
+ j.fetch('properties', []).each do |p|
88
+ p.delete(name)
89
+ end
90
+ end
91
+ end
92
+
93
+ def delete_key_from_product_properties(name)
94
+ selected_product.fetch('properties', []).each do |p|
95
+ p.delete(name)
96
+ end
97
+ end
98
+
99
+ def delete_key_from_product_properties_options_properties(name)
100
+ selected_product.fetch('properties',[]).each do |p|
101
+ p.fetch('options',[]).each do |o|
102
+ o.fetch('properties', []).each do |op|
103
+ op.delete(name)
104
+ end
105
+ end
106
+ end
107
+ end
108
+
109
+ def delete_key_from_job_properties_records_properties(name)
110
+ selected_product['jobs'].each do |j|
111
+ j.fetch('properties',[]).each do |p|
112
+ p.fetch('records',[]).each do |o|
113
+ o.fetch('properties', []).each do |op|
114
+ op.delete(name)
115
+ end
116
+ end
117
+ end
118
+ end
119
+ end
120
+
84
121
  def delete_value_from_job_properties(name)
85
122
  selected_product['jobs'].each do |j|
86
123
  j.fetch('properties', []).each do |p|
@@ -89,5 +126,15 @@ class OpsManager
89
126
  end
90
127
  end
91
128
  end
129
+
130
+ def delete_certs_from_template
131
+ selected_product['jobs'].each do |j|
132
+ j.fetch('properties',[]).each do |p|
133
+
134
+ end
135
+ end
136
+
137
+ end
138
+
92
139
  end
93
140
  end
@@ -1,3 +1,3 @@
1
1
  class OpsManager
2
- VERSION = "0.7.1"
2
+ VERSION = "0.7.14"
3
3
  end
data/specs.4.8 ADDED
Binary file
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ops_manager_cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.7.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - CompoZed
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-10-30 00:00:00.000000000 Z
11
+ date: 2019-01-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -252,6 +252,7 @@ files:
252
252
  - lib/ops_manager/semver.rb
253
253
  - lib/ops_manager/version.rb
254
254
  - ops_manager.gemspec
255
+ - specs.4.8
255
256
  homepage:
256
257
  licenses:
257
258
  - MIT
@@ -272,7 +273,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
272
273
  version: '0'
273
274
  requirements: []
274
275
  rubyforge_project:
275
- rubygems_version: 2.6.6
276
+ rubygems_version: 2.6.11
276
277
  signing_key:
277
278
  specification_version: 4
278
279
  summary: Performs Ops Manager deployments.