Compare commits

...

4 Commits

Author SHA1 Message Date
Jeremy Grossmann ae64f15386
Merge pull request #2365 from GNS3/feature/custom-qemu-path
1 month ago
grossmj 123b5d0800
Support for custom Qemu path in templates and nodes
1 month ago
Jeremy Grossmann e1d3ee12b9
Merge pull request #2364 from GNS3/bugfix/3572
1 month ago
grossmj 998898a471
Fix CPU fractional values for Docker VMs.
1 month ago

@ -506,6 +506,10 @@ class DockerVM(BaseNode):
result = await self.manager.query("POST", "containers/create", data=params)
self._cid = result["Id"]
log.info(f"Docker container '{self._name}' [{self._id}] created")
if self._cpus > 0:
log.info(f"CPU limit set to {self._cpus} CPUs")
if self._memory > 0:
log.info(f"Memory limit set to {self._memory} MB")
return True
def _format_env(self, variables, env):

@ -124,6 +124,8 @@ class QemuVM(BaseNode):
except QemuError:
# If the binary is not found for topologies 1.4 and later
# search via the platform otherwise use the binary name
log.warning(f"Could not find the QEMU binary {qemu_path} on this system, "
f"trying to find one using platform {platform}")
if platform:
self.platform = platform
else:
@ -242,7 +244,7 @@ class QemuVM(BaseNode):
if qemu_path and os.pathsep not in qemu_path:
new_qemu_path = shutil.which(qemu_path, path=os.pathsep.join(self._manager.paths_list()))
if new_qemu_path is None:
raise QemuError(f"QEMU binary path {qemu_path} is not found in the path")
raise QemuError(f"QEMU binary '{qemu_path}' cannot be found on the system")
qemu_path = new_qemu_path
self._check_qemu_path(qemu_path)
@ -289,6 +291,7 @@ class QemuVM(BaseNode):
def platform(self, platform):
self._platform = platform
log.info(f"QEMU VM '{self._name}' [{self._id}] has set the platform {platform}")
self.qemu_path = f"qemu-system-{platform}"
def _disk_setter(self, variable, value):

@ -16,7 +16,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from sqlalchemy import Boolean, Column, String, Integer, ForeignKey, PickleType
from sqlalchemy import Boolean, Column, String, Integer, Float, ForeignKey, PickleType
from sqlalchemy.orm import relationship
from .base import BaseTable, generate_uuid, GUID
@ -77,7 +77,7 @@ class DockerTemplate(Template):
extra_hosts = Column(String)
extra_volumes = Column(PickleType)
memory = Column(Integer)
cpus = Column(Integer)
cpus = Column(Float)
custom_adapters = Column(PickleType)
__mapper_args__ = {"polymorphic_identity": "docker", "polymorphic_load": "selectin"}

@ -1,4 +1,5 @@
Generic single-database configuration with an async dbapi.
# Command to generate a revision
alembic upgrade head
alembic revision --autogenerate -m "add fields in table"

@ -43,7 +43,7 @@ class DockerBase(BaseModel):
extra_hosts: Optional[str] = Field(None, description="Docker extra hosts (added to /etc/hosts)")
extra_volumes: Optional[List[str]] = Field(None, description="Additional directories to make persistent")
memory: Optional[int] = Field(None, description="Maximum amount of memory the container can use in MB")
cpus: Optional[int] = Field(None, description="Maximum amount of CPU resources the container can use")
cpus: Optional[float] = Field(None, description="Maximum amount of CPU resources the container can use")
custom_adapters: Optional[List[CustomAdapter]] = Field(None, description="Custom adapters")

@ -49,7 +49,7 @@ class DockerTemplate(TemplateBase):
extra_hosts: Optional[str] = Field("", description="Docker extra hosts (added to /etc/hosts)")
extra_volumes: Optional[List] = Field([], description="Additional directories to make persistent")
memory: Optional[int] = Field(0, description="Maximum amount of memory the container can use in MB")
cpus: Optional[int] = Field(0, description="Maximum amount of CPU resources the container can use")
cpus: Optional[float] = Field(0, description="Maximum amount of CPU resources the container can use")
custom_adapters: Optional[List[CustomAdapter]] = Field(default_factory=list, description="Custom adapters")

Loading…
Cancel
Save