Example #1
0
 def run(self, credentials, name, repository_name, tag,
         start, cluster_id=None, parameters=None):
     driver = self._get_driver_for_credentials(credentials=credentials)
     hub_client = HubClient()
     image = hub_client.get_image(repository_name, tag)
     if cluster_id is not None:
         cluster = driver.get_cluster(cluster_id)
     else:
         cluster = None
     record = driver.deploy_container(name=name, image=image,
                                      start=start, cluster=cluster,
                                      parameters=parameters)
     return self.resultsets.formatter(record)
class DockerUtilitiesTestCase(unittest.TestCase):
    def setUp(self):
        HubClient.connectionCls.conn_class = DockerMockHttp
        DockerMockHttp.type = None
        DockerMockHttp.use_param = 'a'
        self.driver = HubClient()

    def test_list_tags(self):
        tags = self.driver.list_images('ubuntu', max_count=100)
        self.assertEqual(len(tags), 88)
        self.assertEqual(tags[0].name, 'registry.hub.docker.com/ubuntu:xenial')

    def test_get_repository(self):
        repo = self.driver.get_repository('ubuntu')
        self.assertEqual(repo['name'], 'ubuntu')

    def test_get_image(self):
        image = self.driver.get_image('ubuntu', 'latest')
        self.assertEqual(image.id, '2343')
        self.assertEqual(image.name, 'registry.hub.docker.com/ubuntu:latest')
        self.assertEqual(image.path, 'registry.hub.docker.com/ubuntu:latest')
Example #3
0
class DockerUtilitiesTestCase(unittest.TestCase):
    def setUp(self):
        HubClient.connectionCls.conn_class = DockerMockHttp
        DockerMockHttp.type = None
        DockerMockHttp.use_param = "a"
        self.driver = HubClient()

    def test_list_tags(self):
        tags = self.driver.list_images("ubuntu", max_count=100)
        self.assertEqual(len(tags), 88)
        self.assertEqual(tags[0].name, "registry.hub.docker.com/ubuntu:xenial")

    def test_get_repository(self):
        repo = self.driver.get_repository("ubuntu")
        self.assertEqual(repo["name"], "ubuntu")

    def test_get_image(self):
        image = self.driver.get_image("ubuntu", "latest")
        self.assertEqual(image.id, "2343")
        self.assertEqual(image.name, "registry.hub.docker.com/ubuntu:latest")
        self.assertEqual(image.path, "registry.hub.docker.com/ubuntu:latest")
class DockerUtilitiesTestCase(unittest.TestCase):

    def setUp(self):
        HubClient.connectionCls.conn_class = DockerMockHttp
        DockerMockHttp.type = None
        DockerMockHttp.use_param = 'a'
        self.driver = HubClient()

    def test_list_tags(self):
        tags = self.driver.list_images('ubuntu', max_count=100)
        self.assertEqual(len(tags), 88)
        self.assertEqual(tags[0].name, 'registry.hub.docker.com/ubuntu:xenial')

    def test_get_repository(self):
        repo = self.driver.get_repository('ubuntu')
        self.assertEqual(repo['name'], 'ubuntu')

    def test_get_image(self):
        image = self.driver.get_image('ubuntu', 'latest')
        self.assertEqual(image.id, '2343')
        self.assertEqual(image.name, 'registry.hub.docker.com/ubuntu:latest')
        self.assertEqual(image.path, 'registry.hub.docker.com/ubuntu:latest')
Example #5
0
 def setUp(self):
     HubClient.connectionCls.conn_class = DockerMockHttp
     DockerMockHttp.type = None
     DockerMockHttp.use_param = "a"
     self.driver = HubClient()
 def setUp(self):
     HubClient.connectionCls.conn_classes = (
         DockerMockHttp, DockerMockHttp)
     DockerMockHttp.type = None
     DockerMockHttp.use_param = 'a'
     self.driver = HubClient()
Example #7
0
from libcloud.container.types import Provider
from libcloud.container.providers import get_driver
from libcloud.container.utils.docker import HubClient

cls = get_driver(Provider.ECS)

conn = cls(access_id='SDHFISJDIFJSIDFJ',
           secret='THIS_IS)+_MY_SECRET_KEY+I6TVkv68o4H',
           region='ap-southeast-2')
hub = HubClient()

image = hub.get_image('ubuntu', 'latest')

for cluster in conn.list_clusters():
    print(cluster.name)
    if cluster.name == 'default':
        container = conn.deploy_container(
            cluster=cluster,
            name='my-simple-app',
            image=image)
 def setUp(self):
     HubClient.connectionCls.conn_class = DockerMockHttp
     DockerMockHttp.type = None
     DockerMockHttp.use_param = 'a'
     self.driver = HubClient()
Example #9
0
from libcloud.container.types import Provider
from libcloud.container.providers import get_driver
from libcloud.container.utils.docker import HubClient

cls = get_driver(Provider.KUBERNETES)

conn = cls(key='my_username',
           secret='THIS_IS)+_MY_SECRET_KEY+I6TVkv68o4H',
           host='126.32.21.4')
hub = HubClient()

image = hub.get_image('ubuntu', 'latest')

for cluster in conn.list_clusters():
    print(cluster.name)
    if cluster.name == 'default':
        container = conn.deploy_container(
            cluster=cluster,
            name='my-simple-app',
            image=image)
Example #10
0
from libcloud.container.types import Provider
from libcloud.container.providers import get_driver
from libcloud.container.utils.docker import HubClient

cls = get_driver(Provider.ECS)

conn = cls(
    access_id="SDHFISJDIFJSIDFJ",
    secret="THIS_IS)+_MY_SECRET_KEY+I6TVkv68o4H",
    region="ap-southeast-2",
)
hub = HubClient()

image = hub.get_image("ubuntu", "latest")

for cluster in conn.list_clusters():
    print(cluster.name)
    if cluster.name == "default":
        container = conn.deploy_container(cluster=cluster,
                                          name="my-simple-app",
                                          image=image)
 def run(self, search):
     client = HubClient()
     images = client.list_images(search)
     return [{"name": image.name, "version": image.version} for image in images]