def pull_image_hyper():
	auth = {'username':'******', 'password':'******'}
	c = Client("./hyper_config.json")
	line_concat = ""
	for line in c.pull(repository='REPO', stream=True, auth_config=auth):
		line_concat += json.dumps(json.loads(line))
	return line_concat
def poll_logs(guid):
	import re
	c = Client("./hyper_config.json")
	logs = c.logs(guid)
	split_string = re.split('\n|\r', logs)
	concat = ""
	for item in split_string:
		print(item)
		concat += item + "<br />"
	return "<div>" + concat + "</div>";
Beispiel #3
0
    def test_valid_config(self):
        # Test with valid env vars.
        with patch.object(
                os, 'environ', {
                    'HYPER_ENDPOINT': 'tcp://us-west-1.hyper.sh:443',
                    'HYPER_ACCESSKEY': 'abc123',
                    'HYPER_SECRETKEY': '321cba'
                }):
            assert (isinstance(from_env(), Client))

        # Test with valid config file.
        assert (Client(config_path))

        # Test with valid config object.
        config = json.load(open(config_path))
        assert (Client(config))
Beispiel #4
0
    def test_invalid_path(self):
        # Test no default file and no env vars.
        with self.assertRaises(TypeError):
            Client()

        # Test file can't be found.
        with self.assertRaises(IOError):
            Client('no_file.json')

        # Test invalid config.
        with self.assertRaises(RuntimeError):
            Client({})

        # Test invalid clouds.
        with self.assertRaises(RuntimeError):
            Client({'clouds': {'a': {}, 'b': {}}})
Beispiel #5
0
def assertSetup():
    try:
        Client.guess_config()
    except RuntimeError:
        raise SkipTest("no default config is detected")
Beispiel #6
0
def test_create_container():
    assertSetup()
    c = Client()  # guess config
    cid = c.create_container("busybox")
    c.remove_container(cid, force=True)
Beispiel #7
0
def test_list_images():
    assertSetup()
    c = Client()  # guess config
    assert len(c.images()) != 0
def create_container(api, yt_url):
	c = Client("./hyper_config.json")
	# working_dir="/tmp"
	container = c.create_container(labels={"sh_hyper_instancetype": "s3", 'sh_hyper_noauto_volume': 'true'}, image="1dcb5ad1", command='python3 process_file.py "{yt_url}" "{api_url}"'.format(yt_url=yt_url, api_url=api))
	response = c.start(container=container.get("Id"))
	return container.get("Id")