Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var IMAGE_ATTRIBUTIES = map[string]string{
"name": "name",
"visibility": "visibility",
"container-format": "container_format",
"disk-format": "disk_format",
"kernel-id": "kernel_id",
"os-distro": "os_distro",
"os-version": "os_version",
}
View Source
var Image = &cobra.Command{Use: "image"}
View Source
var ImageList = &cobra.Command{ Use: "list", Short: "List images", Args: func(cmd *cobra.Command, args []string) error { if err := cobra.ExactArgs(0)(cmd, args); err != nil { return err } visibility, _ := cmd.Flags().GetString("visibility") if visibility != "" && !stringutils.ContainsString(glance.IMAGE_VISIBILITIES, visibility) { return fmt.Errorf("invalid visibility, valid: %v", glance.IMAGE_VISIBILITIES) } return nil }, Run: func(cmd *cobra.Command, _ []string) { long, _ := cmd.Flags().GetBool("long") human, _ := cmd.Flags().GetBool("human") name, _ := cmd.Flags().GetString("name") limit, _ := cmd.Flags().GetInt("limit") pageSize, _ := cmd.Flags().GetUint("page-size") visibility, _ := cmd.Flags().GetString("visibility") query := utility.UrlValues(map[string]string{ "name": name, "visibility": visibility, }) if pageSize != 0 { query.Set("limit", fmt.Sprintf("%d", pageSize)) } c := openstack.DefaultClient().GlanceV2() images, err := c.Images().List(query, limit) utility.LogError(err, "get imges failed", true) pt := common.PrettyTable{ ShortColumns: []common.Column{ {Name: "Id"}, {Name: "Name", Sort: true}, {Name: "Status", AutoColor: true}, {Name: "Size", Align: text.AlignRight, Slot: func(item interface{}) interface{} { p, _ := item.(glance.Image) if human { return p.HumanSize() } else { return p.Size } }}, {Name: "DiskFormat"}, {Name: "ContainerFormat"}, }, LongColumns: []common.Column{ {Name: "Visibility"}, {Name: "Protected"}, }, } pt.AddItems(images) common.PrintPrettyTable(pt, long) }, }
View Source
var ImageShow = &cobra.Command{ Use: "show <id or name>", Short: "Show image", Args: cobra.ExactArgs(1), Run: func(cmd *cobra.Command, args []string) { idOrName := args[0] human, _ := cmd.Flags().GetBool("human") c := openstack.DefaultClient().GlanceV2() image, err := c.Images().Found(idOrName) utility.LogError(err, "Get image failed", true) printImage(*image, human) }, }
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.