mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-04-05 20:52:50 +08:00
35 lines
652 B
Go
35 lines
652 B
Go
![]() |
package topology
|
||
|
|
||
|
import (
|
||
|
"encoding/xml"
|
||
|
)
|
||
|
|
||
|
type rack struct {
|
||
|
Name string `xml:"name,attr"`
|
||
|
Ips []string `xml:"Ip"`
|
||
|
}
|
||
|
type dataCenter struct {
|
||
|
Name string `xml:"name,attr"`
|
||
|
Racks []rack `xml:"Rack"`
|
||
|
}
|
||
|
type topology struct {
|
||
|
DataCenters []dataCenter `xml:"DataCenter"`
|
||
|
}
|
||
|
type configuration struct {
|
||
|
XMLName xml.Name `xml:"Configuration"`
|
||
|
Topo topology `xml:"Topology"`
|
||
|
}
|
||
|
|
||
|
func NewConfiguration(b []byte) (*configuration, error){
|
||
|
c := &configuration{}
|
||
|
err := xml.Unmarshal(b, c)
|
||
|
return c, err
|
||
|
}
|
||
|
|
||
|
func (c *configuration) String() string{
|
||
|
if b, e := xml.MarshalIndent(c, " ", " "); e==nil {
|
||
|
return string(b)
|
||
|
}
|
||
|
return ""
|
||
|
}
|