Skip to content

Commit

Permalink
lxc: Disallow launching aliased containers of instance type VM (#14137)
Browse files Browse the repository at this point in the history
An aliased vm image should not launch with `lxc launch <alias_name>`
(unless the `--vm` flag is passed in).

This PR is part of a series of PR's related to
#14047.
  • Loading branch information
tomponline committed Sep 25, 2024
2 parents fce1ec2 + b781061 commit cb8a515
Show file tree
Hide file tree
Showing 42 changed files with 489 additions and 320 deletions.
4 changes: 4 additions & 0 deletions lxc/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,10 @@ func (c *cmdInit) create(conf *config.Config, args []string, launch bool) (lxd.I
return nil, "", errors.New(i18n.G("Asked for a VM but image is of type container"))
}

if imgInfo.Type != "container" && !c.flagVM {
return nil, "", errors.New(i18n.G("Asked for a container but image is of type VM"))
}

req.Type = api.InstanceType(imgInfo.Type)
}

Expand Down
20 changes: 12 additions & 8 deletions po/ar.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: lxd\n"
"Report-Msgid-Bugs-To: [email protected]\n"
"POT-Creation-Date: 2024-09-17 07:40-0600\n"
"POT-Creation-Date: 2024-09-19 13:11-0600\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: Automatically generated\n"
"Language-Team: none\n"
Expand Down Expand Up @@ -770,6 +770,10 @@ msgstr ""
msgid "Asked for a VM but image is of type container"
msgstr ""

#: lxc/init.go:346
msgid "Asked for a container but image is of type VM"
msgstr ""

#: lxc/cluster_group.go:84 lxc/cluster_group.go:85
msgid "Assign sets of groups to cluster members"
msgstr ""
Expand Down Expand Up @@ -841,7 +845,7 @@ msgstr ""
msgid "BASE IMAGE"
msgstr ""

#: lxc/export.go:86
#: lxc/export.go:106
#, c-format
msgid "Backing up instance: %s"
msgstr ""
Expand Down Expand Up @@ -1814,7 +1818,7 @@ msgstr ""
msgid "Device: %s"
msgstr ""

#: lxc/init.go:402
#: lxc/init.go:406
msgid "Didn't get any affected image, instance or snapshot from server"
msgstr ""

Expand Down Expand Up @@ -2862,7 +2866,7 @@ msgstr ""
msgid "Instance name is mandatory"
msgstr ""

#: lxc/init.go:413
#: lxc/init.go:417
#, c-format
msgid "Instance name is: %s"
msgstr ""
Expand Down Expand Up @@ -4938,7 +4942,7 @@ msgstr ""
msgid "Retrieve the container's console log"
msgstr ""

#: lxc/init.go:356
#: lxc/init.go:360
#, c-format
msgid "Retrieving image: %s"
msgstr ""
Expand Down Expand Up @@ -5778,7 +5782,7 @@ msgid ""
"restarted"
msgstr ""

#: lxc/init.go:434
#: lxc/init.go:438
msgid "The instance you are starting doesn't have any network attached to it."
msgstr ""

Expand Down Expand Up @@ -5939,11 +5943,11 @@ msgstr ""
msgid "Timestamps:"
msgstr ""

#: lxc/init.go:436
#: lxc/init.go:440
msgid "To attach a network to an instance, use: lxc network attach"
msgstr ""

#: lxc/init.go:435
#: lxc/init.go:439
msgid "To create a new network, use: lxc network create"
msgstr ""

Expand Down
20 changes: 12 additions & 8 deletions po/ber.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: lxd\n"
"Report-Msgid-Bugs-To: [email protected]\n"
"POT-Creation-Date: 2024-09-17 07:40-0600\n"
"POT-Creation-Date: 2024-09-19 13:11-0600\n"
"PO-Revision-Date: 2022-03-10 15:10+0000\n"
"Last-Translator: Anonymous <[email protected]>\n"
"Language-Team: Berber <https://hosted.weblate.org/projects/linux-containers/"
Expand Down Expand Up @@ -773,6 +773,10 @@ msgstr ""
msgid "Asked for a VM but image is of type container"
msgstr ""

#: lxc/init.go:346
msgid "Asked for a container but image is of type VM"
msgstr ""

#: lxc/cluster_group.go:84 lxc/cluster_group.go:85
msgid "Assign sets of groups to cluster members"
msgstr ""
Expand Down Expand Up @@ -844,7 +848,7 @@ msgstr ""
msgid "BASE IMAGE"
msgstr ""

#: lxc/export.go:86
#: lxc/export.go:106
#, c-format
msgid "Backing up instance: %s"
msgstr ""
Expand Down Expand Up @@ -1817,7 +1821,7 @@ msgstr ""
msgid "Device: %s"
msgstr ""

#: lxc/init.go:402
#: lxc/init.go:406
msgid "Didn't get any affected image, instance or snapshot from server"
msgstr ""

Expand Down Expand Up @@ -2865,7 +2869,7 @@ msgstr ""
msgid "Instance name is mandatory"
msgstr ""

#: lxc/init.go:413
#: lxc/init.go:417
#, c-format
msgid "Instance name is: %s"
msgstr ""
Expand Down Expand Up @@ -4941,7 +4945,7 @@ msgstr ""
msgid "Retrieve the container's console log"
msgstr ""

#: lxc/init.go:356
#: lxc/init.go:360
#, c-format
msgid "Retrieving image: %s"
msgstr ""
Expand Down Expand Up @@ -5781,7 +5785,7 @@ msgid ""
"restarted"
msgstr ""

#: lxc/init.go:434
#: lxc/init.go:438
msgid "The instance you are starting doesn't have any network attached to it."
msgstr ""

Expand Down Expand Up @@ -5942,11 +5946,11 @@ msgstr ""
msgid "Timestamps:"
msgstr ""

#: lxc/init.go:436
#: lxc/init.go:440
msgid "To attach a network to an instance, use: lxc network attach"
msgstr ""

#: lxc/init.go:435
#: lxc/init.go:439
msgid "To create a new network, use: lxc network create"
msgstr ""

Expand Down
20 changes: 12 additions & 8 deletions po/bg.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: lxd\n"
"Report-Msgid-Bugs-To: [email protected]\n"
"POT-Creation-Date: 2024-09-17 07:40-0600\n"
"POT-Creation-Date: 2024-09-19 13:11-0600\n"
"PO-Revision-Date: 2022-03-10 15:09+0000\n"
"Last-Translator: Anonymous <[email protected]>\n"
"Language-Team: Bulgarian <https://hosted.weblate.org/projects/linux-"
Expand Down Expand Up @@ -773,6 +773,10 @@ msgstr ""
msgid "Asked for a VM but image is of type container"
msgstr ""

#: lxc/init.go:346
msgid "Asked for a container but image is of type VM"
msgstr ""

#: lxc/cluster_group.go:84 lxc/cluster_group.go:85
msgid "Assign sets of groups to cluster members"
msgstr ""
Expand Down Expand Up @@ -844,7 +848,7 @@ msgstr ""
msgid "BASE IMAGE"
msgstr ""

#: lxc/export.go:86
#: lxc/export.go:106
#, c-format
msgid "Backing up instance: %s"
msgstr ""
Expand Down Expand Up @@ -1817,7 +1821,7 @@ msgstr ""
msgid "Device: %s"
msgstr ""

#: lxc/init.go:402
#: lxc/init.go:406
msgid "Didn't get any affected image, instance or snapshot from server"
msgstr ""

Expand Down Expand Up @@ -2865,7 +2869,7 @@ msgstr ""
msgid "Instance name is mandatory"
msgstr ""

#: lxc/init.go:413
#: lxc/init.go:417
#, c-format
msgid "Instance name is: %s"
msgstr ""
Expand Down Expand Up @@ -4941,7 +4945,7 @@ msgstr ""
msgid "Retrieve the container's console log"
msgstr ""

#: lxc/init.go:356
#: lxc/init.go:360
#, c-format
msgid "Retrieving image: %s"
msgstr ""
Expand Down Expand Up @@ -5781,7 +5785,7 @@ msgid ""
"restarted"
msgstr ""

#: lxc/init.go:434
#: lxc/init.go:438
msgid "The instance you are starting doesn't have any network attached to it."
msgstr ""

Expand Down Expand Up @@ -5942,11 +5946,11 @@ msgstr ""
msgid "Timestamps:"
msgstr ""

#: lxc/init.go:436
#: lxc/init.go:440
msgid "To attach a network to an instance, use: lxc network attach"
msgstr ""

#: lxc/init.go:435
#: lxc/init.go:439
msgid "To create a new network, use: lxc network create"
msgstr ""

Expand Down
20 changes: 12 additions & 8 deletions po/ca.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: lxd\n"
"Report-Msgid-Bugs-To: [email protected]\n"
"POT-Creation-Date: 2024-09-17 07:40-0600\n"
"POT-Creation-Date: 2024-09-19 13:11-0600\n"
"PO-Revision-Date: 2022-03-10 15:10+0000\n"
"Last-Translator: Anonymous <[email protected]>\n"
"Language-Team: Catalan <https://hosted.weblate.org/projects/linux-containers/"
Expand Down Expand Up @@ -773,6 +773,10 @@ msgstr ""
msgid "Asked for a VM but image is of type container"
msgstr ""

#: lxc/init.go:346
msgid "Asked for a container but image is of type VM"
msgstr ""

#: lxc/cluster_group.go:84 lxc/cluster_group.go:85
msgid "Assign sets of groups to cluster members"
msgstr ""
Expand Down Expand Up @@ -844,7 +848,7 @@ msgstr ""
msgid "BASE IMAGE"
msgstr ""

#: lxc/export.go:86
#: lxc/export.go:106
#, c-format
msgid "Backing up instance: %s"
msgstr ""
Expand Down Expand Up @@ -1817,7 +1821,7 @@ msgstr ""
msgid "Device: %s"
msgstr ""

#: lxc/init.go:402
#: lxc/init.go:406
msgid "Didn't get any affected image, instance or snapshot from server"
msgstr ""

Expand Down Expand Up @@ -2865,7 +2869,7 @@ msgstr ""
msgid "Instance name is mandatory"
msgstr ""

#: lxc/init.go:413
#: lxc/init.go:417
#, c-format
msgid "Instance name is: %s"
msgstr ""
Expand Down Expand Up @@ -4941,7 +4945,7 @@ msgstr ""
msgid "Retrieve the container's console log"
msgstr ""

#: lxc/init.go:356
#: lxc/init.go:360
#, c-format
msgid "Retrieving image: %s"
msgstr ""
Expand Down Expand Up @@ -5781,7 +5785,7 @@ msgid ""
"restarted"
msgstr ""

#: lxc/init.go:434
#: lxc/init.go:438
msgid "The instance you are starting doesn't have any network attached to it."
msgstr ""

Expand Down Expand Up @@ -5942,11 +5946,11 @@ msgstr ""
msgid "Timestamps:"
msgstr ""

#: lxc/init.go:436
#: lxc/init.go:440
msgid "To attach a network to an instance, use: lxc network attach"
msgstr ""

#: lxc/init.go:435
#: lxc/init.go:439
msgid "To create a new network, use: lxc network create"
msgstr ""

Expand Down
Loading

0 comments on commit cb8a515

Please sign in to comment.