<commit_before>#!/usr/bin/env python

import click
import sys
import time

from solar.core import actions
from solar.core import resource
from solar.core import signals
from solar.core import validation
from solar.core.resource import virtual_resource as vr
from solar import errors
from solar import events as evapi

from solar.interfaces.db import get_db


PROFILE = False
#PROFILE = True


if PROFILE:
    import StringIO
    import cProfile
    import pstats

    pr = cProfile.Profile()


GIT_PUPPET_LIBS_URL = 'https://github.com/CGenie/puppet-libs-resource'


# TODO
# Resource for repository OR puppet apt-module in run.pp
# add-apt-repository cloud-archive:juno
# To discuss: install stuff in Docker container

# NOTE
# No copy of manifests, pull from upstream (implemented in the puppet handler)
# Official puppet manifests, not fuel-library


db = get_db()


@click.group()
def main():
    pass


def setup_resources():
    db.clear()

    if PROFILE:
        pr.enable()

    resources = vr.create('nodes', 'templates/nodes_with_transports.yaml', {"count": 2})
    nodes = [x for x in resources if x.name.startswith('node')]
    node1, node2 = nodes
    resources = vr.create('nodes_network', 'templates/nodes_network.yml', {"count": 2})
    nodes_sdn = [x for x in resources if x.name.startswith('node')]
    node1_sdn, node2_sdn = nodes_sdn


    # NETWORKING
    # TODO(bogdando) node's IPs should be populated as br-mgmt IPs, but now are hardcoded in templates
    signals.connect(node1, node1_sdn)
    signals.connect(node1, node2_sdn)

    # MARIADB
    mariadb_service1 = vr.create('mariadb_service1', 'resources/mariadb_service', {
        'image': 'mariadb',
        'port': 3306
    })[0]

    signals.connect(node1, mariadb_service1)

    # RABBIT
    rabbitmq_service1 = vr.create('rabbitmq_service1', 'resources/rabbitmq_service/', {
        'management_port': 15672,
        'port': 5672,
    })[0]
    openstack_vhost = vr.create('openstack_vhost', 'resources/rabbitmq_vhost/', {
        'vhost_name': 'openstack'
    })[0]

    openstack_rabbitmq_user = vr.create('openstack_rabbitmq_user', 'resources/rabbitmq_user/', {
        'user_name': 'openstack',
        'password': '<PASSWORD>'
    })[0]

    signals.connect(node1, rabbitmq_service1)
    signals.connect(rabbitmq_service1, openstack_vhost)
    signals.connect(rabbitmq_service1, openstack_rabbitmq_user)<commit_msg>Fix node2 connection for sdn resource<commit_after>#!/usr/bin/env python

import click
import sys
import time

from solar.core import actions
from solar.core import resource
from solar.core import signals
from solar.core import validation
from solar.core.resource import virtual_resource as vr
from solar import errors
from solar import events as evapi

from solar.interfaces.db import get_db


PROFILE = False
#PROFILE = True


if PROFILE:
    import StringIO
    import cProfile
    import pstats

    pr = cProfile.Profile()


GIT_PUPPET_LIBS_URL = 'https://github.com/CGenie/puppet-libs-resource'


# TODO
# Resource for repository OR puppet apt-module in run.pp
# add-apt-repository cloud-archive:juno
# To discuss: install stuff in Docker container

# NOTE
# No copy of manifests, pull from upstream (implemented in the puppet handler)
# Official puppet manifests, not fuel-library


db = get_db()


@click.group()
def main():
    pass


def setup_resources():
    db.clear()

    if PROFILE:
        pr.enable()

    resources = vr.create('nodes', 'templates/nodes_with_transports.yaml', {"count": 2})
    nodes = [x for x in resources if x.name.startswith('node')]
    node1, node2 = nodes
    resources = vr.create('nodes_network', 'templates/nodes_network.yml', {"count": 2})
    nodes_sdn = [x for x in resources if x.name.startswith('node')]
    node1_sdn, node2_sdn = nodes_sdn


    # NETWORKING
    # TODO(bogdando) node's IPs should be populated as br-mgmt IPs, but now are hardcoded in templates
    signals.connect(node1, node1_sdn)
    signals.connect(node2, node2_sdn)

    # MARIADB
    mariadb_service1 = vr.create('mariadb_service1', 'resources/mariadb_service', {
        'image': 'mariadb',
        'port': 3306
    })[0]

    signals.connect(node1, mariadb_service1)

    # RABBIT
    rabbitmq_service1 = vr.create('rabbitmq_service1', 'resources/rabbitmq_service/', {
        'management_port': 15672,
        'port': 5672,
    })[0]
    openstack_vhost = vr.create('openstack_vhost', 'resources/rabbitmq_vhost/', {
        'vhost_name': 'openstack'
    })[0]

    openstack_rabbitmq_user = vr.create('openstack_rabbitmq_user', 'resources/rabbitmq_user/', {
        'user_name': 'openstack',
        'password': '<PASSWORD>'
    })[0]

    signals.connect(node1, rabbitmq_service1)
    signals.connect(rabbitmq_service1, openstack_vhost)
    signals.connect(rabbitmq_service1, openstack_rabbitmq_user)
{'fraction_non_alphanumeric': 0.10802980132450331, 'fraction_numerical': 0.015521523178807946, 'mean_word_length': 3.794642857142857, 'pattern_counts': {'":': 4, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1858850', 'n_tokens_mistral': 1676, 'n_tokens_neox': 1596, 'n_words': 404}