Exemple #1
0
def start(__cloudify_id, db_name='pickle', db_data={}, **kwargs):
    db_file = get_db_file_location(db_name)
    db = pickledb.load(db_file, False)
    for key, value in db_data.iteritems():
        db.set(key, value)
    db.dump()
    send_event(__cloudify_id, "10.0.0.5", "pickle db status", "state", "running")
Exemple #2
0
def start(__cloudify_id, db_name='pickle', db_data={}, **kwargs):
    db_file = get_db_file_location(db_name)
    db = pickledb.load(db_file, False)
    for key, value in db_data.iteritems():
        db.set(key, value)
    db.dump()
    send_event(__cloudify_id, "10.0.0.5", "pickle db status", "state",
               "running")
def start(__cloudify_id, port=8080, **kwargs):
    os.system("nohup python -m SimpleHTTPServer {0} &".format(port))

    # verify http server is up
    for attempt in range(10):
        try:
            response = urllib2.urlopen("http://localhost:{0}".format(port))
            response.read()
            break
        except BaseException:
            time.sleep(1)
    else:
        raise RuntimeError("failed to start python http server")
    send_event(__cloudify_id, "10.0.0.5", "webserver status", "state", "running")
def start(__cloudify_id, port=8080, **kwargs):
    os.system("nohup python -m SimpleHTTPServer {0} &".format(port))

    # verify http server is up
    for attempt in range(10):
        try:
            response = urllib2.urlopen("http://localhost:{0}".format(port))
            response.read()
            break
        except BaseException:
            time.sleep(1)
    else:
        raise RuntimeError("failed to start python http server")
    send_event(__cloudify_id, "10.0.0.5", "webserver status", "state",
               "running")
def provision(__cloudify_id, nova_config, security_group, **kwargs):
    nova_client = _init_client(nova_config)
    if _get_sg_by_name(nova_client, security_group['name']):
        raise RuntimeError("Can not provision sg with name '{0}' because sg with such name already exists"
                           .format(security_group['name']))

    sg = nova_client.security_groups.create(security_group['name'], security_group.get('description', '(no description)'))
    for rule in security_group['rules']:
        nova_client.security_group_rules.create(
            sg.id,
            ip_protocol="tcp",
            from_port=rule['port'],
            to_port=rule['port'],
            cidr=rule.get('cidr'),
            group_id=rule.get('group_id')
        )
    send_event(__cloudify_id, "cosmo_manager", "sg status", "state", "running") # XXX
def provision(__cloudify_id, security_group, **kwargs):
    neutron_client = _init_client()
    if _get_security_group_by_name(neutron_client, security_group['name']):
        raise RuntimeError("Can not provision security group with name '{0}' because security group with such name already exists"
                           .format(security_group['name']))

    sg = neutron_client.create_security_group({
        'security_group': {
            'name': security_group['name'],
            'description': security_group.get('description', None),
        }
    })['security_group']

    rules_to_apply = security_group['rules']
    egress_rules_to_apply = _egress_rules(rules_to_apply)
    if egress_rules_to_apply and security_group.get('disable_egress'):
        raise RuntimeError("Security group {0} can not have both disable_egress and an egress rule".format(security_group['name']))

    if egress_rules_to_apply or security_group.get('disable_egress'):
        for er in _egress_rules(_rules_for_sg_id(neutron_client, sg['id'])):
            neutron_client.delete_security_group_rule(er['id'])

    for rule in rules_to_apply:
        if ('remote_group_name' in rule) and rule['remote_group_name']:
            remote_group_id = _get_security_group_by_name(neutron_client, rule['remote_group_name'])['id']
        else:
            remote_group_id = None
        neutron_client.create_security_group_rule({
            'security_group_rule': {
                'security_group_id': sg['id'],
                'direction': rule.get('direction', DEFAULT_RULE_DIRECTION),
                'protocol': rule.get('protocol', DEFAULT_RULE_PROTOCOL),
                'port_range_min': rule.get('port', rule.get('port_range_min', DEFAULT_RULE_PORT_MIN)),
                'port_range_max': rule.get('port', rule.get('port_range_max', DEFAULT_RULE_PORT_MAX)),
                'remote_ip_prefix': rule.get('remote_ip_prefix'),
                'remote_group_id': rule.get('remote_group_id', remote_group_id),
            }
        })

    send_event(__cloudify_id, "sg-" + security_group['name'], "security group status", "state", "running")
def start(__cloudify_id, **kwargs):
    send_event(__cloudify_id, "10.0.0.5", "flask status", "state", "running")
Exemple #8
0
def start(__cloudify_id, **kwargs):
    send_event(__cloudify_id, "10.0.0.5", "flask status", "state", "running")
Exemple #9
0
def start(__relationship_cloudify_id, **kwargs):
    send_event(__relationship_cloudify_id, "10.0.0.5", "flask app status", "state", "running")
def start(__cloudify_id, policy_service, chef_start_runlist=None, chef_attributes=None, **kwargs):
    run_chef(chef_start_runlist, chef_attributes)
    host = get_cosmo_properties()['ip']
    send_event(__cloudify_id, host, policy_service, "state", "running")
Exemple #11
0
def start(__relationship_cloudify_id, **kwargs):
    send_event(__relationship_cloudify_id, "10.0.0.5", "flask app status", "state", "running")
 def test_send_event(self):
     send_event("test", "test", "test", "test", "test")