Skip to content

Commit b8e3fb6

Browse files
committed
Updated hostname to hostIp and updated methods and configs accordingly.
Signed-off-by: Jason011125 <zic022@ucsd.edu>
1 parent 3b6b0a1 commit b8e3fb6

File tree

22 files changed

+54
-54
lines changed

22 files changed

+54
-54
lines changed

cli/cli/cli.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,11 @@ func NewCurveAdm() (*CurveAdm, error) {
9494

9595
rootDir := fmt.Sprintf("%s/.curveadm", home)
9696
curveadm := &CurveAdm{
97-
rootDir: rootDir,
98-
dataDir: path.Join(rootDir, "data"),
99-
pluginDir: path.Join(rootDir, "plugins"),
100-
logDir: path.Join(rootDir, "logs"),
101-
tempDir: path.Join(rootDir, "temp"),
97+
rootDir: rootDir,
98+
dataDir: path.Join(rootDir, "data"),
99+
pluginDir: path.Join(rootDir, "plugins"),
100+
logDir: path.Join(rootDir, "logs"),
101+
tempDir: path.Join(rootDir, "temp"),
102102
httpConfPath: path.Join(rootDir, "http/conf"),
103103
httpLogPath: path.Join(rootDir, "http/logs"),
104104
}
@@ -335,7 +335,7 @@ func (curveadm *CurveAdm) ParseTopologyData(data string) ([]*topology.DeployConf
335335
return nil, err
336336
}
337337
for _, hc := range hcs {
338-
ctx.Add(hc.GetHost(), hc.GetHostname())
338+
ctx.Add(hc.GetHost(), hc.GetHostIp())
339339
}
340340

341341
dcs, err := topology.ParseTopology(data, ctx)
@@ -499,7 +499,7 @@ func (curveadm *CurveAdm) DiffTopology(data1, data2 string) ([]topology.Topology
499499
return nil, err
500500
}
501501
for _, hc := range hcs {
502-
ctx.Add(hc.GetHost(), hc.GetHostname())
502+
ctx.Add(hc.GetHost(), hc.GetHostIp())
503503
}
504504

505505
if len(data1) == 0 {

cli/command/hosts/list_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,20 @@ const (
1010
data = `
1111
hosts:
1212
- host: host1
13-
hostname: 1.1.1.1
13+
hostIp: 1.1.1.1
1414
labels:
1515
- all
1616
- host1
1717
- group1
1818
- host: host2
19-
hostname: 2.2.2.2
19+
hostIp: 2.2.2.2
2020
labels:
2121
- all
2222
- host2
2323
- group1
2424
- group2
2525
- host: host3
26-
hostname: 3.3.3.3
26+
hostIp: 3.3.3.3
2727
labels:
2828
- all
2929
- host3

internal/configure/hosts/hc_get.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func (hc *HostConfig) getBool(i *comm.Item) bool {
6868
}
6969

7070
func (hc *HostConfig) GetHost() string { return hc.getString(CONFIG_HOST) }
71-
func (hc *HostConfig) GetHostname() string { return hc.getString(CONFIG_HOSTNAME) }
71+
func (hc *HostConfig) GetHostIp() string { return hc.getString(CONFIG_HOSTIP) }
7272
func (hc *HostConfig) GetSSHHostname() string { return hc.getString(CONFIG_SSH_HOSTNAME) }
7373
func (hc *HostConfig) GetUser() string { return hc.getString(CONFIG_USER) }
7474
func (hc *HostConfig) GetSSHPort() int { return hc.getInt(CONFIG_SSH_PORT) }
@@ -80,7 +80,7 @@ func (hc *HostConfig) GetEnvs() []string { return hc.envs }
8080
func (hc *HostConfig) GetSSHConfig() *module.SSHConfig {
8181
hostname := hc.GetSSHHostname()
8282
if len(hostname) == 0 {
83-
hostname = hc.GetHostname()
83+
hostname = hc.GetHostIp()
8484
}
8585
return &module.SSHConfig{
8686
User: hc.GetUser(),

internal/configure/hosts/hc_item.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ var (
4545
nil,
4646
)
4747

48-
CONFIG_HOSTNAME = itemset.Insert(
49-
"hostname",
48+
CONFIG_HOSTIP = itemset.Insert(
49+
"hostip",
5050
comm.REQUIRE_STRING,
5151
false,
5252
nil,

internal/configure/hosts/hosts.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,12 +144,12 @@ func (hc *HostConfig) Build() error {
144144
if len(hc.GetHost()) == 0 {
145145
return errno.ERR_HOST_FIELD_MISSING.
146146
F("hosts[%d].host = nil", hc.sequence)
147-
} else if len(hc.GetHostname()) == 0 {
147+
} else if len(hc.GetHostIp()) == 0 {
148148
return errno.ERR_HOSTNAME_FIELD_MISSING.
149-
F("hosts[%d].hostname = nil", hc.sequence)
150-
} else if !utils.IsValidAddress(hc.GetHostname()) {
149+
F("hosts[%d].hostIp = nil", hc.sequence)
150+
} else if !utils.IsValidAddress(hc.GetHostIp()) {
151151
return errno.ERR_HOSTNAME_REQUIRES_VALID_IP_ADDRESS.
152-
F("hosts[%d].hostname = %s", hc.sequence, hc.GetHostname())
152+
F("hosts[%d].hostIp = %s", hc.sequence, hc.GetHostIp())
153153
} else if hc.GetSSHPort() > os.GetMaxPortNum() {
154154
return errno.ERR_HOSTS_SSH_PORT_EXCEED_MAX_PORT_NUMBER.
155155
F("hosts[%d].ssh_port = %d", hc.sequence, hc.GetSSHPort())

internal/configure/monitor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ func ParseMonitorConfig(curveadm *cli.CurveAdm, filename string, data string, hs
265265
return nil, err
266266
}
267267
for _, hc := range hcs {
268-
ctx.Add(hc.GetHost(), hc.GetHostname())
268+
ctx.Add(hc.GetHost(), hc.GetHostIp())
269269
}
270270

271271
mkind := dcs[0].GetKind()

internal/configure/topology/context.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ func NewContext() *Context {
3232
return &Context{m: map[string]string{}}
3333
}
3434

35-
func (ctx *Context) Add(host, hostname string) {
36-
ctx.m[host] = hostname
35+
func (ctx *Context) Add(host, hostIp string) {
36+
ctx.m[host] = hostIp
3737
}
3838

3939
func (ctx *Context) Lookup(host string) string {

internal/configure/topology/dc.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ type (
5353
parentId string // role_host_[name/hostSequence]_0
5454
role string // etcd/mds/metaserevr/chunkserver
5555
host string
56-
hostname string
56+
hostIp string
5757
name string
5858
replicas int
5959
hostSequence int // start with 0
@@ -251,7 +251,7 @@ func (dc *DeployConfig) convert() error {
251251

252252
func (dc *DeployConfig) ResolveHost() error {
253253
if dc.ctx == nil {
254-
dc.hostname = dc.host
254+
dc.hostIp = dc.host
255255
return nil
256256
}
257257

@@ -267,8 +267,8 @@ func (dc *DeployConfig) ResolveHost() error {
267267
if err != nil {
268268
return errno.ERR_RENDERING_VARIABLE_FAILED.E(err)
269269
}
270-
dc.hostname = dc.ctx.Lookup(dc.GetHost())
271-
if len(dc.hostname) == 0 {
270+
dc.hostIp = dc.ctx.Lookup(dc.GetHost())
271+
if len(dc.hostIp) == 0 {
272272
return errno.ERR_HOST_NOT_FOUND.
273273
F("host: %s", dc.GetHost())
274274
}

internal/configure/topology/dc_get.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ func (dc *DeployConfig) GetId() string { return dc.id }
115115
func (dc *DeployConfig) GetParentId() string { return dc.parentId }
116116
func (dc *DeployConfig) GetRole() string { return dc.role }
117117
func (dc *DeployConfig) GetHost() string { return dc.host }
118-
func (dc *DeployConfig) GetHostname() string { return dc.hostname }
118+
func (dc *DeployConfig) GetHostIp() string { return dc.hostIp }
119119
func (dc *DeployConfig) GetName() string { return dc.name }
120120
func (dc *DeployConfig) GetReplicas() int { return dc.replicas }
121121
func (dc *DeployConfig) GetHostSequence() int { return dc.hostSequence }

internal/configure/topology/dc_item.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ var (
136136
REQUIRE_STRING,
137137
true,
138138
func(dc *DeployConfig) interface{} {
139-
return dc.GetHostname()
139+
return dc.GetHostIp()
140140
},
141141
)
142142

@@ -195,7 +195,7 @@ var (
195195
REQUIRE_STRING,
196196
true,
197197
func(dc *DeployConfig) interface{} {
198-
return dc.GetHostname()
198+
return dc.GetHostIp()
199199
},
200200
)
201201

0 commit comments

Comments
 (0)