()
| 71 | } |
| 72 | |
| 73 | func pushOpenstackCmd() *cobra.Command { |
| 74 | var ( |
| 75 | imageName string |
| 76 | ) |
| 77 | cmd := &cobra.Command{ |
| 78 | Use: "openstack", |
| 79 | Short: "push image to OpenStack Image store (Glance)", |
| 80 | Long: `Push image to OpenStack Image store (Glance). |
| 81 | First argument specifies the path to a disk file. |
| 82 | `, |
| 83 | Args: cobra.ExactArgs(1), |
| 84 | RunE: func(cmd *cobra.Command, args []string) error { |
| 85 | path := args[0] |
| 86 | |
| 87 | // Check that the file both exists, and can be read |
| 88 | checkFile(path) |
| 89 | |
| 90 | client, err := clientconfig.NewServiceClient("image", nil) |
| 91 | if err != nil { |
| 92 | log.Fatalf("Error connecting to your OpenStack cloud: %s", err) |
| 93 | } |
| 94 | |
| 95 | createOpenStackImage(path, imageName, client) |
| 96 | return nil |
| 97 | }, |
| 98 | } |
| 99 | |
| 100 | cmd.Flags().StringVar(&imageName, "img-name", "", "A unique name for the image, if blank the filename will be used") |
| 101 | |
| 102 | return cmd |
| 103 | } |
no test coverage detected