$ for i in ./*.rb; do egrep -w namespace ${i} | egrep -v '# '; done
Dcmgr::Endpoints::V1203::CoreAPI.namespace '/accounts' do
namespace '/:id' do
Dcmgr::Endpoints::V1203::CoreAPI.namespace '/alarms' do
Dcmgr::Endpoints::V1203::CoreAPI.namespace '/backup_objects' do
Dcmgr::Endpoints::V1203::CoreAPI.namespace '/backup_storages' do
Dcmgr::Endpoints::V1203::CoreAPI.namespace '/dc_networks' do
Dcmgr::Endpoints::V1203::CoreAPI.namespace '/host_node_groups', &TagEndpointFactory.make_tag_endpoint(Dcmgr::Tags::HostNodeGroup,:host_nodes)
Dcmgr::Endpoints::V1203::CoreAPI.namespace('/host_nodes') do
Dcmgr::Endpoints::V1203::CoreAPI.namespace '/images' do
Dcmgr::Endpoints::V1203::CoreAPI.namespace '/instances' do
namespace '/:instance_id/monitoring' do
namespace '/:instance_id/volumes' do
Dcmgr::Endpoints::V1203::CoreAPI.namespace '/ip_handles' do
Dcmgr::Endpoints::V1203::CoreAPI.namespace '/ip_pools' do
Dcmgr::Endpoints::V1203::CoreAPI.namespace '/jobs' do
Dcmgr::Endpoints::V1203::CoreAPI.namespace '/load_balancers' do
Dcmgr::Endpoints::V1203::CoreAPI.namespace '/network_groups', &TagEndpointFactory.make_tag_endpoint(Dcmgr::Tags::NetworkGroup,:networks)
Dcmgr::Endpoints::V1203::CoreAPI.namespace '/network_vifs' do
namespace '/:vif_id/monitors' do
Dcmgr::Endpoints::V1203::CoreAPI.namespace '/networks' do
Dcmgr::Endpoints::V1203::CoreAPI.namespace '/reports' do
Dcmgr::Endpoints::V1203::CoreAPI.namespace '/security_groups' do
Dcmgr::Endpoints::V1203::CoreAPI.namespace '/ssh_key_pairs' do
Dcmgr::Endpoints::V1203::CoreAPI.namespace '/storage_node_groups', &TagEndpointFactory.make_tag_endpoint(Dcmgr::Tags::StorageNodeGroup,:storage_nodes)
Dcmgr::Endpoints::V1203::CoreAPI.namespace '/storage_nodes' do
Dcmgr::Endpoints::V1203::CoreAPI.namespace '/text_logs' do
Dcmgr::Endpoints::V1203::CoreAPI.namespace '/volume_snapshots' do
Dcmgr::Endpoints::V1203::CoreAPI.namespace '/volumes' do
Last active
December 25, 2015 01:59
-
-
Save hansode/6899224 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# requires: | |
# bash | |
# | |
tmpprefix=/tmp/__v1203 | |
egrep ' do' *.rb \ | |
| grep -v fetch \ | |
| egrep -v '[A-Z]' | sort | uniq \ | |
| egrep -v quota | sort \ | |
| egrep 'get|put|delete|post' \ | |
| egrep -v '# (get|put|delete|post)' | sort | uniq \ | |
| egrep -v each \ | |
| sed 's,do$,,' \ | |
| while read line; do | |
line=$(echo ${line} | sed "s,',,g") | |
set ${line} | |
namespace=${1/:/} | |
namespace=${namespace/.rb/} | |
shift | |
method=$(echo $1 | tr a-z A-Z) | |
shift | |
echo "+ \`${method} /${namespace}$@\`" >> ${tmpprefix}_${namespace}.$$.txt | |
echo ... ${namespace} >&2 | |
done | |
for i in ${tmpprefix}_*.$$.txt; do | |
ns=${i##*/} | |
ns=${ns/__v1203_/} | |
ns=${ns%%.$$.txt} | |
echo "## ${ns}" | |
echo | |
for j in POST GET PUT DELETE; do | |
grep ${j} ${i} | sort | |
done | |
echo | |
rm -f ${i} | |
done |
$ grep 'define_error(' errors.rb | grep -v 'def ' | sed "s,define_error,,; s,(,,; s,),,; s/,//g; s,',,g" | awk '{print $3, $2, $1}'
$ grep 'define_error(' errors.rb | grep -v 'def ' | sed "s,define_error,,; s,(,,; s,),,; s/,//g; s,',,g" | awk '{printf "| %s | **%s** | %-40s |\n", $3, $2, $1}'
$ for i in 1shot alarm instance-clone lb-cluster local-volume-instance sg-cluster; do [[ -d ${i} ]] || continue; echo "### ${i}"; echo ;(cd ${i} && ls -1 t.*.sh | sed "s,^,+ ,"); echo; done
$ for i in t.*.sh; do echo "+ ${i}"; egrep 'function test_' $i | sed "s,^function ,,; s,() {,,; s,^, + ,"; done
$ for i in t.*.sh; do [[ -d ${i} ]] || continue; echo "+ ${i%%/*}"; for j in ${i}/test_*; do echo -n " + ${j##*/} -"; methods="$(cut -d' ' -f6 ${j}/*/request | sort | uniq | sort)"; for method in ${methods}; do echo -n " \`${method}\`"; done ; echo; done ; done
$ for i in $(ls -trd t.*.sh); do [[ -d ${i} ]] || continue; echo "+ ${i%%/*}"; for j in $(ls -trd ${i}/test_*); do echo -n " + ${j##*/} -"; methods="$(cut -d' ' -f6 ${j}/*/request | sort | uniq | sort)"; for method in ${methods}; do echo -n " \`${method}\`"; done ; echo; done ; done
$ for i in $(ls -trd t.*.sh 2>/dev/null); do [[ -d ${i} ]] || continue; echo "+ ${i%%/*}"; for j in $(ls -trd ${i}/test_* 2>/dev/null); do echo -n " + ${j##*/} -"; methods="$(cut -d' ' -f6 ${j}/*/request 2>/dev/null | sort | uniq | sort)"; for method in ${methods}; do echo -n " \`${method}\`"; done ; echo; done ; done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### mussel hack!!! | |
# | |
# top-level: | |
# | |
# + stdout | |
# + stderr | |
# + history | |
# + statistics/:namespace/:cmd/:today/:txid/ | |
# + test/:category/:api_version/:script/:step/:today/:txid/ | |
# | |
# curl logging: | |
# | |
# + api.request | |
# + api.response | |
# + bash.declare | |
# + bash.funcname | |
# + cmd.name | |
# + cmd.command | |
# + cmd.exit | |
# + http.request.header | |
# + http.request.method | |
# + http.request.params | |
# + http.request.uri | |
# + http.response.header | |
# + http.trace | |
# + mussel.cmd | |
# + mussel.namespace | |
# | |
front_offset=$((${#BASH_SOURCE[@]} - 1)) | |
front_filename=${BASH_SOURCE[${front_offset}]} | |
front_path=$(cd ${front_filename%%/*} && pwd)/${front_filename##*/} | |
front_shortpath=${front_path##*/client/mussel/} | |
log_store_dir=${HOME}/.mussel.log | |
[[ -d ${log_store_dir} ]] || mkdir -p ${log_store_dir} | |
function gen_txid() { | |
LANG=C date +%Y%m%d.%H%M%S.%N | |
} | |
mussel_build_id=${mussel_build_id:-$(gen_txid)} | |
function mussel_curl_beautify() { | |
local line | |
while read line; do | |
set ${line} | |
while [[ "$1" ]]; do | |
case $1 in | |
curl) echo -n "$1" ;; | |
-fsSkL) echo " $1 \\ " ;; | |
-H|-X) echo " $1 $2 \\" ; shift ;; | |
--data-urlencode) echo " $1 $2 \\"; shift ;; | |
-D) shift ;; | |
*) echo " $1 " ;; | |
esac | |
shift | |
done | sed "s,${DCMGR_HOST}:${DCMGR_PORT},localhost:9001," | |
done < <(cat "$@") | |
} | |
# command subsutitutions | |
function cmdlog() { | |
local core_cmd=${FUNCNAME[1]} | |
local today=$(LANG=C date +%Y%m%d) | |
local sub_log_store_dir=${log_store_dir}/${front_shortpath}/${_shunit_test_:-${core_cmd}}/${today}/$(gen_txid) | |
[[ -d ${sub_log_store_dir} ]] || mkdir -p ${sub_log_store_dir} | |
local cmd_opts= | |
local stdout_paths=${sub_log_store_dir}/cmd.stdout | |
local stderr_paths=${sub_log_store_dir}/cmd.stderr | |
echo "${FUNCNAME[@]}" >${sub_log_store_dir}/bash.funcname | |
declare >${sub_log_store_dir}/bash.declare | |
echo "${core_cmd}" >${sub_log_store_dir}/cmd.name | |
echo "${core_cmd} $@" >${sub_log_store_dir}/cmd.command | |
case "${core_cmd}" in | |
curl) | |
echo "${namespace}" >${sub_log_store_dir}/mussel.namespace | |
echo "${cmd}" >${sub_log_store_dir}/mussel.cmd | |
if [[ -n "${namespace}" ]] && [[ -n "${cmd}" ]]; then | |
local sub_log_store_dir_mussel=${log_store_dir}/statistics/${namespace}/${cmd}/${today} | |
[[ -d "${sub_log_store_dir_mussel}" ]] || mkdir -p ${sub_log_store_dir_mussel} | |
ln -s ${sub_log_store_dir} ${sub_log_store_dir_mussel} | |
fi | |
unset namespace cmd # make sure to unset following values for next task(s) | |
echo "${core_cmd} $@" \ | |
| tee ${sub_log_store_dir}/api.request \ | |
| mussel_curl_beautify | tee \ | |
>(egrep -- -X | awk '{print $2}' >${sub_log_store_dir}/http.request.method) \ | |
>(egrep -- -H | awk '{print $2}' >${sub_log_store_dir}/http.request.header) \ | |
>(egrep -- --data-urlencode | awk '{print $2}' >${sub_log_store_dir}/http.request.params) \ | |
>(tail -1 | xargs echo >${sub_log_store_dir}/http.request.uri) \ | |
>/dev/null | |
stdout_paths="${stdout_paths} ${sub_log_store_dir}/cmd.stdout ${sub_log_store_dir}/api.response" | |
cmd_opts="-D ${sub_log_store_dir}/http.response.header --trace-ascii ${sub_log_store_dir}/http.trace" | |
;; | |
esac | |
exec 1> >(tee ${stdout_paths} >/dev/stdout) | |
exec 2> >(tee ${stderr_paths} >/dev/stderr) | |
eval "$(which ${core_cmd}) ${cmd_opts} $@" </dev/stdin # "</dev/stdin" for here-document | |
local retval=$? | |
echo "${retval}" >${sub_log_store_dir}/cmd.exit | |
{ | |
LANG=C date "+# %F %T %N #${mussel_build_id}" | |
echo "${core_cmd} $@ # => ${retval} (${front_shortpath}) #${mussel_build_id}" | |
} >>${log_store_dir}/history | |
return ${retval} | |
} | |
function nc() { | |
cmdlog "$@" | |
} | |
function ping() { | |
cmdlog "$@" | |
} | |
function openssl() { | |
cmdlog "$@" | |
} | |
function ssh() { | |
cmdlog "-o 'StrictHostKeyChecking no' -o 'UserKnownHostsFile /dev/null' $@" | |
} | |
function curl() { | |
case "$@" in | |
*${DCMGR_BASE_URI}*) | |
cmdlog "$@" | |
;; | |
*) | |
eval "$(which curl) $@" | |
;; | |
esac | |
} | |
function shlog() { | |
exec 1> >(tee -a ${log_store_dir}/stdout >/dev/stdout) | |
exec 2> >(tee -a ${log_store_dir}/stderr >/dev/stderr) | |
eval "$@" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment