Pivotal/Cloud Foundry/OpsManager
Cloud Foundry | Cloud Foundry CLI | Apps | Tasks | Logs | OpsManager
Contents |
install packages via cli with om tools
It is best to always do this from within the CloudFoundry network as some of these packages can be rather large, a SSH session in Ops Manager is a great choice. However, if you have a fast connection which can upload GBs relatively quickly, you can do it from your local machine.
install om-tools
Start by installing om-tools, a cli tool for interacting with pivnet. Download the latest release from github (https://github.com/pivotal-cf/om/)
~$ wget https://github.com/pivotal-cf/om/releases/download/0.39.0/om-linux ~$ chmod +x ~/om-linux ~$ ln -s ~/om-linux /usr/local/bin/om ~$ source ~/.bash_profile ~$ om -version
install pivnet cli
Next we need to install the pivnet cli. Download the latest release from github (https://github.com/pivotal-cf/pivnet-cli/)
~$ wget https://github.com/pivotal-cf/pivnet-cli/releases/download/v0.0.53/pivnet-darwin-amd64-0.0.53 ~$ chmod +x ~/pivnet-darwin-amd64-0.0.53 ~$ ln -s ~/Git/pivnet-cli/pivnet-darwin-amd64-0.0.53 /usr/local/bin/pivnet ~$ source ~/.bash_profile ~$ pivnet -version
get pivnet token
Get your pivnet legacy token from here: https://login.run.pivotal.io/login
Click Username > Edit Profile > Look for LEGACY API TOKEN [DEPRECATED] > copy token.
Apply the API token and test the pivnet CLI
~$ pivnet login --api-token=h9482hd929dh2998hg ~$ pivnet products
Download Product tile
While you can very easily do this by simply going to https://network.pivotal.io/, i'm going to show how to do it through solely CLI.
Using pivnet cli
we need to discover the following items before we can download the product file:
- product-slug (generally the product name)
- release version (can include spaces)
- product file ID
Let's start by getting the product-slug for the mysqlv2 tile
[~] pivnet products | grep -E 'SLUG|mysql' | ID | SLUG | NAME | | 41 | p-mysql | MySQL for PCF v1 | | 209 | a9s-mysql | a9s MySQL for PCF | | 180 | pivotal-mysql | MySQL for PCF |
Now lets get the most current release vesion
[~] pivnet releases -p pivotal-mysql +--------+---------+--------------------------------+--------------------------+ | ID | VERSION | DESCRIPTION | UPDATED AT | +--------+---------+--------------------------------+--------------------------+ | 122966 | 2.3.1 | MySQL for PCF v2.3.1. It | 2018-07-12T20:27:34.759Z | | | | provides dedicated single node | | | | | instances with configurable | | | | | plans, full backups, and | | | | | metrics. | |
Finally lets get the product file ID:
[~] pivnet product-files -p pivotal-mysql -r 2.3.1 +--------+--------------------------------+--------------+---------------------+------------------------------------------------------------------+------------------------------------------------------------------------------------------------------+ | ID | NAME | FILE VERSION | FILE TYPE | SHA256 | AWS OBJECT KEY | +--------+--------------------------------+--------------+---------------------+------------------------------------------------------------------+------------------------------------------------------------------------------------------------------+ | 149560 | Open Source License Disclosure | 1 | Open Source License | 2a3c887a92d299e19db179ed12d93aa5dc715c4c0665100a493428f9da4ac228 | product-files/pivotal-mysql/open_source_license_pivotal-mysql-2.3.0-build.172-f1cb31e-1526618752.txt | | | for MySQL for PCF 2.3.0 | | | | | | 164030 | MySQL for PCF v2 | 2.3.1 | Software | 370d15b112965c3fddb01ff9f921534d6b906d86e1ca3dcc22c451096292fda3 | product-files/pivotal-mysql/pivotal-mysql-2.3.1-build.11.pivotal | +--------+--------------------------------+--------------+---------------------+------------------------------------------------------------------+------------------------------------------------------------------------------------------------------+
With all (3) we can now download the tile:
[~] pivnet download-product-files -p pivotal-mysql -r 2.3.1 -i 164030 -d ~/ --accept-eula
Setup alias or token variable
Depending on how you want to communicate through om, you can either use a username/password combo or a token from ops manager.
Username/Password
alias oml="om -k -t https://opsmgr-10.haas-59.pez.pivotal.io -u admin -p password"
If you want the om
output to be verbose and list the raw http response, use the -tr
flag
alias oml="om -k -t https://opsmgr-10.haas-59.pez.pivotal.io -u admin -p password -tr"
Uploading tile to ops manager
As stated initially, uploading should be done from a location that has a fast connection to Ops Manager. You can even do this from Ops Manager itself using SSH.
Setup the $FILE
variable using the file that we just downloaded.
~$ export FILE=pivotal-mysql-2.3.1-build.11.pivotal
Using the Alias and FILE variables that we set, we can upload the package to Ops Manager.
~$ ubuntu@opsmgr-10-haas-59-pez-pivotal-io:~$ oml upload-product --product $FILE & [1] 5654 ubuntu@opsmgr-10-haas-59-pez-pivotal-io:~$ processing product beginning product upload to Ops Manager 1.80 GiB / 1.80 GiB [===========================================] 100.00% 1m17s 54s elapsed, waiting for response from Ops Manager... finished upload [1]+ Done om -k -t https://opsmgr-10.haas-59.pez.pivotal.io -u admin -p password upload-product --product $FILE
Staging Product
Using OM tools and our oml
alias we can check the available products.
~$ oml available-products +---------------+----------------+ | NAME | VERSION | +---------------+----------------+ | pivotal-mysql | 2.3.1-build.11 | | cf | 2.1.7 | | aws-services | 1.4.8 | +---------------+----------------+
With that information, we can stage the tile.
~$ oml stage-product --product-name pivotal-mysql --product-version "2.3.1-build.11" staging pivotal-mysql 2.3.1-build.11 finished staging
JSON config
In order to utilize om configure-product
we need a JSON file to pass with the settings. Rather than building one from scratch, the easiest way is to pull it using om curl
.
NOTE:The product must be staged or deployed for this to work.
First we need to obtain a product identification string that uniquely identifies the product. The only way i've found to do this is through URL analysis via Ops Manager. From the Installation Dashboard > right-click on the tile and copy the URL or link address.
For Example: https://opsmgr-10.haas-59.pez.pivotal.io/products/pivotal-mysql-0f6e3fc68d8a5d2e1b93/az_and_network_assignments/edit
In the above example, the product identification string is: pivotal-mysql-0f6e3fc68d8a5d2e1b93
quick reference
query opsmanager api and print pretty json
~$ testjson=$(curl "https://opsmgr-15.haas-59.pez.pivotal.io/api/v0/stemcell_assignments" --insecure \ -X GET \ -H "Authorization: Bearer $access_token") | echo $testjson | python -m json.tool | more % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0{ "products": [ { "available_stemcell_versions": [ "3468.51" ], "deployed_stemcell_version": "3468.51", "guid": "p-rabbitmq-49407616425a3f96dd5b", "identifier": "p-rabbitmq", "is_staged_for_deletion": false, "label": "RabbitMQ", "product_version": "1.12.7", "required_stemcell_os": "ubuntu-trusty", "required_stemcell_version": "3468.51", "staged_stemcell_version": "3468.51" }, { "available_stemcell_versions": [ "3541.37" ], "deployed_stemcell_version": "3541.37", "guid": "pivotal-mysql-f1cb955f294464dfaffd", "identifier": "pivotal-mysql", "is_staged_for_deletion": false, "label": "MySQL for Pivotal Cloud Foundry v2", "product_version": "2.3.1-build.11", "required_stemcell_os": "ubuntu-trusty", "required_stemcell_version": "3541.34", "staged_stemcell_version": "3541.37" }, { "available_stemcell_versions": [ "3541.37" ], "deployed_stemcell_version": "3541.37", "guid": "p-bosh-404ef12b578f0da0977e", "identifier": "p-bosh", "is_staged_for_deletion": false, "label": "BOSH Director", "product_version": "2.1-build.348", "required_stemcell_os": "ubuntu-trusty", "required_stemcell_version": "3541.37", "staged_stemcell_version": "3541.37" }, { "available_stemcell_versions": [ "3541.37" ], "deployed_stemcell_version": "3541.37", "guid": "cf-5a3f75999090a1afbfdb", "identifier": "cf", "is_staged_for_deletion": false, "label": "Pivotal Application Service", "product_version": "2.1.10", "required_stemcell_os": "ubuntu-trusty", "required_stemcell_version": "3541.36", "staged_stemcell_version": "3541.37" }, { "available_stemcell_versions": [ "3468.51" ], "deployed_stemcell_version": "3468.51", "guid": "p-spring-cloud-services-a033fcb589ee1a7435fa", "identifier": "p-spring-cloud-services", "is_staged_for_deletion": false, "label": "Spring Cloud Services", "product_version": "1.5.6", "required_stemcell_os": "ubuntu-trusty", "required_stemcell_version": "3468", "staged_stemcell_version": "3468.51" } ], "stemcell_library": [ { "hypervisor": "esxi", "infrastructure": "vsphere", "light": false, "os": "ubuntu-trusty", "version": "3468.51" }, { "hypervisor": "esxi", "infrastructure": "vsphere", "light": false, "os": "ubuntu-trusty", "version": "3541.37" } ] } 100 2020 0 2020 0 0 1020 0 --:--:-- 0:00:01 --:--:-- 1020