Commit 4e7e5fee authored by Thomas Goirand's avatar Thomas Goirand

Add a cluster-show command.

parent 6cd11736
......@@ -15,6 +15,7 @@ openstack-cluster-installer (21) UNRELEASED; urgency=medium
* Provision ssh public / private keypair between nova nodes in the
/var/lib/nova/.ssh folder, to allow (live) migration using ssh / scp.
* Switch to a db migration system with the schema saved in PHP format.
* Add a cluster-show command.
[ Oliver Chaze ]
* swift: do not log in syslog general logs
......
......@@ -111,7 +111,7 @@ _ocicli() {
;;
esac
;;
cluster-show-machines|cluster-show-networks|cluster-show-ips|cluster-delete)
cluster-show-machines|cluster-show-networks|cluster-show-ips|cluster-delete|cluster-show)
local cluster_list=$(ocicli -csv cluster-list | grep -v "id,name,domain" | cut -d, -f2 | tr \\n " ")
COMPREPLY=( $(compgen -W "${cluster_list}" -- ${cur}) )
return 0
......
......@@ -51,6 +51,7 @@ usage (){
echo " cluster-list"
echo " cluster-create <cluster-name> <domaine-name.com>"
echo " cluster-delete <cluster-name>"
echo " cluster-show <cluster-name>"
echo " cluster-show-networks <cluster-name>"
echo " cluster-show-machines <cluster-name>"
echo " cluster-show-ips <cluster-name>"
......@@ -231,6 +232,30 @@ ocicli_cluster_list (){
cat ${API_RESPONSE_FILE} | jq -r '.["data"]|=sort_by(.name)|.["data"][] | "\(.id),\(.name),\(.domain)"'
}
ocicli_cluster_show (){
ocicli_call "action=cluster_show&name=${1}"
OCICLI_CLUSTER_SHOW_NAME=$(cat ${API_RESPONSE_FILE} | jq -r '.["data"]| "\(.name)"')
OCICLI_CLUSTER_SHOW_DOMAIN=$(cat ${API_RESPONSE_FILE} | jq -r '.["data"]| "\(.domain)"')
OCICLI_CLUSTER_SHOW_VIP_HOSTNAME=$(cat ${API_RESPONSE_FILE} | jq -r '.["data"]| "\(.vip_hostname)"')
OCICLI_CLUSTER_SHOW_SWIFT_PART_POWER=$(cat ${API_RESPONSE_FILE} | jq -r '.["data"]| "\(.swift_part_power)"')
OCICLI_CLUSTER_SHOW_SWIFT_REPLICAS=$(cat ${API_RESPONSE_FILE} | jq -r '.["data"]| "\(.swift_replicas)"')
OCICLI_CLUSTER_SHOW_SWIFT_MIN_PART_HOURS=$(cat ${API_RESPONSE_FILE} | jq -r '.["data"]| "\(.swift_min_part_hours)"')
OCICLI_CLUSTER_SHOW_SWIFT_PROXY_HOSTNAME=$(cat ${API_RESPONSE_FILE} | jq -r '.["data"]| "\(.swift_proxy_hostname)"')
OCICLI_CLUSTER_SHOW_SWIFT_ENCRYPTION_KEY=$(cat ${API_RESPONSE_FILE} | jq -r '.["data"]| "\(.swift_encryption_key_id)"')
OCICLI_CLUSTER_SHOW_HAPROXY_CUSTOM_URL=$(cat ${API_RESPONSE_FILE} | jq -r '.["data"]| "\(.haproxy_custom_url)"')
OCICLI_CLUSTER_SHOW_STATSD_HOSTNAME=$(cat ${API_RESPONSE_FILE} | jq -r '.["data"]| "\(.statsd_hostname)"')
echo "Name:,${OCICLI_CLUSTER_SHOW_NAME}"
echo "Domain:,${OCICLI_CLUSTER_SHOW_DOMAIN}"
echo "VIP Hostname:,${OCICLI_CLUSTER_SHOW_VIP_HOSTNAME}"
echo "Swift part power:,${OCICLI_CLUSTER_SHOW_SWIFT_PART_POWER}"
echo "Swift replicas:,${OCICLI_CLUSTER_SHOW_SWIFT_REPLICAS}"
echo "Swift min part hours:,${OCICLI_CLUSTER_SHOW_SWIFT_MIN_PART_HOURS}"
echo "Swift proxy hostname:,${OCICLI_CLUSTER_SHOW_SWIFT_PROXY_HOSTNAME}"
echo "Swift encryption key uuid:,${OCICLI_CLUSTER_SHOW_SWIFT_ENCRYPTION_KEY}"
echo "Haproxy custom url:,${OCICLI_CLUSTER_SHOW_HAPROXY_CUSTOM_URL}"
echo "Statsd hostname:,${OCICLI_CLUSTER_SHOW_STATSD_HOSTNAME}"
}
ocicli_swiftregion_list () {
ocicli_call "action=swiftregion_list"
echo "id,name"
......@@ -549,6 +574,9 @@ case "${ACTION}" in
ocicli_call "action=cluster_delete&name=${1}"
ocicli_display_status
;;
"cluster-show")
ocicli_cluster_show ${1}
;;
"cluster-show-networks")
ocicli_cluster_show_networks $@
;;
......
......@@ -1233,6 +1233,29 @@ function api_actions($con,$conf){
$json["data"] = $a;
return $json;
break;
case "cluster_show":
$safe_cluster_name = safe_fqdn("name");
if($safe_cluster_name === FALSE){
$json["status"] = "error";
$json["message"] = "Error: not valid cluster name.";
return $json;
}
$q = "SELECT * FROM clusters WHERE name='$safe_cluster_name'";
$r = mysqli_query($con, $q);
if($r === FALSE){
$json["status"] = "error";
$json["message"] = mysqli_error($con);
return $json;
}
$n = mysqli_num_rows($r);
if($n != 1){
$json["status"] = "error";
$json["message"] = "Error: cluster not found.";
return $json;
}
$json["data"] = mysqli_fetch_array($r);
return $json;
break;
case "cluster_show_ips":
$safe_cluster_name = safe_fqdn("name");
if($safe_cluster_name === FALSE){
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment