-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cmd/status.go:31 (TODO): Added px describe cluster command #41
Conversation
cmd/describeCluster.go
Outdated
@@ -0,0 +1,112 @@ | |||
// Copyright © 2019 NAME HERE <EMAIL ADDRESS> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add portworx in the copyright string instead of "NAME HERE "
for _, pool := range n.GetPools() { | ||
used += pool.GetUsed() | ||
capacity += pool.GetTotalSize() | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think, To get the node specific capacity and Used memory, we have to use GetMemTotal and GetMemUsed. This will match with the pxctl cluster list or inspect output. Please check it out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@siva-portworx A lot of values in pxctl are internal to Portworx. Line 101-103 use the OpenStorage SDK, which is public, so this is the method that has to be used.
cmd/describeCluster_test.go
Outdated
assert.Contains(t, lines, "Cluster Status: STATUS_OK") | ||
assert.Contains(t, lines, "Version: 1.0.0-fake") | ||
assert.Contains(t, lines, "Cluster UUID: ce6b309e289d620be08c964969aeb39f") | ||
assert.Contains(t, lines[9], "node-1") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These unit tests were done when we were just starting and only using the mock-sdk-server. Now that we can point at any cluster, we cannot depend on the values, we only test that we get in the output what px printed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have removed one node restriction though, keeping check for at least one node to be present. If it is run on any other cluster other than mock server, we will not be able to verify the values because we wouldn't know what is the expected value.
cmd/describeCluster_test.go
Outdated
// Only one node and an empty line | ||
assert.Len(t, lines[9:len(lines)], 2) | ||
|
||
/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be deleted.
a58d4c3
to
579420d
Compare
Added px describe cluster command. Reference cmd/status.go
Testing:
Help:
~/go/src/github.com/portworx/px# ./px describe --help
Show detailed information of Portworx resources
Usage:
px describe [flags]
px describe [command]
Available Commands:
cluster Describe a Portworx cluster
pvc Describe Portworx volume for Kubernetes PVCs
volume Describe a Portworx volume
Flags:
-h, --help help for describe
Global Flags:
--config string config file (default is $HOME/.px/config.yml)
--context string Force context name for the command
--show-labels Show labels in the last column of the output
Use "px describe [command] --help" for more information about a command.
~/go/src/github.com/portworx/px# ./px describe cluster
Cluster ID: px-cluster-df2b73b3-e2d7-4ce6-ae9a-fd9488e6756e
Cluster UUID: b23b54da-ebf0-4a93-979b-01930b05b876
Cluster Status: STATUS_OK
Version: 2.0.3.8-6940616
build: 694061605df84a3bce57a1f278c972249e6e715a
SDK Version 0.22.11
used test 0
used test 0
used test 0
Hostname IP SchedulerNodeName Used Capacity Status
ravi-blr-dev-dour-shoulder-1 70.0.87.82 ravi-blr-dev-dour-shoulder-1 0 Gi 0 Gi STATUS_OK
ravi-blr-dev-dour-shoulder-3 70.0.87.120 ravi-blr-dev-dour-shoulder-3 0 Gi 0 Gi STATUS_OK
ravi-blr-dev-dour-shoulder-2 70.0.87.118 ravi-blr-dev-dour-shoulder-2 0 Gi 0 Gi STATUS_OK
From the unit test:
~/go/src/github.com/portworx/px/cmd# go test -v -run TestDescribeCluster
=== RUN TestDescribeCluster
--- PASS: TestDescribeCluster (0.03s)
PASS
ok github.com/portworx/px/cmd 0.048s