Skip to content

portMapping isn't iterable #25

@graovic

Description

@graovic

Hi,

I think you have a bug in MarathonContainerPortMapping class. Object generated from this class isn't iterable so bug is shown when you try to build docker container from this client. First MarathonContainerPortMapping doesn't returning iterator ,and second maybe it's better to this object (from class MarathonContainerPortMapping) contains list of PortMapping objects that contains container_port=, host_port=, service_port=, protocol'. And of course returning these elements through iterator.

from marathon import MarathonClient
from marathon.models.container import MarathonContainer
from marathon.models.container import MarathonDockerContainer
from marathon.models.container import MarathonContainerPortMapping
from marathon.models.container import MarathonContainerVolume
c = MarathonClient("localhost:8080")
portMapping = MarathonContainerPortMapping(container_port=80, host_port=0, service_port=1822, protocol='tcp')
docker = MarathonDockerContainer(image="ppoint/cmsv2", network="BRIDGE", port_mappings=portMapping)
Traceback (most recent call last):
File "", line 1, in
File "/usr/lib/python2.7/site-packages/marathon/models/container.py", line 56, in init
for pm in (port_mappings or [])
TypeError: 'MarathonContainerPortMapping' object is not iterable

python --version
Python 2.7.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions