Exemple #1
0
 def test_context_manager(self, cwdmock):
     cwdmock.return_value = '/tmp'
     with patch('os.chdir') as chmock:
         compose = Compose('files/workspace', strict=False)
         with patch('charms.docker.runner.check_output'):
             compose.up('nginx')
             # We can only test the return called with in this manner.
             # So check that we at least reset context
             chmock.assert_called_with('/tmp')
Exemple #2
0
def swarm_relation_broken():
    """
    Destroy the swarm agent, and optionally the manager.
    This state should only be entered if the Docker host relation with ETCD has
    been broken, thus leaving the cluster without a discovery service
    """
    c = Compose('files/swarm')
    c.kill()
    c.rm()
    remove_state('swarm.available')
    status_set('waiting', 'Reconfiguring swarm')
Exemple #3
0
def start_swarm(cluster_string, cert_path=None):
    ''' Render the compose configuration and start the swarm scheduler '''
    opts = {}
    opts['addr'] = unit_private_ip()
    opts['port'] = 2376
    opts['leader'] = is_leader()
    opts['connection_string'] = cluster_string
    if cert_path:
        opts['discovery_tls_path'] = cert_path
    render('docker-compose.yml', 'files/swarm/docker-compose.yml', opts)
    c = Compose('files/swarm')
    c.up()
    set_state('swarm.available')
Exemple #4
0
def compose():
    '''compose brings up the athens service.'''
    status_set('maintenance', 'docker-compose up athens')
    os.environ['athens_image'] = config()['athens-image']
    os.environ['ATHENS_DISK_STORAGE_ROOT'] = '/srv/athens/cache'
    os.environ['ATHENS_STORAGE_TYPE'] = 'disk'
    os.environ['ATHENS_NETRC_PATH'] = '/srv/athens/netrc'
    os.environ['http_proxy'] = config()['http_proxy']
    os.environ['https_proxy'] = config()['https_proxy']
    os.environ['no_proxy'] = config()['no_proxy']
    Compose(charm_dir()).up()
    clear_flag('athens.restart')
    set_flag('athens.up')
    application_version_set(
        requests.get('http://localhost:3000/version').json()['version'])
    status_set('active', 'athens running')
 def _compose(self):
     return Compose(os.path.dirname(str(self.compose_config)))
def stop():
    compose = Compose('files/docker-registry')
    compose.down()
    close_port(config().previous('registry_port'))
    status_set('maintenance', 'Docker registry stopped.')
def start():
    compose = Compose('files/docker-registry')
    compose.up()
    open_port(config('registry_port'))
    status_set('active', 'Docker registry ready.')
Exemple #8
0
 def test_init_strict(self):
     with patch('charms.docker.compose.Workspace.validate') as f:
         Compose('test', strict=True)
         # Is this the beast? is mock() doing the right thing here?
         f.assert_called_with()
Exemple #9
0
 def test_run(self, ccmock, chmock):
     compose = Compose('files/workspace', strict=False)
     compose.up('nginx')
     chmock.assert_called_with('files/workspace')
     ccmock.assert_called_with(['docker-compose', 'up', '-d', 'nginx'])
Exemple #10
0
 def compose(self):
     return Compose('files/test', strict=False)
Exemple #11
0
 def test_socket_run_has_host_output(self, ccmock, chmock):
     compose = Compose('files/workspace', strict=False, socket='test')
     compose.up()
     chmock.assert_called_with('files/workspace')
     ccmock.assert_called_with(['docker-compose', 'up', '-d'])
     assert (os.getenv('DOCKER_HOST') == 'test')