Skip to content

Instantly share code, notes, and snippets.

View wolfoo2931's full-sized avatar
🎯
Focusing

Wolf Oliver wolfoo2931

🎯
Focusing
View GitHub Profile
module Net
class HTTP
alias_method :old_request, :request
def request(req, body = nil, &block)
start_time = Time.now
result = old_request(req, body, &block)
puts "-"*120
puts "reqeust (#{(Time.now - start_time).round(2)} sec) #{req.method} --> #{self.address}#{req.path}"
#puts caller
# This command deletes all orphaned disks in a BOSH director (see: bosh.io; cloudfoundry.org)
# It assumes that the BOSH CLI is installed and that a BOSH director is targeded and the CLI is authenticated
for disk in `bosh disks --orphaned | grep 'disk-' | cut -d ' ' -f 2`; do; bosh delete disk $disk; done
azs:
- name: z1
cloud_properties: {availability_zone: REPLACE}
- name: z2
cloud_properties: {availability_zone: REPLACE}
- name: z3
cloud_properties: {availability_zone: REPLACE}
vm_types:
@wolfoo2931
wolfoo2931 / index.html
Last active August 9, 2017 15:56
update content of domelement #jsbench #jsperf (https://jsbench.github.io/#6d174b84a69b037c059b6a234bb5bcd0) #jsbench #jsperf
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>update content of domelement #jsbench #jsperf</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script>
<script src="./suite.js"></script>
</head>
<body>
<h1>Open the console to view the results</h1>
deployment_name=<your-bosh-deployment-name> #e.g. d30cf96
deployer_api_pwd=<the-deployer-api-password>
deployer_api_ip=<the-deployer-api-ip-address>
template_name=$(curl admin:${deployer_api_pwd}@${deployer_api_ip}:3000/deployments.json | jq -r ".[] | select(.name == \"${deployment_name}\") | .template_name")
template_content=$(curl admin:${deployer_api_pwd}@${deployer_api_ip}:3000/templates.json | jq -r ".[] | select(.name == \"${template_name}\") | .content" | ruby -ryaml -rjson -e 'puts JSON.pretty_generate(YAML.load(ARGF))')
echo $template_content | jq '.jobs' | jq -r '.[].vm_type'
deployment_name=<your-bosh-deployment-name> #e.g. d30cf96
deployer_api_pwd=<the-deployer-api-password>
deployer_api_ip=<the-deployer-api-ip-address>
template_name=$(curl admin:${deployer_api_pwd}@${deployer_api_ip}:3000/deployments.json | jq -r ".[] | select(.name == \"${deployment_name}\") | .template_name")
template_content=$(curl admin:${deployer_api_pwd}@${deployer_api_ip}:3000/templates.json | jq -r ".[] | select(.name == \"${template_name}\") | .content" | ruby -ryaml -rjson -e 'puts JSON.pretty_generate(YAML.load(ARGF))')
echo $template_content | jq '.jobs' | jq -r '.[].vm_type'
curl admin:xx@<broker-ip>:3000/v2/catalog | jq '.'
{
"services": [
{
"id": "7ee52a02-8839-43c2-a550-728ad736bbda",
"name": "a9s-postgresql94",
"description": "This is a service creating and managing dedicated PostgreSQL service instances and clusters, powered by the anynines Service Framework",
"bindable": true,
"tags": [
"sql",
curl admin:xx@<deployer-ip>:3000/deployments/161.json?with_vm_details=true | jq '.'
{
"id": 161,
"name": "d621cb1",
"description": null,
"metadata": null,
"current_state": "deployed",
"template_id": 1,
"template_version": 203,
@wolfoo2931
wolfoo2931 / curl request to broker
Created October 23, 2017 08:04
broker metadata api
curl admin:xx@10.244.10.42:3000/v2/catalog | jq .
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 3333 0 3333 0 0 14999 0 --:--:-- --:--:-- --:--:-- 15081
{
"services": [
{
"id": "ce7d9d95-6877-4151-9e58-249745aebd77",
"name": "a9s-redis32",
"description": "This is a service creating and managing dedicated Redis service instances, powered by the anynines Service Framework",
- type: replace
path: /properties/nats?
value:
machines:
- ((/cf_nats_ip))
user: nats-user
password: ((/cf_nats_password))
port: 4222
- type: remove