def start(ssh_key_path, cloud_yml_path, kolla_dir):
    """ Start the Ansible container """
    name = 'ansible'
    repo = 'breqwatr/ansible'
    tag = SERVICE_IMAGE_TAGS[repo]
    image = '{}:{}'.format(repo, tag)
    docker_kwargs = {
        'volumes': {
            ssh_key_path: {
                'bind': '/root/.ssh/id_rsa',
                'mode': 'ro'
            },
            cloud_yml_path: {
                'bind': '/etc/breqwatr/cloud.yml',
                'mode': 'rw'
            },
            kolla_dir: {
                'bind': '/etc/kolla',
                'mode': 'rw'
            }
        }
    }
    docker = Docker()
    docker.pull(repository=repo, tag=tag)
    success = docker.run(image, name=name, **docker_kwargs)
    return success
示例#2
0
def api_start(fqdn, rabbit_pass, rabbit_ips_list, sql_ip,
              sql_password, ceph_enabled=False, https=True):
    """ Start the Arcus API service """
    name = "arcus_api"
    repo = "breqwatr/arcus-api"
    tag = SERVICE_IMAGE_TAGS[repo]
    image = '{}:{}'.format(repo, tag)
    rabbit_ips_csv = ','.join(rabbit_ips_list)
    docker_kwargs = {
        'environment': {
            'OPENSTACK_VIP': fqdn,
            'PUBLIC_ENDPOINT': 'true',
            'HTTPS_OPENSTACK_APIS': str(https).lower(),
            'RABBITMQ_USERNAME': '******',
            'RABBITMQ_PASSWORD': rabbit_pass,
            'RABBIT_IPS_CSV': rabbit_ips_csv,
            'SQL_USERNAME': '******',
            'SQL_PASSWORD': sql_password,
            'SQL_IP': sql_ip,
            'CEPH_ENABLED': str(ceph_enabled).lower()
        },
        'ports': {'1234': ('0.0.0.0', '1234')},
        'restart_policy': {'Name': 'always'}
    }
    docker = Docker()
    docker.pull(repository=repo, tag=tag)
    success = docker.run(image, name=name, **docker_kwargs)
    return success
示例#3
0
def client_start(api_ip, openstack_ip, glance_https=True, arcus_https=False,
                 cert_path=None, cert_key_path=None):
    """ Start the Arcus Client service """
    name = 'arcus_client'
    repo = 'breqwatr/arcus-client'
    tag = SERVICE_IMAGE_TAGS[repo]
    image = '{}:{}'.format(repo, tag)
    docker_kwargs = {
        'environment': {
            'ARCUS_API_IP': api_ip,
            'ARCUS_API_PORT': '1234',
            'OPENSTACK_VIP': openstack_ip,
            'ARCUS_USE_HTTPS': arcus_https,
            'GLANCE_HTTPS': str(glance_https).lower(),
            'VERSION': tag
        },
        'ports': {
            '80': ('0.0.0.0', '80'),
            '443': ('0.0.0.0', '443')
        },
        'restart_policy': {'Name': 'always'}
    }
    if arcus_https:
        docker_kwargs['volumes'] = {
            cert_path: {'bind': '/etc/nginx/haproxy.crt', 'mode': 'ro'},
            cert_key_path: {'bind': '/etc/nginx/haproxy.key', 'mode': 'ro'}}
    docker = Docker()
    docker.pull(repository=repo, tag=tag)
    success = docker.run(image, name=name, **docker_kwargs)
    return success
示例#4
0
def mgr_start(openstack_ip, sql_ip, sql_pass, rabbit_ip_list, rabbit_pass,
              kolla_dir, enable_ceph, ssh_key_path):
    """ Start the Arcus Mgr service """
    name = 'arcus_mgr'
    repo = 'breqwatr/arcus-mgr'
    tag = SERVICE_IMAGE_TAGS[repo]
    image = '{}:{}'.format(repo, tag)
    rabbit_ips_csv = ','.join(rabbit_ip_list)
    docker_kwargs = {
        'environment': {
            'OPENSTACK_VIP': openstack_ip,
            'SQL_USERNAME': '******',
            'SQL_PASSWORD': sql_pass,
            'SQL_IP': sql_ip,
            'DR_SQL_USERNAME': '******',
            'DR_SQL_PASSWORD': sql_pass,
            'DR_SQL_IP': sql_ip,
            'RABBIT_NODES_CSV': rabbit_ips_csv,
            'RABBIT_USERNAME': '******',
            'RABBIT_PASSWORD': rabbit_pass,
            'ENABLE_CEPH': str(enable_ceph).lower()
        },
        'volumes': {
            kolla_dir: {'bind': '/etc/kolla/', 'mode': 'rw'},
            ssh_key_path: {'bind': '/root/.ssh/id_rsa', 'mode': 'ro'}
        },
        'restart_policy': {'Name': 'always'},
        'network_mode': 'host'
    }
    docker = Docker()
    docker.pull(repository=repo, tag=tag)
    success = docker.run(image, name=name, **docker_kwargs)
    return success
示例#5
0
def start(tag=None):
    """ Start the NTP service """
    name = 'ntp'
    repo = 'breqwatr/ntp'
    tag = SERVICE_IMAGE_TAGS[repo]
    docker = Docker()
    docker.pull(repository=repo, tag=tag)
    image = '{}:{}'.format(repo, tag)
    docker.run(image, name=name, network_mode='host', privileged=True)
def sync_image(registry_url, image, tag=None):
    """ Pull images from upstream or import from media, push to registry """
    if tag is None:
        tag = KOLLA_IMAGE_TAGS[image]
    docker = Docker()
    docker.pull(image, tag)
    echo('> Applying new tag')
    docker.retag(image, tag, registry_url)
    echo('> Pushing {}:{} to {}'.format(image, tag, registry_url))
    docker.push(image, tag, registry_url)
示例#7
0
def start(interface_name, cloud_vip, cloud_fqdn, tag=None):
    """ Start the DNS container """
    name = 'dns'
    repo = 'breqwatr/dns'
    tag = SERVICE_IMAGE_TAGS[repo]
    docker = Docker()
    docker.pull(repository=repo, tag=tag)
    image = '{}:{}'.format(repo, tag)
    env = {
        'INTERFACE': interface_name,
        'CLOUD_VIP': cloud_vip,
        'CLOUD_FQDN': cloud_fqdn,
    }
    docker.run(image, name=name, network_mode='host', environment=env)
示例#8
0
def start(tag=None):
    """ Start the APT container """
    name = 'pip'
    repo = 'breqwatr/pip'
    tag = SERVICE_IMAGE_TAGS[repo]
    image = '{}:{}'.format(repo, tag)
    docker_kwargs = {
        'network_mode': 'host',
        'restart_policy': {
            'Name': 'always'
        }
    }
    docker = Docker()
    docker.pull(repository=repo, tag=tag)
    success = docker.run(image, name=name, **docker_kwargs)
    return success
def start(ip='0.0.0.0', port=5000):
    """ Start the registry container """
    name = 'registry'
    repo = 'registry'
    tag = SERVICE_IMAGE_TAGS[repo]
    http_addr = "{}:{}".format(ip, port)
    image = '{}:{}'.format(repo, tag)
    docker_kwargs = {
        'environment': {
            'REGISTRY_HTTP_ADDR': http_addr
        },
        'ports': {
            port: port
        }
    }
    docker = Docker()
    docker.pull(repository=repo, tag=tag)
    success = docker.run(image, name=name, **docker_kwargs)
    return success
示例#10
0
def start(tag=None, port=81):
    """ Start the APT container """
    name = 'apt'
    repo = 'breqwatr/apt'
    tag = SERVICE_IMAGE_TAGS[repo]
    image = '{}:{}'.format(repo, tag)
    restart_policy = {'Name': 'always'}
    env = {
        'GPG_PRIVATE_KEY_FILE': '/keys/breqwatr-private-key.asc',
        'GPG_PUBLIC_KEY_FILE': '/keys/breqwatr-private-key.asc',
    }
    ports = {'80': ('0.0.0.0', port)}
    docker = Docker()
    docker.pull(repository=repo, tag=tag)
    success = docker.run(image,
                         name=name,
                         environment=env,
                         restart_policy=restart_policy,
                         ports=ports)
    return success
示例#11
0
def start(interface, dhcp_start, dhcp_end, dns_ip='8.8.8.8'):
    """ Start the breqwatr-pxe container """
    name = 'pxe'
    repo = "breqwatr/pxe"
    tag = SERVICE_IMAGE_TAGS[repo]
    image = '{}:{}'.format(repo, tag)
    docker_kwargs = {
        'privileged': True,
        'network_mode': 'host',
        'environment': {
            'INTERFACE': interface,
            'DHCP_RANGE_START': dhcp_start,
            'DHCP_RANGE_END': dhcp_end,
            'DNS_IP': dns_ip
        },
        'sysctls': {
            'net.ipv4.ip_forward': 1
        }
    }
    docker = Docker()
    docker.pull(repository=repo, tag=tag)
    success = docker.run(image, name=name, **docker_kwargs)
    return success
示例#12
0
def export_image(repository, tag, pull, force):
    """ Export an image to directory """
    client = Docker()
    if pull:
        client.pull(repository=repository, tag=tag)
    client.export_image(repository, tag=tag, force=force)