[lxc-devel] [lxd/master] lxd-p2c: Add --storage-size option
stgraber on Github
lxc-bot at linuxcontainers.org
Fri Jun 21 01:56:12 UTC 2019
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 354 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20190620/b1f0f6b0/attachment.bin>
-------------- next part --------------
From e983d088231d38dbf701fdd7f1792fc3e10f93e3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Thu, 20 Jun 2019 21:55:56 -0400
Subject: [PATCH] lxd-p2c: Add --storage-size option
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
lxd-p2c/main_migrate.go | 25 ++++++++++++++++++-------
1 file changed, 18 insertions(+), 7 deletions(-)
diff --git a/lxd-p2c/main_migrate.go b/lxd-p2c/main_migrate.go
index 7b005013d9..8c8128b88d 100644
--- a/lxd-p2c/main_migrate.go
+++ b/lxd-p2c/main_migrate.go
@@ -19,13 +19,14 @@ import (
type cmdMigrate struct {
global *cmdGlobal
- flagConfig []string
- flagNetwork string
- flagProfile []string
- flagStorage string
- flagType string
- flagRsyncArgs string
- flagNoProfiles bool
+ flagConfig []string
+ flagNetwork string
+ flagProfile []string
+ flagStorage string
+ flagStorageSize string
+ flagType string
+ flagRsyncArgs string
+ flagNoProfiles bool
}
func (c *cmdMigrate) Command() *cobra.Command {
@@ -49,6 +50,7 @@ func (c *cmdMigrate) Command() *cobra.Command {
cmd.Flags().StringVarP(&c.flagNetwork, "network", "n", "", "Network to use for the container"+"``")
cmd.Flags().StringArrayVarP(&c.flagProfile, "profile", "p", nil, "Profile to apply to the container"+"``")
cmd.Flags().StringVarP(&c.flagStorage, "storage", "s", "", "Storage pool to use for the container"+"``")
+ cmd.Flags().StringVar(&c.flagStorageSize, "storage-size", "", "Size of the storage volume (requires --storage)"+"``")
cmd.Flags().StringVarP(&c.flagType, "type", "t", "", "Instance type to use for the container"+"``")
cmd.Flags().StringVar(&c.flagRsyncArgs, "rsync-args", "", "Extra arguments to pass to rsync"+"``")
cmd.Flags().BoolVar(&c.flagNoProfiles, "no-profiles", false, "Create the container with no profiles applied")
@@ -76,6 +78,10 @@ func (c *cmdMigrate) Run(cmd *cobra.Command, args []string) error {
return fmt.Errorf("no-profiles can't be specified alongside profiles")
}
+ if c.flagStorageSize != "" && c.flagStorage == "" {
+ return fmt.Errorf("--storage-size requires --storage be passed")
+ }
+
// Handle mandatory arguments
if len(args) < 3 {
cmd.Help()
@@ -180,6 +186,11 @@ func (c *cmdMigrate) Run(cmd *cobra.Command, args []string) error {
"pool": storage,
"path": "/",
}
+
+ storageSize := c.flagStorageSize
+ if storageSize != "" {
+ apiArgs.Devices["root"]["size"] = storageSize
+ }
}
// Check if the container already exists
More information about the lxc-devel
mailing list