Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 1D777200BAB for ; Sat, 8 Oct 2016 04:30:40 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 1C0A6160AE9; Sat, 8 Oct 2016 02:30:40 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id DF6F1160AE8 for ; Sat, 8 Oct 2016 04:30:38 +0200 (CEST) Received: (qmail 78867 invoked by uid 500); 8 Oct 2016 02:30:33 -0000 Mailing-List: contact notifications-help@libcloud.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@libcloud.apache.org Delivered-To: mailing list notifications@libcloud.apache.org Received: (qmail 78305 invoked by uid 500); 8 Oct 2016 02:30:32 -0000 Delivered-To: apmail-libcloud-commits@libcloud.apache.org Received: (qmail 78244 invoked by uid 99); 8 Oct 2016 02:30:32 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 08 Oct 2016 02:30:32 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id B946AE08C1; Sat, 8 Oct 2016 02:30:32 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: anthonyshaw@apache.org To: commits@libcloud.apache.org Date: Sat, 08 Oct 2016 02:30:43 -0000 Message-Id: <0a3afcd0ec714fef838972280b358669@git.apache.org> In-Reply-To: <1829233ccd204694aab9500ef389cc8d@git.apache.org> References: <1829233ccd204694aab9500ef389cc8d@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [12/27] libcloud git commit: move _build_payload to bottom near other helper functions archived-at: Sat, 08 Oct 2016 02:30:40 -0000 move _build_payload to bottom near other helper functions Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/6a1d03d6 Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/6a1d03d6 Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/6a1d03d6 Branch: refs/heads/trunk Commit: 6a1d03d6bfffcf5b69c35f52f95add492aac00c0 Parents: 12cdf36 Author: Mario Loria Authored: Thu Sep 29 11:53:55 2016 -0400 Committer: Anthony Shaw Committed: Sat Oct 8 13:29:22 2016 +1100 ---------------------------------------------------------------------- libcloud/container/drivers/rancher.py | 466 ++++++++++++++--------------- 1 file changed, 233 insertions(+), 233 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/libcloud/blob/6a1d03d6/libcloud/container/drivers/rancher.py ---------------------------------------------------------------------- diff --git a/libcloud/container/drivers/rancher.py b/libcloud/container/drivers/rancher.py index 63c1aeb..1e8e18b 100644 --- a/libcloud/container/drivers/rancher.py +++ b/libcloud/container/drivers/rancher.py @@ -287,239 +287,6 @@ class RancherContainerDriver(ContainerDriver): ) return result.status in VALID_RESPONSE_CODES - def _build_payload(self, image, start=True, name=None, image_type="docker", - blkiodeviceoptions=None, build=None, - capadd=None, - capdrop=None, command=None, - count=None, cpuset=None, cpushares=None, - datavolumemounts=None, datavolumes=None, - datavolumesfrom=None, description=None, devices=None, - dns=None, dnssearch=None, domainname=None, - entrypoint=None, environment=None, expose=None, - extrahosts=None, healthcheck=None, hostname=None, - instancelinks=None, labels=None, logconfig=None, - lxcconf=None, memory=None, memoryswap=None, - networkcontainerrid=None, networkids=None, - networkmode=None, pidmode=None, ports=None, - privileged=None, publishallports=None, - readonly=None, registrycredentialid=None, - requestedhostid=None, restartpolicy=None, - securityopt=None, - stdinopen=None, tty=None, user=None, - volumedriver=None, workingdir=None): - """ - - :param image: The Image object to deploy. - :type image: :class:`libcloud.container.base.ContainerImage` - - :param start: Whether to start the container on creation. - :type start: ``bool`` - - :param name: The desired name of the container. - :type name: ``str`` - - :param image_type: The image format of the desired image to deploy. - :type image_type: ``str`` - - :param blkiodeviceoptions: The blkioDeviceOptions for the container. - :type blkiodeviceoptions: ``dict`` - - :param build: Build details for the container. - :type build: ``dict`` - - :param capadd: Linux Capabilities to enable for this container. - :type capadd: ``list`` - - :param capdrop: Linux capabilities to disable for this container. - :type capdrop: ``list`` - - :param command: The command to execute when this container is run. - :type command: ``list`` - - :param count: The number of containers of this nature to launch. - :type count: ``int`` - - :param cpuset: Memory nodes in which to allow execution. - :type cpuset: ``str`` - - :param cpushares: Relative weight cpu shares to allow. - :type cpushares: ``int`` - - :param datavolumemounts: Data volume mountes this container should have - :type datavolumemounts: ``dict`` - - :param datavolumes: Data volumes to associate with this container. - :type datavolumes: ``list`` - - :param datavolumesfrom: Data volumes to inherit. - :type datavolumesfrom: ``list`` - - :param description: Description for this container. - :type description: ``str`` - - :param devices: Devices inside the container without privliged mode. - :type devices: ``list`` - - :param dns: DNS servers the container should utilize. - :type dns: ``list`` - - :param dnssearch: DNS search domains the container should utilize. - :type dnssearch: ``list`` - - :param domainname: The domain name the container should have. - :type domainname: ``str`` - - :param entrypoint: The entrypoint the container should have. - :type entrypoint: ``list`` - - :param environment: Environment variables the container should have. - :type environment: ``dict`` - - :param expose: Ports which should be exposed in the container. - :type expose: ``list`` - - :param extrahosts: Extra hosts file entries this container should have. - :type extrahosts: ``list`` - - :param healthcheck: Health check parameters for this container. - :type healthcheck: ``dict`` - - :param hostname: The hostname this container should have. - :type hostname: ``str`` - - :param instancelinks: Instance links the container should have. - :type instancelinks: ``dict`` - - :param labels: Labels to associate with this container. - :type labels: ``dict`` - - :param logconfig: Log configuration for this container. - :type logconfig: ``dict`` - - :param lxcconf: lxcConf specific to this container. - :type lxcconf: ``dict`` - - :param memory: The memory limit for this container. - :type memory: ``int`` - - :param memoryswap: Total memory limit for this container. - :type memoryswap: ``int`` - - :param networkcontainerrid: A Network container Id for this container. - :type networkcontainerrid: ``dict`` - - :param networkids: NetworkIds this container should contain. - :type networkids: ``list`` - - :param networkmode: The networkMode to enable for this container. - :type networkmode: ``str`` - - :param pidmode: The pidMode for this container. - :type pidmode: ``str`` - - :param ports: The ports to publicize for this container. - :type ports: ``list`` - - :param privileged: Whether to enable privileged mode for this container - :type privileged: ``bool`` - - :param publishallports: Publish all ports in container. - :type publishallports: ``bool`` - - :param readonly: Whether this container should be readOnly. - :type readonly: ``bool`` - - :param registrycredentialid: Registry credentials to use. - :type registrycredentialid: ``dict`` - - :param requestedhostid: Id of the requested host to run this container. - :type requestedhostid: ``dict`` - - :param restartpolicy: The container restart policy. - :type restartpolicy: ``dict`` - - :param securityopt: Security options to provide for this container. - :type securityopt: ``list`` - - :param stdinopen: Whether to keep stdin open. - :type stdinopen: ``bool`` - - :param tty: Enable a tty for this container. - :type tty: ``bool`` - - :param user: User this container should be tied to. - :type user: ``str`` - - :param volumedriver: The volume driver to use for this container. - :type volumedriver: ``str`` - - :param workingdir: The workingDir this container should start in. - :type workingdir: ``str`` - - :return: - """ - - if command is not None: - command = shlex.split(str(command)) - - if image.version is not None: - imageuuid = image_type + ':' + image.path + ':' + image.version - else: - imageuuid = image_type + ':' + image.path - - payload = { - "blkioDeviceOptions": blkiodeviceoptions, - "build": build, - "capAdd": capadd, - "capDrop": capdrop, - "command": command, - "count": count, - "cpuSet": cpuset, - "cpuShares": cpushares, - "dataVolumeMounts": datavolumemounts, - "dataVolumes": datavolumes, - "dataVolumesFrom": datavolumesfrom, - "description": description, - "devices": devices, - "dns": dns, - "dnsSearch": dnssearch, - "domainName": domainname, - "entryPoint": entrypoint, - "environment": environment, - "expose": expose, - "extraHosts": extrahosts, - "healthCheck": healthcheck, - "hostname": hostname, - "imageUuid": imageuuid, - "instanceLinks": instancelinks, - "labels": labels, - "logConfig": logconfig, - "lxcConf": lxcconf, - "memory": memory, - "memorySwap": memoryswap, - "name": name, - "networkContainerId": networkcontainerrid, - "networkIds": networkids, - "networkMode": networkmode, - "pidMode": pidmode, - "ports": ports, - "privileged": privileged, - "publishAllPorts": publishallports, - "readOnly": readonly, - "registryCredentialId": registrycredentialid, - "requestedHostId": requestedhostid, - "restartPolicy": restartpolicy, - "securityOpt": securityopt, - "startOnCreate": start, - "stdinOpen": stdinopen, - "tty": tty, - "user": user, - "volumeDriver": volumedriver, - "workingdir": workingdir - } - - return payload - def ex_list_services(self): """ List all Rancher Services @@ -1186,3 +953,236 @@ class RancherContainerDriver(ContainerDriver): state=state, driver=self.connection.driver, extra=extra) + + def _build_payload(self, image, start=True, name=None, image_type="docker", + blkiodeviceoptions=None, build=None, + capadd=None, + capdrop=None, command=None, + count=None, cpuset=None, cpushares=None, + datavolumemounts=None, datavolumes=None, + datavolumesfrom=None, description=None, devices=None, + dns=None, dnssearch=None, domainname=None, + entrypoint=None, environment=None, expose=None, + extrahosts=None, healthcheck=None, hostname=None, + instancelinks=None, labels=None, logconfig=None, + lxcconf=None, memory=None, memoryswap=None, + networkcontainerrid=None, networkids=None, + networkmode=None, pidmode=None, ports=None, + privileged=None, publishallports=None, + readonly=None, registrycredentialid=None, + requestedhostid=None, restartpolicy=None, + securityopt=None, + stdinopen=None, tty=None, user=None, + volumedriver=None, workingdir=None): + """ + + :param image: The Image object to deploy. + :type image: :class:`libcloud.container.base.ContainerImage` + + :param start: Whether to start the container on creation. + :type start: ``bool`` + + :param name: The desired name of the container. + :type name: ``str`` + + :param image_type: The image format of the desired image to deploy. + :type image_type: ``str`` + + :param blkiodeviceoptions: The blkioDeviceOptions for the container. + :type blkiodeviceoptions: ``dict`` + + :param build: Build details for the container. + :type build: ``dict`` + + :param capadd: Linux Capabilities to enable for this container. + :type capadd: ``list`` + + :param capdrop: Linux capabilities to disable for this container. + :type capdrop: ``list`` + + :param command: The command to execute when this container is run. + :type command: ``list`` + + :param count: The number of containers of this nature to launch. + :type count: ``int`` + + :param cpuset: Memory nodes in which to allow execution. + :type cpuset: ``str`` + + :param cpushares: Relative weight cpu shares to allow. + :type cpushares: ``int`` + + :param datavolumemounts: Data volume mountes this container should have + :type datavolumemounts: ``dict`` + + :param datavolumes: Data volumes to associate with this container. + :type datavolumes: ``list`` + + :param datavolumesfrom: Data volumes to inherit. + :type datavolumesfrom: ``list`` + + :param description: Description for this container. + :type description: ``str`` + + :param devices: Devices inside the container without privliged mode. + :type devices: ``list`` + + :param dns: DNS servers the container should utilize. + :type dns: ``list`` + + :param dnssearch: DNS search domains the container should utilize. + :type dnssearch: ``list`` + + :param domainname: The domain name the container should have. + :type domainname: ``str`` + + :param entrypoint: The entrypoint the container should have. + :type entrypoint: ``list`` + + :param environment: Environment variables the container should have. + :type environment: ``dict`` + + :param expose: Ports which should be exposed in the container. + :type expose: ``list`` + + :param extrahosts: Extra hosts file entries this container should have. + :type extrahosts: ``list`` + + :param healthcheck: Health check parameters for this container. + :type healthcheck: ``dict`` + + :param hostname: The hostname this container should have. + :type hostname: ``str`` + + :param instancelinks: Instance links the container should have. + :type instancelinks: ``dict`` + + :param labels: Labels to associate with this container. + :type labels: ``dict`` + + :param logconfig: Log configuration for this container. + :type logconfig: ``dict`` + + :param lxcconf: lxcConf specific to this container. + :type lxcconf: ``dict`` + + :param memory: The memory limit for this container. + :type memory: ``int`` + + :param memoryswap: Total memory limit for this container. + :type memoryswap: ``int`` + + :param networkcontainerrid: A Network container Id for this container. + :type networkcontainerrid: ``dict`` + + :param networkids: NetworkIds this container should contain. + :type networkids: ``list`` + + :param networkmode: The networkMode to enable for this container. + :type networkmode: ``str`` + + :param pidmode: The pidMode for this container. + :type pidmode: ``str`` + + :param ports: The ports to publicize for this container. + :type ports: ``list`` + + :param privileged: Whether to enable privileged mode for this container + :type privileged: ``bool`` + + :param publishallports: Publish all ports in container. + :type publishallports: ``bool`` + + :param readonly: Whether this container should be readOnly. + :type readonly: ``bool`` + + :param registrycredentialid: Registry credentials to use. + :type registrycredentialid: ``dict`` + + :param requestedhostid: Id of the requested host to run this container. + :type requestedhostid: ``dict`` + + :param restartpolicy: The container restart policy. + :type restartpolicy: ``dict`` + + :param securityopt: Security options to provide for this container. + :type securityopt: ``list`` + + :param stdinopen: Whether to keep stdin open. + :type stdinopen: ``bool`` + + :param tty: Enable a tty for this container. + :type tty: ``bool`` + + :param user: User this container should be tied to. + :type user: ``str`` + + :param volumedriver: The volume driver to use for this container. + :type volumedriver: ``str`` + + :param workingdir: The workingDir this container should start in. + :type workingdir: ``str`` + + :return: + """ + + if command is not None: + command = shlex.split(str(command)) + + if image.version is not None: + imageuuid = image_type + ':' + image.path + ':' + image.version + else: + imageuuid = image_type + ':' + image.path + + payload = { + "blkioDeviceOptions": blkiodeviceoptions, + "build": build, + "capAdd": capadd, + "capDrop": capdrop, + "command": command, + "count": count, + "cpuSet": cpuset, + "cpuShares": cpushares, + "dataVolumeMounts": datavolumemounts, + "dataVolumes": datavolumes, + "dataVolumesFrom": datavolumesfrom, + "description": description, + "devices": devices, + "dns": dns, + "dnsSearch": dnssearch, + "domainName": domainname, + "entryPoint": entrypoint, + "environment": environment, + "expose": expose, + "extraHosts": extrahosts, + "healthCheck": healthcheck, + "hostname": hostname, + "imageUuid": imageuuid, + "instanceLinks": instancelinks, + "labels": labels, + "logConfig": logconfig, + "lxcConf": lxcconf, + "memory": memory, + "memorySwap": memoryswap, + "name": name, + "networkContainerId": networkcontainerrid, + "networkIds": networkids, + "networkMode": networkmode, + "pidMode": pidmode, + "ports": ports, + "privileged": privileged, + "publishAllPorts": publishallports, + "readOnly": readonly, + "registryCredentialId": registrycredentialid, + "requestedHostId": requestedhostid, + "restartPolicy": restartpolicy, + "securityOpt": securityopt, + "startOnCreate": start, + "stdinOpen": stdinopen, + "tty": tty, + "user": user, + "volumeDriver": volumedriver, + "workingdir": workingdir + } + + return payload