Esempio n. 1
0
def copy_file(tpl_file, charm_dir, is_bundle=False, debug=False):
    c = Charm(charm_dir)

    if not c.is_charm():
        raise Exception('%s is not a charm' % charm_dir)

    shutil.copy(os.path.join(CHARM_TPL, tpl_file), charm_dir)
Esempio n. 2
0
def copy_file(tpl_file, charm_dir, is_bundle=False, debug=False):
    c = Charm(charm_dir)

    if not c.is_charm():
        raise Exception('%s is not a charm' % charm_dir)

    shutil.copy(os.path.join(CHARM_TPL, tpl_file), charm_dir)
Esempio n. 3
0
def readme(charm_dir, is_bundle=False, debug=False):
    c = Charm(charm_dir)

    if not c.is_charm():
        raise Exception('%s is not a charm' % charm_dir)

    shutil.copy(os.path.join(CHARM_TPL, 'README.ex'), charm_dir)
Esempio n. 4
0
def tests(charm_dir, is_bundle=False, debug=False, series='trusty'):
    c = Charm(charm_dir)

    if not c.is_charm():
        raise Exception('Not a Charm')

    mdata = c.metadata()

    interfaces = {}
    deploy = [mdata['name']]
    relations = []

    for rel_type in ['provides', 'requires']:
        if rel_type in mdata:
            interfaces[rel_type] = {}
            for rel, data in mdata[rel_type].iteritems():
                iface = data['interface']
                if iface and iface not in interfaces[rel_type]:
                    r = graph(iface, rel_type, series=series)
                    # If we dont find an interface, do nothing
                    if r is None:
                        continue
                    interfaces[rel_type][iface] = r
                    deploy.append(r.name)

                relations.append(['%s:%s' % (mdata['name'], rel), r.name])

    t = Template(file=os.path.join(TPL_DIR, 'tests', '99-autogen.tpl'),
                 searchList=[{
                     'deploy': deploy,
                     'relate': relations,
                     'series': series
                 }])

    if not os.path.exists(os.path.join(charm_dir, 'tests')):
        os.mkdir(os.path.join(charm_dir, 'tests'))

    with open(os.path.join(charm_dir, 'tests', '99-autogen'), 'w') as f:
        f.write(str(t))

    if not os.path.exists(os.path.join(charm_dir, 'tests', '00-setup')):
        with open(os.path.join(charm_dir, 'tests', '00-setup'), 'w') as f:
            f.write("""#!/bin/bash

sudo add-apt-repository ppa:juju/stable -y
sudo apt-get update
sudo apt-get install amulet python3-requests -y
""")

    os.chmod(os.path.join(charm_dir, 'tests', '99-autogen'), 0755)
    os.chmod(os.path.join(charm_dir, 'tests', '00-setup'), 0755)
Esempio n. 5
0
def tests(charm_dir, is_bundle=False, debug=False, series='trusty'):
    c = Charm(charm_dir)

    if not c.is_charm():
        raise Exception('Not a Charm')

    mdata = c.metadata()

    interfaces = {}
    deploy = [mdata['name']]
    relations = []

    for rel_type in ['provides', 'requires']:
        if rel_type in mdata:
            interfaces[rel_type] = {}
            for rel, data in mdata[rel_type].iteritems():
                iface = data['interface']
                if iface and iface not in interfaces[rel_type]:
                    r = graph(iface, rel_type, series=series)
                    # If we dont find an interface, do nothing
                    if r is None:
                        continue
                    interfaces[rel_type][iface] = r
                    deploy.append(r.name)

                relations.append(['%s:%s' % (mdata['name'], rel), r.name])

    t = Template(file=os.path.join(TPL_DIR, 'tests', '99-autogen.tpl'),
                 searchList=[{'deploy': deploy, 'relate': relations,
                              'series': series}])

    if not os.path.exists(os.path.join(charm_dir, 'tests')):
        os.mkdir(os.path.join(charm_dir, 'tests'))

    with open(os.path.join(charm_dir, 'tests', '99-autogen'), 'w') as f:
        f.write(str(t))

    if not os.path.exists(os.path.join(charm_dir, 'tests', '00-setup')):
        with open(os.path.join(charm_dir, 'tests', '00-setup'), 'w') as f:
            f.write("""#!/bin/bash

sudo add-apt-repository ppa:juju/stable -y
sudo apt-get update
sudo apt-get install amulet python3-requests -y
""")

    os.chmod(os.path.join(charm_dir, 'tests', '99-autogen'), 0755)
    os.chmod(os.path.join(charm_dir, 'tests', '00-setup'), 0755)
Esempio n. 6
0
def tests(charm_dir, is_bundle=False, debug=False):
    c = Charm(charm_dir)

    interfaces = {}
    deploy = []
    relations = []

    if not c.is_charm():
        raise Exception('Not a Charm')

    mdata = c.metadata()

    for rel_type in ['provides', 'requires']:
        if rel_type in mdata:
            interfaces[rel_type] = {}
            for rel, data in mdata[rel_type].iteritems():
                iface = data['interface']
                if iface and iface not in interfaces[rel_type]:
                    r = graph(iface, rel_type)
                    interfaces[rel_type][iface] = r
                    deploy.append(r.url)

                relations.append(['%s:%s' % (mdata['name'], rel), r.name])

    d = Template(file=ATPL['deploy'], searchList=[{'services': deploy}])
    s = Template(file=ATPL['relate'], searchList=[{'relations': relations}])

    t = Template(file=ATPL['body'], searchList=[{'deploy': d, 'relate': s}])

    if not os.path.exists(os.path.join(charm_dir, 'tests')):
        os.mkdir(os.path.join(charm_dir, 'tests'))

    with open(os.path.join(charm_dir, 'tests', '00-autogen'), 'w') as f:
        f.write(str(t))

    if not os.path.exists(os.path.join(charm_dir, 'tests', '00-setup')):
        with open(os.path.join(charm_dir, 'tests', '00-setup'), 'w') as f:
            f.write("""#!/bin/bash

add-apt-repository ppa:juju/stable
apt-get update
apt-get install amulet
""")

    os.chmod(os.path.join(charm_dir, 'tests', '00-autogen'), 0755)
    os.chmod(os.path.join(charm_dir, 'tests', '00-setup'), 0755)