You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by an...@apache.org on 2016/10/08 02:30:33 UTC
[02/27] libcloud git commit: everything is perfect; add tests
http://git-wip-us.apache.org/repos/asf/libcloud/blob/d179167a/libcloud/test/container/fixtures/rancher/ex_search_services.json
----------------------------------------------------------------------
diff --git a/libcloud/test/container/fixtures/rancher/ex_search_services.json b/libcloud/test/container/fixtures/rancher/ex_search_services.json
new file mode 100644
index 0000000..56be671
--- /dev/null
+++ b/libcloud/test/container/fixtures/rancher/ex_search_services.json
@@ -0,0 +1,346 @@
+{
+ "type": "collection",
+ "resourceType": "service",
+ "links": {
+ "self": "http://172.30.0.100:8080/v1/services"
+ },
+ "createTypes": {
+ "dnsService": "http://172.30.0.100:8080/v1/dnsservices",
+ "externalService": "http://172.30.0.100:8080/v1/externalservices",
+ "loadBalancerService": "http://172.30.0.100:8080/v1/loadbalancerservices",
+ "service": "http://172.30.0.100:8080/v1/services"
+ },
+ "actions": {},
+ "data": [
+ {
+ "id": "1s3",
+ "type": "service",
+ "links": {
+ "self": "http://172.30.0.100:8080/v1/services/1s3",
+ "account": "http://172.30.0.100:8080/v1/services/1s3/account",
+ "consumedbyservices": "http://172.30.0.100:8080/v1/services/1s3/consumedbyservices",
+ "consumedservices": "http://172.30.0.100:8080/v1/services/1s3/consumedservices",
+ "environment": "http://172.30.0.100:8080/v1/services/1s3/environment",
+ "instances": "http://172.30.0.100:8080/v1/services/1s3/instances",
+ "serviceExposeMaps": "http://172.30.0.100:8080/v1/services/1s3/serviceexposemaps",
+ "containerStats": "http://172.30.0.100:8080/v1/services/1s3/containerstats"
+ },
+ "actions": {
+ "update": "http://172.30.0.100:8080/v1/services/1s3/?action=update",
+ "restart": "http://172.30.0.100:8080/v1/services/1s3/?action=restart",
+ "remove": "http://172.30.0.100:8080/v1/services/1s3/?action=remove",
+ "setservicelinks": "http://172.30.0.100:8080/v1/services/1s3/?action=setservicelinks",
+ "removeservicelink": "http://172.30.0.100:8080/v1/services/1s3/?action=removeservicelink",
+ "upgrade": "http://172.30.0.100:8080/v1/services/1s3/?action=upgrade",
+ "addservicelink": "http://172.30.0.100:8080/v1/services/1s3/?action=addservicelink",
+ "deactivate": "http://172.30.0.100:8080/v1/services/1s3/?action=deactivate"
+ },
+ "name": "ghost",
+ "state": "active",
+ "accountId": "1a5",
+ "assignServiceIpAddress": false,
+ "createIndex": 1,
+ "created": "2016-09-22T18:00:26Z",
+ "createdTS": 1474567226000,
+ "currentScale": 1,
+ "description": null,
+ "environmentId": "1e2",
+ "externalId": null,
+ "fqdn": null,
+ "healthState": "healthy",
+ "kind": "service",
+ "launchConfig": {
+ "imageUuid": "docker:ghost",
+ "kind": "container",
+ "labels": {
+ "io.rancher.service.hash": "af9b5ddd2891271b12a88129e2bc37ff57998182"
+ },
+ "logConfig": {},
+ "networkMode": "managed",
+ "ports": [
+ "80:2368/tcp"
+ ],
+ "privileged": false,
+ "publishAllPorts": false,
+ "readOnly": false,
+ "startOnCreate": true,
+ "stdinOpen": false,
+ "tty": false,
+ "version": "0",
+ "vcpu": 1
+ },
+ "metadata": {
+ "io.rancher.service.hash": "f49280e1f709117b76693b638834791e4f4ef0fd"
+ },
+ "publicEndpoints": [
+ {
+ "ipAddress": "172.30.0.101",
+ "port": 80,
+ "serviceId": "1s3",
+ "hostId": "1h1",
+ "instanceId": "1i5"
+ }
+ ],
+ "removed": null,
+ "retainIp": null,
+ "scale": 1,
+ "scalePolicy": null,
+ "secondaryLaunchConfigs": [],
+ "selectorContainer": null,
+ "selectorLink": null,
+ "startOnCreate": false,
+ "transitioning": "no",
+ "transitioningMessage": null,
+ "transitioningProgress": null,
+ "upgrade": null,
+ "uuid": "c2ce7050-e5b5-42c7-a9fb-8ed8d33a4884",
+ "vip": null
+ },
+ {
+ "id": "1s6",
+ "type": "service",
+ "links": {
+ "self": "http://172.30.0.100:8080/v1/services/1s6",
+ "account": "http://172.30.0.100:8080/v1/services/1s6/account",
+ "consumedbyservices": "http://172.30.0.100:8080/v1/services/1s6/consumedbyservices",
+ "consumedservices": "http://172.30.0.100:8080/v1/services/1s6/consumedservices",
+ "environment": "http://172.30.0.100:8080/v1/services/1s6/environment",
+ "instances": "http://172.30.0.100:8080/v1/services/1s6/instances",
+ "serviceExposeMaps": "http://172.30.0.100:8080/v1/services/1s6/serviceexposemaps",
+ "containerStats": "http://172.30.0.100:8080/v1/services/1s6/containerstats"
+ },
+ "actions": {
+ "update": "http://172.30.0.100:8080/v1/services/1s6/?action=update",
+ "restart": "http://172.30.0.100:8080/v1/services/1s6/?action=restart",
+ "remove": "http://172.30.0.100:8080/v1/services/1s6/?action=remove",
+ "setservicelinks": "http://172.30.0.100:8080/v1/services/1s6/?action=setservicelinks",
+ "removeservicelink": "http://172.30.0.100:8080/v1/services/1s6/?action=removeservicelink",
+ "upgrade": "http://172.30.0.100:8080/v1/services/1s6/?action=upgrade",
+ "addservicelink": "http://172.30.0.100:8080/v1/services/1s6/?action=addservicelink",
+ "deactivate": "http://172.30.0.100:8080/v1/services/1s6/?action=deactivate"
+ },
+ "name": "123",
+ "state": "active",
+ "accountId": "1a5",
+ "assignServiceIpAddress": false,
+ "createIndex": 1,
+ "created": "2016-09-22T18:28:04Z",
+ "createdTS": 1474568884000,
+ "currentScale": 1,
+ "description": null,
+ "environmentId": "1e2",
+ "externalId": null,
+ "fqdn": null,
+ "healthState": "healthy",
+ "kind": "service",
+ "launchConfig": {
+ "capAdd": [],
+ "capDrop": [],
+ "count": null,
+ "cpuSet": null,
+ "cpuShares": null,
+ "dataVolumes": [],
+ "dataVolumesFrom": [],
+ "description": null,
+ "devices": [],
+ "dns": [],
+ "dnsSearch": [],
+ "domainName": null,
+ "hostname": null,
+ "imageUuid": "docker:ubuntu:trusty",
+ "kind": "container",
+ "labels": {
+ "io.rancher.container.pull_image": "always"
+ },
+ "logConfig": {
+ "config": {},
+ "driver": ""
+ },
+ "memory": null,
+ "memoryMb": null,
+ "memorySwap": null,
+ "networkMode": "managed",
+ "pidMode": null,
+ "ports": [],
+ "privileged": false,
+ "publishAllPorts": false,
+ "readOnly": false,
+ "requestedIpAddress": null,
+ "startOnCreate": true,
+ "stdinOpen": true,
+ "tty": true,
+ "user": null,
+ "userdata": null,
+ "version": "0bdea468-c3e9-4562-951c-d543958e966a",
+ "volumeDriver": null,
+ "workingDir": null,
+ "dataVolumesFromLaunchConfigs": [],
+ "networkLaunchConfig": null,
+ "vcpu": 1
+ },
+ "metadata": null,
+ "publicEndpoints": null,
+ "removed": null,
+ "retainIp": null,
+ "scale": 1,
+ "scalePolicy": null,
+ "secondaryLaunchConfigs": [],
+ "selectorContainer": null,
+ "selectorLink": null,
+ "startOnCreate": true,
+ "transitioning": "no",
+ "transitioningMessage": null,
+ "transitioningProgress": null,
+ "upgrade": {
+ "inServiceStrategy": {
+ "batchSize": 1,
+ "intervalMillis": 2000,
+ "launchConfig": {
+ "capAdd": [],
+ "capDrop": [],
+ "count": null,
+ "cpuSet": null,
+ "cpuShares": null,
+ "dataVolumes": [],
+ "dataVolumesFrom": [],
+ "description": null,
+ "devices": [],
+ "dns": [],
+ "dnsSearch": [],
+ "domainName": null,
+ "hostname": null,
+ "imageUuid": "docker:ubuntu:trusty",
+ "kind": "container",
+ "labels": {
+ "io.rancher.container.pull_image": "always"
+ },
+ "logConfig": {
+ "config": {},
+ "driver": ""
+ },
+ "memory": null,
+ "memoryMb": null,
+ "memorySwap": null,
+ "networkMode": "managed",
+ "pidMode": null,
+ "ports": [],
+ "privileged": false,
+ "publishAllPorts": false,
+ "readOnly": false,
+ "requestedIpAddress": null,
+ "startOnCreate": true,
+ "stdinOpen": true,
+ "tty": true,
+ "user": null,
+ "userdata": null,
+ "version": "0bdea468-c3e9-4562-951c-d543958e966a",
+ "volumeDriver": null,
+ "workingDir": null,
+ "dataVolumesFromLaunchConfigs": [],
+ "networkLaunchConfig": null,
+ "vcpu": 1
+ },
+ "previousLaunchConfig": {
+ "capAdd": [],
+ "capDrop": [],
+ "count": null,
+ "cpuSet": null,
+ "cpuShares": null,
+ "dataVolumes": [],
+ "dataVolumesFrom": [],
+ "description": null,
+ "devices": [],
+ "dns": [],
+ "dnsSearch": [],
+ "domainName": null,
+ "hostname": null,
+ "imageUuid": "docker:ubuntu:trusty",
+ "kind": "container",
+ "labels": {
+ "io.rancher.container.pull_image": "always"
+ },
+ "logConfig": {
+ "config": {},
+ "driver": ""
+ },
+ "memory": null,
+ "memoryMb": null,
+ "memorySwap": null,
+ "networkMode": "managed",
+ "pidMode": null,
+ "ports": [],
+ "privileged": false,
+ "publishAllPorts": false,
+ "readOnly": false,
+ "requestedIpAddress": null,
+ "startOnCreate": true,
+ "stdinOpen": true,
+ "tty": true,
+ "user": null,
+ "userdata": null,
+ "version": "0",
+ "volumeDriver": null,
+ "workingDir": null,
+ "dataVolumesFromLaunchConfigs": [],
+ "networkLaunchConfig": null,
+ "vcpu": 1
+ },
+ "previousSecondaryLaunchConfigs": [],
+ "secondaryLaunchConfigs": [],
+ "startFirst": true
+ },
+ "toServiceStrategy": null
+ },
+ "uuid": "c0ae4d08-e20a-45ef-9fb9-ad9f7cdeeb15",
+ "vip": null
+ }
+ ],
+ "sortLinks": {
+ "accountId": "http://172.30.0.100:8080/v1/services?limit=4&sort=accountId",
+ "createIndex": "http://172.30.0.100:8080/v1/services?limit=4&sort=createIndex",
+ "created": "http://172.30.0.100:8080/v1/services?limit=4&sort=created",
+ "description": "http://172.30.0.100:8080/v1/services?limit=4&sort=description",
+ "environmentId": "http://172.30.0.100:8080/v1/services?limit=4&sort=environmentId",
+ "externalId": "http://172.30.0.100:8080/v1/services?limit=4&sort=externalId",
+ "healthState": "http://172.30.0.100:8080/v1/services?limit=4&sort=healthState",
+ "id": "http://172.30.0.100:8080/v1/services?limit=4&sort=id",
+ "kind": "http://172.30.0.100:8080/v1/services?limit=4&sort=kind",
+ "name": "http://172.30.0.100:8080/v1/services?limit=4&sort=name",
+ "removeTime": "http://172.30.0.100:8080/v1/services?limit=4&sort=removeTime",
+ "removed": "http://172.30.0.100:8080/v1/services?limit=4&sort=removed",
+ "selectorContainer": "http://172.30.0.100:8080/v1/services?limit=4&sort=selectorContainer",
+ "selectorLink": "http://172.30.0.100:8080/v1/services?limit=4&sort=selectorLink",
+ "state": "http://172.30.0.100:8080/v1/services?limit=4&sort=state",
+ "uuid": "http://172.30.0.100:8080/v1/services?limit=4&sort=uuid",
+ "vip": "http://172.30.0.100:8080/v1/services?limit=4&sort=vip"
+ },
+ "pagination": {
+ "first": null,
+ "previous": null,
+ "next": "http://172.30.0.100:8080/v1/services?limit=4&marker=m4",
+ "limit": 4,
+ "total": null,
+ "partial": true
+ },
+ "sort": null,
+ "filters": {
+ "accountId": null,
+ "createIndex": null,
+ "created": null,
+ "description": null,
+ "environmentId": null,
+ "externalId": null,
+ "healthState": null,
+ "id": null,
+ "kind": null,
+ "name": null,
+ "removeTime": null,
+ "removed": null,
+ "selectorContainer": null,
+ "selectorLink": null,
+ "state": null,
+ "uuid": null,
+ "vip": null
+ },
+ "createDefaults": {}
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/libcloud/blob/d179167a/libcloud/test/container/fixtures/rancher/list_containers.json
----------------------------------------------------------------------
diff --git a/libcloud/test/container/fixtures/rancher/list_containers.json b/libcloud/test/container/fixtures/rancher/list_containers.json
new file mode 100644
index 0000000..e55d786
--- /dev/null
+++ b/libcloud/test/container/fixtures/rancher/list_containers.json
@@ -0,0 +1,336 @@
+{
+ "type": "collection",
+ "resourceType": "container",
+ "links": {
+ "self": "http://172.30.0.100:8080/v1/containers"
+ },
+ "createTypes": {
+ "container": "http://172.30.0.100:8080/v1/containers",
+ "launchConfig": "http://172.30.0.100:8080/v1/launchconfigs",
+ "virtualMachine": "http://172.30.0.100:8080/v1/virtualmachines"
+ },
+ "actions": {},
+ "data": [
+ {
+ "id": "1i1",
+ "type": "container",
+ "links": {
+ "self": "http://172.30.0.100:8080/v1/containers/1i1",
+ "account": "http://172.30.0.100:8080/v1/containers/1i1/account",
+ "credentials": "http://172.30.0.100:8080/v1/containers/1i1/credentials",
+ "healthcheckInstanceHostMaps": "http://172.30.0.100:8080/v1/containers/1i1/healthcheckinstancehostmaps",
+ "hosts": "http://172.30.0.100:8080/v1/containers/1i1/hosts",
+ "instanceLabels": "http://172.30.0.100:8080/v1/containers/1i1/instancelabels",
+ "instanceLinks": "http://172.30.0.100:8080/v1/containers/1i1/instancelinks",
+ "instances": "http://172.30.0.100:8080/v1/containers/1i1/instances",
+ "mounts": "http://172.30.0.100:8080/v1/containers/1i1/mounts",
+ "ports": "http://172.30.0.100:8080/v1/containers/1i1/ports",
+ "serviceEvents": "http://172.30.0.100:8080/v1/containers/1i1/serviceevents",
+ "serviceExposeMaps": "http://172.30.0.100:8080/v1/containers/1i1/serviceexposemaps",
+ "services": "http://172.30.0.100:8080/v1/containers/1i1/services",
+ "targetInstanceLinks": "http://172.30.0.100:8080/v1/containers/1i1/targetinstancelinks",
+ "volumes": "http://172.30.0.100:8080/v1/containers/1i1/volumes",
+ "stats": "http://172.30.0.100:8080/v1/containers/1i1/stats",
+ "containerStats": "http://172.30.0.100:8080/v1/containers/1i1/containerstats"
+ },
+ "actions": {
+ "update": "http://172.30.0.100:8080/v1/containers/1i1/?action=update",
+ "error": "http://172.30.0.100:8080/v1/containers/1i1/?action=error",
+ "remove": "http://172.30.0.100:8080/v1/containers/1i1/?action=remove",
+ "start": "http://172.30.0.100:8080/v1/containers/1i1/?action=start",
+ "logs": "http://172.30.0.100:8080/v1/containers/1i1/?action=logs",
+ "setlabels": "http://172.30.0.100:8080/v1/containers/1i1/?action=setlabels"
+ },
+ "name": "Concrete5_CMSMysql_1",
+ "state": "stopped",
+ "accountId": "1a5",
+ "blkioDeviceOptions": null,
+ "build": null,
+ "capAdd": null,
+ "capDrop": null,
+ "command": null,
+ "cpuSet": null,
+ "cpuShares": null,
+ "createIndex": 1,
+ "created": "2016-09-22T17:58:55Z",
+ "createdTS": 1474567135000,
+ "dataVolumeMounts": {},
+ "dataVolumes": [
+ "CMS_DB_DATA:/var/lib/mysql"
+ ],
+ "dataVolumesFrom": null,
+ "deploymentUnitUuid": "761675e2-7fc7-4fbf-a825-132429a44349",
+ "description": null,
+ "devices": null,
+ "dns": [
+ "169.254.169.250"
+ ],
+ "dnsSearch": [
+ "concrete5.rancher.internal",
+ "cmsmysql.concrete5.rancher.internal",
+ "rancher.internal"
+ ],
+ "dockerPorts": [],
+ "domainName": null,
+ "entryPoint": null,
+ "environment": {
+ "MYSQL_DATABASE": "CMS_DB",
+ "MYSQL_PASSWORD": "password",
+ "MYSQL_ROOT_PASSWORD": "password",
+ "MYSQL_USER": "CMS_USER"
+ },
+ "expose": null,
+ "externalId": "957136960bd1b51acf5a6c0079d0e35b8d5c14f54722a3063ceb868e85fd3758",
+ "extraHosts": null,
+ "firstRunning": "2016-09-22T17:59:40Z",
+ "firstRunningTS": 1474567180000,
+ "healthCheck": null,
+ "healthState": null,
+ "hostId": "1h1",
+ "hostname": null,
+ "imageUuid": "docker:mysql",
+ "kind": "container",
+ "labels": {
+ "io.rancher.project.name": "Concrete5",
+ "io.rancher.container.pull_image": "always",
+ "io.rancher.service.deployment.unit": "761675e2-7fc7-4fbf-a825-132429a44349",
+ "io.rancher.service.launch.config": "io.rancher.service.primary.launch.config",
+ "io.rancher.project_service.name": "Concrete5/CMSMysql",
+ "io.rancher.stack.name": "Concrete5",
+ "io.rancher.stack_service.name": "Concrete5/CMSMysql",
+ "io.rancher.service.hash": "c5d6bacef4be47a5ca5d1517a1d33319d024cdde",
+ "io.rancher.container.uuid": "a1140e7c-9260-423e-a7d0-8f5f7bb8e946",
+ "io.rancher.container.name": "Concrete5_CMSMysql_1",
+ "io.rancher.container.ip": "10.42.80.96/16"
+ },
+ "logConfig": {},
+ "lxcConf": null,
+ "memory": null,
+ "memorySwap": null,
+ "nativeContainer": false,
+ "networkContainerId": null,
+ "networkMode": "managed",
+ "pidMode": null,
+ "ports": null,
+ "primaryIpAddress": "10.42.80.96",
+ "privileged": false,
+ "publishAllPorts": false,
+ "readOnly": false,
+ "registryCredentialId": null,
+ "removed": null,
+ "requestedHostId": null,
+ "restartPolicy": null,
+ "securityOpt": null,
+ "startCount": 4,
+ "startOnCreate": true,
+ "stdinOpen": true,
+ "systemContainer": null,
+ "transitioning": "no",
+ "transitioningMessage": null,
+ "transitioningProgress": null,
+ "tty": true,
+ "user": null,
+ "uuid": "a1140e7c-9260-423e-a7d0-8f5f7bb8e946",
+ "version": "0",
+ "volumeDriver": null,
+ "workingDir": null
+ },
+ {
+ "id": "1i2",
+ "type": "container",
+ "links": {
+ "self": "http://172.30.0.100:8080/v1/containers/1i2",
+ "account": "http://172.30.0.100:8080/v1/containers/1i2/account",
+ "credentials": "http://172.30.0.100:8080/v1/containers/1i2/credentials",
+ "healthcheckInstanceHostMaps": "http://172.30.0.100:8080/v1/containers/1i2/healthcheckinstancehostmaps",
+ "hosts": "http://172.30.0.100:8080/v1/containers/1i2/hosts",
+ "instanceLabels": "http://172.30.0.100:8080/v1/containers/1i2/instancelabels",
+ "instanceLinks": "http://172.30.0.100:8080/v1/containers/1i2/instancelinks",
+ "instances": "http://172.30.0.100:8080/v1/containers/1i2/instances",
+ "mounts": "http://172.30.0.100:8080/v1/containers/1i2/mounts",
+ "ports": "http://172.30.0.100:8080/v1/containers/1i2/ports",
+ "serviceEvents": "http://172.30.0.100:8080/v1/containers/1i2/serviceevents",
+ "serviceExposeMaps": "http://172.30.0.100:8080/v1/containers/1i2/serviceexposemaps",
+ "services": "http://172.30.0.100:8080/v1/containers/1i2/services",
+ "targetInstanceLinks": "http://172.30.0.100:8080/v1/containers/1i2/targetinstancelinks",
+ "volumes": "http://172.30.0.100:8080/v1/containers/1i2/volumes",
+ "stats": "http://172.30.0.100:8080/v1/containers/1i2/stats",
+ "containerStats": "http://172.30.0.100:8080/v1/containers/1i2/containerstats"
+ },
+ "actions": {
+ "update": "http://172.30.0.100:8080/v1/containers/1i2/?action=update",
+ "stop": "http://172.30.0.100:8080/v1/containers/1i2/?action=stop",
+ "restart": "http://172.30.0.100:8080/v1/containers/1i2/?action=restart",
+ "migrate": "http://172.30.0.100:8080/v1/containers/1i2/?action=migrate",
+ "logs": "http://172.30.0.100:8080/v1/containers/1i2/?action=logs",
+ "setlabels": "http://172.30.0.100:8080/v1/containers/1i2/?action=setlabels",
+ "execute": "http://172.30.0.100:8080/v1/containers/1i2/?action=execute",
+ "proxy": "http://172.30.0.100:8080/v1/containers/1i2/?action=proxy"
+ },
+ "name": "Network Agent",
+ "state": "running",
+ "accountId": "1a5",
+ "blkioDeviceOptions": null,
+ "build": null,
+ "capAdd": null,
+ "capDrop": null,
+ "command": null,
+ "cpuSet": null,
+ "cpuShares": null,
+ "createIndex": null,
+ "created": "2016-09-22T17:58:57Z",
+ "createdTS": 1474567137000,
+ "dataVolumeMounts": {},
+ "dataVolumes": [
+ "/var/lib/rancher/etc:/var/lib/rancher/etc:ro"
+ ],
+ "dataVolumesFrom": null,
+ "deploymentUnitUuid": null,
+ "description": null,
+ "devices": null,
+ "dns": null,
+ "dnsSearch": null,
+ "domainName": null,
+ "entryPoint": null,
+ "environment": null,
+ "expose": null,
+ "externalId": "129c67adc9fa084fbc8e1f963db0180896b88af3dca69c7e8fe0493284e4651c",
+ "extraHosts": null,
+ "firstRunning": "2016-09-22T17:59:11Z",
+ "firstRunningTS": 1474567151000,
+ "healthCheck": null,
+ "healthState": null,
+ "hostId": "1h1",
+ "hostname": null,
+ "imageUuid": "docker:rancher/agent-instance:v0.8.3",
+ "kind": "container",
+ "labels": {
+ "io.rancher.container.system": "NetworkAgent",
+ "io.rancher.container.uuid": "b0f88089-d28b-4388-93a7-889b750cd7cb",
+ "io.rancher.container.name": "Network Agent",
+ "io.rancher.container.agent_id": "2",
+ "io.rancher.container.ip": "10.42.247.188/16"
+ },
+ "logConfig": null,
+ "lxcConf": null,
+ "memory": null,
+ "memorySwap": null,
+ "nativeContainer": false,
+ "networkContainerId": null,
+ "networkIds": [],
+ "networkMode": null,
+ "pidMode": null,
+ "ports": null,
+ "primaryIpAddress": "10.42.247.188",
+ "privileged": true,
+ "publishAllPorts": false,
+ "readOnly": false,
+ "registryCredentialId": null,
+ "removed": null,
+ "requestedHostId": null,
+ "restartPolicy": null,
+ "securityOpt": null,
+ "startCount": 3,
+ "startOnCreate": true,
+ "stdinOpen": false,
+ "systemContainer": "NetworkAgent",
+ "transitioning": "no",
+ "transitioningMessage": null,
+ "transitioningProgress": null,
+ "tty": false,
+ "user": null,
+ "uuid": "b0f88089-d28b-4388-93a7-889b750cd7cb",
+ "version": "0",
+ "volumeDriver": null,
+ "workingDir": null
+ }
+ ],
+ "sortLinks": {
+ "accountId": "http://172.30.0.100:8080/v1/containers?limit=2&sort=accountId",
+ "agentId": "http://172.30.0.100:8080/v1/containers?limit=2&sort=agentId",
+ "allocationState": "http://172.30.0.100:8080/v1/containers?limit=2&sort=allocationState",
+ "compute": "http://172.30.0.100:8080/v1/containers?limit=2&sort=compute",
+ "createIndex": "http://172.30.0.100:8080/v1/containers?limit=2&sort=createIndex",
+ "created": "http://172.30.0.100:8080/v1/containers?limit=2&sort=created",
+ "deploymentUnitUuid": "http://172.30.0.100:8080/v1/containers?limit=2&sort=deploymentUnitUuid",
+ "description": "http://172.30.0.100:8080/v1/containers?limit=2&sort=description",
+ "dnsInternal": "http://172.30.0.100:8080/v1/containers?limit=2&sort=dnsInternal",
+ "dnsSearchInternal": "http://172.30.0.100:8080/v1/containers?limit=2&sort=dnsSearchInternal",
+ "domain": "http://172.30.0.100:8080/v1/containers?limit=2&sort=domain",
+ "externalId": "http://172.30.0.100:8080/v1/containers?limit=2&sort=externalId",
+ "firstRunning": "http://172.30.0.100:8080/v1/containers?limit=2&sort=firstRunning",
+ "healthState": "http://172.30.0.100:8080/v1/containers?limit=2&sort=healthState",
+ "healthUpdated": "http://172.30.0.100:8080/v1/containers?limit=2&sort=healthUpdated",
+ "hostname": "http://172.30.0.100:8080/v1/containers?limit=2&sort=hostname",
+ "id": "http://172.30.0.100:8080/v1/containers?limit=2&sort=id",
+ "imageId": "http://172.30.0.100:8080/v1/containers?limit=2&sort=imageId",
+ "instanceTriggeredStop": "http://172.30.0.100:8080/v1/containers?limit=2&sort=instanceTriggeredStop",
+ "kind": "http://172.30.0.100:8080/v1/containers?limit=2&sort=kind",
+ "memoryMb": "http://172.30.0.100:8080/v1/containers?limit=2&sort=memoryMb",
+ "name": "http://172.30.0.100:8080/v1/containers?limit=2&sort=name",
+ "nativeContainer": "http://172.30.0.100:8080/v1/containers?limit=2&sort=nativeContainer",
+ "networkContainerId": "http://172.30.0.100:8080/v1/containers?limit=2&sort=networkContainerId",
+ "offeringId": "http://172.30.0.100:8080/v1/containers?limit=2&sort=offeringId",
+ "registryCredentialId": "http://172.30.0.100:8080/v1/containers?limit=2&sort=registryCredentialId",
+ "removeTime": "http://172.30.0.100:8080/v1/containers?limit=2&sort=removeTime",
+ "removed": "http://172.30.0.100:8080/v1/containers?limit=2&sort=removed",
+ "serviceIndexId": "http://172.30.0.100:8080/v1/containers?limit=2&sort=serviceIndexId",
+ "startCount": "http://172.30.0.100:8080/v1/containers?limit=2&sort=startCount",
+ "state": "http://172.30.0.100:8080/v1/containers?limit=2&sort=state",
+ "systemContainer": "http://172.30.0.100:8080/v1/containers?limit=2&sort=systemContainer",
+ "token": "http://172.30.0.100:8080/v1/containers?limit=2&sort=token",
+ "userdata": "http://172.30.0.100:8080/v1/containers?limit=2&sort=userdata",
+ "uuid": "http://172.30.0.100:8080/v1/containers?limit=2&sort=uuid",
+ "version": "http://172.30.0.100:8080/v1/containers?limit=2&sort=version",
+ "zoneId": "http://172.30.0.100:8080/v1/containers?limit=2&sort=zoneId"
+ },
+ "pagination": {
+ "first": null,
+ "previous": null,
+ "next": "http://172.30.0.100:8080/v1/containers?limit=2&marker=m2",
+ "limit": 2,
+ "total": null,
+ "partial": true
+ },
+ "sort": null,
+ "filters": {
+ "accountId": null,
+ "agentId": null,
+ "allocationState": null,
+ "compute": null,
+ "createIndex": null,
+ "created": null,
+ "deploymentUnitUuid": null,
+ "description": null,
+ "dnsInternal": null,
+ "dnsSearchInternal": null,
+ "domain": null,
+ "externalId": null,
+ "firstRunning": null,
+ "healthState": null,
+ "healthUpdated": null,
+ "hostname": null,
+ "id": null,
+ "imageId": null,
+ "instanceTriggeredStop": null,
+ "kind": null,
+ "memoryMb": null,
+ "name": null,
+ "nativeContainer": null,
+ "networkContainerId": null,
+ "offeringId": null,
+ "registryCredentialId": null,
+ "removeTime": null,
+ "removed": null,
+ "serviceIndexId": null,
+ "startCount": null,
+ "state": null,
+ "systemContainer": null,
+ "token": null,
+ "userdata": null,
+ "uuid": null,
+ "version": null,
+ "zoneId": null
+ },
+ "createDefaults": {}
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/libcloud/blob/d179167a/libcloud/test/container/fixtures/rancher/stop_container.json
----------------------------------------------------------------------
diff --git a/libcloud/test/container/fixtures/rancher/stop_container.json b/libcloud/test/container/fixtures/rancher/stop_container.json
new file mode 100644
index 0000000..fad41a6
--- /dev/null
+++ b/libcloud/test/container/fixtures/rancher/stop_container.json
@@ -0,0 +1,109 @@
+{
+ "id": "1i31",
+ "type": "container",
+ "links": {
+ "self": "http://172.30.0.100:8080/v1/containers/1i31",
+ "account": "http://172.30.0.100:8080/v1/containers/1i31/account",
+ "credentials": "http://172.30.0.100:8080/v1/containers/1i31/credentials",
+ "healthcheckInstanceHostMaps": "http://172.30.0.100:8080/v1/containers/1i31/healthcheckinstancehostmaps",
+ "hosts": "http://172.30.0.100:8080/v1/containers/1i31/hosts",
+ "instanceLabels": "http://172.30.0.100:8080/v1/containers/1i31/instancelabels",
+ "instanceLinks": "http://172.30.0.100:8080/v1/containers/1i31/instancelinks",
+ "instances": "http://172.30.0.100:8080/v1/containers/1i31/instances",
+ "mounts": "http://172.30.0.100:8080/v1/containers/1i31/mounts",
+ "ports": "http://172.30.0.100:8080/v1/containers/1i31/ports",
+ "serviceEvents": "http://172.30.0.100:8080/v1/containers/1i31/serviceevents",
+ "serviceExposeMaps": "http://172.30.0.100:8080/v1/containers/1i31/serviceexposemaps",
+ "services": "http://172.30.0.100:8080/v1/containers/1i31/services",
+ "targetInstanceLinks": "http://172.30.0.100:8080/v1/containers/1i31/targetinstancelinks",
+ "volumes": "http://172.30.0.100:8080/v1/containers/1i31/volumes",
+ "stats": "http://172.30.0.100:8080/v1/containers/1i31/stats",
+ "containerStats": "http://172.30.0.100:8080/v1/containers/1i31/containerstats"
+ },
+ "actions": {
+ "update": "http://172.30.0.100:8080/v1/containers/1i31/?action=update",
+ "error": "http://172.30.0.100:8080/v1/containers/1i31/?action=error",
+ "remove": "http://172.30.0.100:8080/v1/containers/1i31/?action=remove",
+ "start": "http://172.30.0.100:8080/v1/containers/1i31/?action=start",
+ "logs": "http://172.30.0.100:8080/v1/containers/1i31/?action=logs",
+ "setlabels": "http://172.30.0.100:8080/v1/containers/1i31/?action=setlabels"
+ },
+ "name": "newcontainer",
+ "state": "stopping",
+ "accountId": "1a5",
+ "blkioDeviceOptions": null,
+ "build": null,
+ "capAdd": null,
+ "capDrop": null,
+ "command": null,
+ "cpuSet": null,
+ "cpuShares": null,
+ "createIndex": null,
+ "created": "2016-10-06T15:55:58Z",
+ "createdTS": 1475769358000,
+ "dataVolumeMounts": {},
+ "dataVolumes": [],
+ "dataVolumesFrom": null,
+ "deploymentUnitUuid": null,
+ "description": null,
+ "devices": null,
+ "dns": [
+ "169.254.169.250"
+ ],
+ "dnsSearch": [
+ "rancher.internal"
+ ],
+ "dockerPorts": [],
+ "domainName": null,
+ "entryPoint": null,
+ "environment": {
+ "STORAGE_TYPE": "file"
+ },
+ "expose": null,
+ "externalId": "ab334bd25d25db7b94fdcead8f5c023b05bed424f56243187aa90f5ef7f07b09",
+ "extraHosts": null,
+ "firstRunning": "2016-10-06T15:56:00Z",
+ "firstRunningTS": 1475769360000,
+ "healthCheck": null,
+ "healthState": null,
+ "hostId": "1h1",
+ "hostname": null,
+ "imageUuid": "docker:rlister/hastebin:latest",
+ "kind": "container",
+ "labels": {
+ "io.rancher.container.uuid": "6d3dcf5f-28b8-4e60-9bf1-618b76a9a805",
+ "io.rancher.container.name": "newcontainer",
+ "io.rancher.container.ip": "10.42.204.104/16"
+ },
+ "logConfig": null,
+ "lxcConf": null,
+ "memory": null,
+ "memorySwap": null,
+ "nativeContainer": false,
+ "networkContainerId": null,
+ "networkMode": "managed",
+ "pidMode": null,
+ "ports": null,
+ "primaryIpAddress": "10.42.204.104",
+ "privileged": false,
+ "publishAllPorts": false,
+ "readOnly": false,
+ "registryCredentialId": null,
+ "removed": null,
+ "requestedHostId": null,
+ "restartPolicy": null,
+ "securityOpt": null,
+ "startCount": 1,
+ "startOnCreate": true,
+ "stdinOpen": false,
+ "systemContainer": null,
+ "transitioning": "yes",
+ "transitioningMessage": null,
+ "transitioningProgress": null,
+ "tty": false,
+ "user": null,
+ "uuid": "6d3dcf5f-28b8-4e60-9bf1-618b76a9a805",
+ "version": "0",
+ "volumeDriver": null,
+ "workingDir": null
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/libcloud/blob/d179167a/libcloud/test/container/test_rancher.py
----------------------------------------------------------------------
diff --git a/libcloud/test/container/test_rancher.py b/libcloud/test/container/test_rancher.py
new file mode 100644
index 0000000..2d1cc4d
--- /dev/null
+++ b/libcloud/test/container/test_rancher.py
@@ -0,0 +1,245 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import sys
+
+from libcloud.test import unittest
+
+from libcloud.container.base import ContainerImage
+from libcloud.container.drivers.rancher import RancherContainerDriver
+
+from libcloud.utils.py3 import httplib
+from libcloud.test.secrets import CONTAINER_PARAMS_RANCHER
+from libcloud.test.file_fixtures import ContainerFileFixtures
+from libcloud.test import MockHttp
+
+
+class RancherContainerDriverTestCase(unittest.TestCase):
+
+ def setUp(self):
+ RancherContainerDriver.connectionCls.conn_classes = (
+ RancherMockHttp, RancherMockHttp)
+ RancherMockHttp.type = None
+ RancherMockHttp.use_param = 'a'
+ self.driver = RancherContainerDriver(*CONTAINER_PARAMS_RANCHER)
+
+ # Stacks
+ def test_ex_list_stacks(self):
+ stacks = self.driver.ex_list_stacks()
+ self.assertEqual(len(stacks), 6)
+ self.assertEqual(stacks[0]['id'], "1e1")
+
+ def test_ex_deploy_stack(self):
+ stack = self.driver.ex_deploy_stack(name="newstack",
+ environment={
+ "root_password": "password"
+ })
+ self.assertEqual(stack['id'], "1e9")
+ self.assertEqual(stack['environment']['root_password'], "password")
+
+ def test_ex_get_stack(self):
+ # also uses ex_deploy_stack.json
+ stack = self.driver.ex_get_stack("1e9")
+ self.assertEqual(stack['id'], "1e9")
+ self.assertEqual(stack['environment']['root_password'], "password")
+
+ def test_ex_search_stacks(self):
+ # also uses ex_list_stacks.json
+ stacks = self.driver.ex_search_stacks({"healthState": "healthy"})
+ self.assertEqual(len(stacks), 6)
+ self.assertEqual(stacks[0]['healthState'], "healthy")
+
+ def test_ex_destroy_stack(self):
+ # Not sure how to do these with returns in mockhttp
+ response = self.driver.ex_destroy_stack("1e10")
+ self.assertEqual(response, True)
+
+ def test_ex_activate_stack(self):
+ response = self.driver.ex_activate_stack("1e1")
+ self.assertEqual(response, True)
+
+ def test_ex_deactivate_stack(self):
+ # also uses ex_activate_stack.json
+ response = self.driver.ex_activate_stack("1e1")
+ self.assertEqual(response, True)
+
+ def test_ex_list_services(self):
+ services = self.driver.ex_list_services()
+ self.assertEqual(len(services), 4)
+ self.assertEqual(services[0]['id'], "1s1")
+
+ def test_ex_deploy_service(self):
+ image = ContainerImage(
+ id="hastebin",
+ name="hastebin",
+ path="rlister/hastebin",
+ version="latest",
+ driver=None
+ )
+ service = self.driver.ex_deploy_service(name="newservice",
+ environment_id="1e1",
+ image=image,
+ environment={
+ "root_password": "password"
+ })
+ self.assertEqual(service['id'], "1s13")
+ self.assertEqual(service['environmentId'], "1e6")
+ self.assertEqual(service['launchConfig']['environment']
+ ['root_password'], "password")
+ self.assertEqual(service['launchConfig']['imageUuid'],
+ "docker:rlister/hastebin:latest")
+
+ def test_ex_get_service(self):
+ # also uses ex_deploy_service.json
+ service = self.driver.ex_get_service("1s13")
+ self.assertEqual(service['id'], "1s13")
+ self.assertEqual(service['environmentId'], "1e6")
+ self.assertEqual(service['launchConfig']['environment']
+ ['root_password'], "password")
+
+ def test_ex_search_services(self):
+ services = self.driver.ex_search_services({"healthState": "healthy"})
+ self.assertEqual(len(services), 2)
+ self.assertEqual(services[0]['healthState'], "healthy")
+
+ def test_ex_destroy_service(self):
+ # Not sure how to do these with returns in mockhttp
+ response = self.driver.ex_destroy_service("1s13")
+ self.assertEqual(response, True)
+
+ def test_ex_activate_service(self):
+ response = self.driver.ex_activate_service("1s6")
+ self.assertEqual(response, True)
+
+ def test_ex_deactivate_service(self):
+ # also uses ex_activate_service.json
+ response = self.driver.ex_activate_service("1s6")
+ self.assertEqual(response, True)
+
+ def test_list_containers(self):
+ containers = self.driver.list_containers()
+ self.assertEqual(len(containers), 2)
+ self.assertEqual(containers[0].id, "1i1")
+
+ def test_deploy_container(self):
+ container = self.driver.deploy_container(
+ name='newcontainer',
+ image=ContainerImage(
+ id="hastebin",
+ name="hastebin",
+ path="rlister/hastebin",
+ version="latest",
+ driver=None
+ ),
+ environment={"STORAGE_TYPE": "file"},
+ networkMode="managed"
+ )
+ self.assertEqual(container.id, '1i31')
+ self.assertEqual(container.name, 'newcontainer')
+ self.assertEqual(container.extra['environment'],
+ {'STORAGE_TYPE': 'file'})
+
+ def test_get_container(self):
+ # also uses ex_deploy_container.json
+ container = self.driver.get_container("1i31")
+ self.assertEqual(container.id, '1i31')
+ self.assertEqual(container.name, 'newcontainer')
+ self.assertEqual(container.extra['environment'],
+ {'STORAGE_TYPE': 'file'})
+
+ def test_stop_container(self):
+ container = self.driver.get_container("1i31")
+ container.stop()
+
+ def test_ex_search_containers(self):
+ containers = self.driver.ex_search_containers({"state": "running"})
+ self.assertEqual(len(containers), 1)
+
+ def test_destroy_container(self):
+ container = self.driver.get_container("1i31")
+ container.destroy()
+
+
+class RancherMockHttp(MockHttp):
+ fixtures = ContainerFileFixtures('rancher')
+
+ def _v1_environments(self, method, url, body, headers):
+ if method == 'GET':
+ return (httplib.OK, self.fixtures.load('ex_list_stacks.json'), {},
+ httplib.responses[httplib.OK])
+ else:
+ return (httplib.OK, self.fixtures.load('ex_deploy_stack.json'), {},
+ httplib.responses[httplib.OK])
+
+ def _v1_environments_1e9(self, method, url, body, headers):
+ return (httplib.OK, self.fixtures.load('ex_deploy_stack.json'), {},
+ httplib.responses[httplib.OK])
+
+ def _v1_environments_1e10(self, method, url, body, headers):
+ return (httplib.OK, self.fixtures.load('ex_destroy_stack.json'), {},
+ httplib.responses[httplib.OK])
+
+ def _v1_environments_1e1(self, method, url, body, headers):
+ return (httplib.OK, self.fixtures.load('ex_activate_stack.json'), {},
+ httplib.responses[httplib.OK])
+
+ def _v1_services(self, method, url, body, headers):
+ if '?healthState=healthy' in url:
+ return (httplib.OK, self.fixtures.load('ex_search_services.json'),
+ {}, httplib.responses[httplib.OK])
+ elif method == 'GET':
+ return (httplib.OK, self.fixtures.load('ex_list_services.json'),
+ {}, httplib.responses[httplib.OK])
+ else:
+ return (httplib.OK, self.fixtures.load('ex_deploy_service.json'),
+ {}, httplib.responses[httplib.OK])
+
+ def _v1_services_1s13(self, method, url, body, headers):
+ if method == 'GET':
+ return (httplib.OK, self.fixtures.load('ex_deploy_service.json'),
+ {}, httplib.responses[httplib.OK])
+ elif method == 'DELETE':
+ return (httplib.OK, self.fixtures.load('ex_destroy_service.json'),
+ {}, httplib.responses[httplib.OK])
+
+ def _v1_services_1s6(self, method, url, body, headers):
+ return (httplib.OK, self.fixtures.load('ex_activate_service.json'), {},
+ httplib.responses[httplib.OK])
+
+ def _v1_containers(self, method, url, body, headers):
+ if '?state=running' in url:
+ return (httplib.OK, self.fixtures.load(
+ 'ex_search_containers.json'), {}, httplib.responses[httplib.OK]
+ )
+ elif method == 'POST':
+ return (httplib.OK, self.fixtures.load('deploy_container.json'),
+ {}, httplib.responses[httplib.OK])
+ return (httplib.OK, self.fixtures.load('list_containers.json'), {},
+ httplib.responses[httplib.OK])
+
+ def _v1_containers_1i31(self, method, url, body, headers):
+ if method == 'GET':
+ return (httplib.OK, self.fixtures.load('deploy_container.json'),
+ {}, httplib.responses[httplib.OK])
+ elif method == 'DELETE' or '?action=stop' in url:
+ return (httplib.OK, self.fixtures.load('stop_container.json'), {},
+ httplib.responses[httplib.OK])
+ else:
+ return (httplib.OK, self.fixtures.load('deploy_container.json'),
+ {}, httplib.responses[httplib.OK])
+
+
+if __name__ == '__main__':
+ sys.exit(unittest.main())