Skip to content
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

update paddle configure #98

Merged
merged 4 commits into from
May 26, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions doc/client_design.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,16 @@ Client configurations stores in a file: `~/.paddle/config` in the below `yaml` f
```yaml
datacenters:
- name: datacenter1
active: true
username: user1
password: secret
usercert: /path/to/user.pem
userkey: /path/to/user-key.pem
endpoint: http://cloud.paddlepaddle.org
- name: datacenter2
active: false
username: user1
password: secret
endpoint: http://cloud2.paddlepaddle.org
current-datacenter: datacenter1
```

***NOTICE:*** The ***first*** "active" configuration part will be used.
Expand Down
4 changes: 2 additions & 2 deletions doc/usage_cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@
```yaml
datacenters:
- name: datacenter1
active: true
username: [your user name]
password: [secret]
endpoint: http://cloud.paddlepaddle.org
current-datacenter: datacenter1
```

配置文件用于指定使用的PaddlePaddleCloud服务器集群的接入地址,并需要配置用户的登录信息:
- name: 自定义的datacenter名称,可以是任意字符串
- active: 为true说明使用这个datacenter作为当前操作的datacenter,配置文件中只能有一个datacenter的配置为true
- username: PaddlePaddleCloud的用户名,账号在未开放注册前需要联系管理员分配,通常用户名为邮箱地址
- password: 账号对应的密码
- endpoint: PaddlePaddleCloud集群API地址,可以从集群管理员处获得
- current-datacenter: 标明使用哪个datacenter作为当前操作的datacenter

配置文件创建完成后,执行`paddlecloud`会显示该客户端的帮助信息:

Expand Down
8 changes: 4 additions & 4 deletions go/paddlecloud/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
)

type submitConfigDataCenter struct {
Active bool `yaml:"active"`
Name string `yaml:"name"`
Username string `yaml:"username"`
Password string `yaml:"password"`
Expand All @@ -25,8 +24,9 @@ type submitConfigDataCenter struct {

// Configuration load from user config yaml files
type submitConfig struct {
DC []submitConfigDataCenter `yaml:"datacenters"`
ActiveConfig *submitConfigDataCenter
DC []submitConfigDataCenter `yaml:"datacenters"`
ActiveConfig *submitConfigDataCenter
CurrentDatacenter string `yaml:"current-datacenter"`
}

// UserHomeDir get user home dierctory on different platforms
Expand Down Expand Up @@ -80,7 +80,7 @@ func parseConfig(configFile string) *submitConfig {
}
// put active config
for _, item := range config.DC {
if item.Active {
if item.Name == config.CurrentDatacenter {
config.ActiveConfig = &item
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should break here. &item will change in next loop.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

}
}
Expand Down