You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ro...@apache.org on 2018/05/09 13:50:51 UTC
[cloudstack-cloudmonkey] branch master updated: Fixes #17: handle
errors when unable to connect
This is an automated email from the ASF dual-hosted git repository.
rohit pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cloudstack-cloudmonkey.git
The following commit(s) were added to refs/heads/master by this push:
new 2494d02 Fixes #17: handle errors when unable to connect
2494d02 is described below
commit 2494d0248965ea83abcd98a83fc1cfa6c5e142bd
Author: Rohit Yadav <ro...@apache.org>
AuthorDate: Wed May 9 19:11:40 2018 +0530
Fixes #17: handle errors when unable to connect
Signed-off-by: Rohit Yadav <ro...@apache.org>
---
cmd/login.go | 5 +++--
cmd/network.go | 8 +++++---
config/about.go | 3 ++-
3 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/cmd/login.go b/cmd/login.go
index 36b54e8..3a67103 100644
--- a/cmd/login.go
+++ b/cmd/login.go
@@ -82,9 +82,10 @@ func init() {
client, _, err := Login(r)
if client == nil || err != nil {
- fmt.Println("Failed to login, check credentials")
+ fmt.Println("Failed to login, check credentials and try again.")
} else {
- fmt.Println("Success!")
+ fmt.Println("Successfully logged in and saved credentials to the server profile.")
+ r.Config.UpdateConfig("", "")
}
return nil
diff --git a/cmd/network.go b/cmd/network.go
index 19cac73..3361526 100644
--- a/cmd/network.go
+++ b/cmd/network.go
@@ -78,10 +78,13 @@ func Login(r *Request) (*http.Client, string, error) {
sessionKey := ""
resp, err := client.PostForm(r.Config.ActiveProfile.URL, params)
+ if err != nil {
+ return client, sessionKey, errors.New("failed to connect to management server, please check the URL: " + r.Config.ActiveProfile.URL)
+ }
if resp.StatusCode != http.StatusOK {
- e := errors.New("failed to log in")
+ e := errors.New("failed to log in, please check the credentials")
if err != nil {
- e = errors.New("failed to log in due to:" + err.Error())
+ e = errors.New("failed to log in due to " + err.Error())
}
return client, sessionKey, e
}
@@ -146,7 +149,6 @@ func NewAPIRequest(r *Request, api string, args []string) (map[string]interface{
client.Timeout = time.Duration(time.Duration(r.Config.Core.Timeout) * time.Second)
response, err := client.Get(fmt.Sprintf("%s?%s", r.Config.ActiveProfile.URL, encodedParams))
if err != nil {
- fmt.Println("Error:", err)
return nil, err
}
body, _ := ioutil.ReadAll(response.Body)
diff --git a/config/about.go b/config/about.go
index c47c029..088d31c 100644
--- a/config/about.go
+++ b/config/about.go
@@ -32,6 +32,7 @@ func (c *Config) Version() string {
// PrintHeader prints startup message in CLI mode
func (c *Config) PrintHeader() {
fmt.Println(c.Name(), c.Version())
- fmt.Println("Type \"help\" for details, \"sync\" to update API cache or press tab to list commands")
+ fmt.Println("Type \"help\" for details, \"sync\" to update API cache or press tab to list options")
+ fmt.Println("Report issue and features here: https://github.com/apache/cloudstack-cloudmonkey/issues")
fmt.Println()
}
--
To stop receiving notification emails like this one, please contact
rohit@apache.org.