Last active
July 10, 2017 14:16
-
-
Save ffledgling/7cab94c297ed23b3dfb425692d5a775c to your computer and use it in GitHub Desktop.
ceph-go example: Connect to cluster, list osd pools
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func listOSDPools() { | |
| // Runs the equivalent of ceph osd lspools | |
| // Contains basic connection logic that's reusable | |
| log.Println("Function started...") // We have this because connection etc take a while. | |
| // If like me, you tried this first and expected it to work, it doesn't: | |
| /* | |
| conn, _ := rados.NewConn() | |
| args := []string{"--name", "client.ffledgling", "--conf", "/home/ffledgling/ceph.conf"} | |
| conn.ParseCmdLineArgs(args) | |
| */ | |
| conn, _ := rados.NewConnWithUser("ffledgling") | |
| conn.ReadConfigFile("/home/ffledgling/ceph.conf") | |
| if err := conn.Connect(); err != nil { | |
| log.Fatalln("Connection Failed.", err) | |
| } | |
| // Get the list of pools | |
| list, err := conn.ListPools() | |
| if err != nil { | |
| log.Println(err) | |
| } | |
| for i, e := range list { | |
| log.Println(i, e) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment