当前位置: 首页>>代码示例>>Python>>正文


Python ModelMeta.remove_all方法代码示例

本文整理汇总了Python中solar.dblayer.model.ModelMeta.remove_all方法的典型用法代码示例。如果您正苦于以下问题:Python ModelMeta.remove_all方法的具体用法?Python ModelMeta.remove_all怎么用?Python ModelMeta.remove_all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在solar.dblayer.model.ModelMeta的用法示例。


在下文中一共展示了ModelMeta.remove_all方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: setup_resources

# 需要导入模块: from solar.dblayer.model import ModelMeta [as 别名]
# 或者: from solar.dblayer.model.ModelMeta import remove_all [as 别名]
def setup_resources():
    ModelMeta.remove_all()

    node2 = vr.create('node2', 'resources/ro_node/', {
        'ip': '10.0.0.4',
        'ssh_key': '/vagrant/.vagrant/machines/solar-dev2/virtualbox/private_key',
        'ssh_user': 'vagrant'
    })[0]

    solar_bootstrap2 = vr.create('solar_bootstrap2', 'resources/solar_bootstrap', {'master_ip': '10.0.0.2'})[0]

    signals.connect(node2, solar_bootstrap2)

    has_errors = False
    for r in locals().values():
        if not isinstance(r, resource.Resource):
            continue

        print 'Validating {}'.format(r.name)
        errors = validation.validate_resource(r)
        if errors:
            has_errors = True
            print 'ERROR: %s: %s' % (r.name, errors)

    if has_errors:
        sys.exit(1)
开发者ID:aglarendil,项目名称:solar,代码行数:28,代码来源:example-bootstrap.py

示例2: run

# 需要导入模块: from solar.dblayer.model import ModelMeta [as 别名]
# 或者: from solar.dblayer.model.ModelMeta import remove_all [as 别名]
def run():
    ModelMeta.remove_all()

    resources = vr.create('nodes', 'templates/nodes.yaml', {'count': 2})

    node1, node2 = [x for x in resources if x.name.startswith('node')]
    hosts1, hosts2 = [x for x in resources
                      if x.name.startswith('hosts_file')]

    node1.connect(hosts1, {
        'name': 'hosts:name',
        'ip': 'hosts:ip',
    })

    node2.connect(hosts1, {
        'name': 'hosts:name',
        'ip': 'hosts:ip',
    })

    node1.connect(hosts2, {
        'name': 'hosts:name',
        'ip': 'hosts:ip',
    })

    node2.connect(hosts2, {
        'name': 'hosts:name',
        'ip': 'hosts:ip',
    })
开发者ID:Mirantis,项目名称:solar,代码行数:30,代码来源:hosts.py

示例3: undeploy

# 需要导入模块: from solar.dblayer.model import ModelMeta [as 别名]
# 或者: from solar.dblayer.model.ModelMeta import remove_all [as 别名]
def undeploy():
    resources = resource.load_all()
    resources = {r.name: r for r in resources}

    for name in reversed(resources_to_run):
        try:
            actions.resource_action(resources[name], 'remove')
        except errors.SolarError as e:
            print 'WARNING: %s' % str(e)

    ModelMeta.remove_all()
开发者ID:aglarendil,项目名称:solar,代码行数:13,代码来源:example-bootstrap.py

示例4: undeploy

# 需要导入模块: from solar.dblayer.model import ModelMeta [as 别名]
# 或者: from solar.dblayer.model.ModelMeta import remove_all [as 别名]
def undeploy():
    ModelMeta.remove_all()

    resources = resource.load_all()
    resources = {r.name: r for r in resources}

    actions.resource_action(resources['openstack_rabbitmq_user'], 'remove')
    actions.resource_action(resources['openstack_vhost'], 'remove')
    actions.resource_action(resources['rabbitmq_service1'], 'remove')

    ModelMeta.remove_all()
开发者ID:aglarendil,项目名称:solar,代码行数:13,代码来源:example-compiled-resources.py

示例5: setup_riak

# 需要导入模块: from solar.dblayer.model import ModelMeta [as 别名]
# 或者: from solar.dblayer.model.ModelMeta import remove_all [as 别名]
def setup_riak():

    ModelMeta.remove_all()
    nodes = template.nodes_from('templates/riak_nodes.yaml')

    riak_services = nodes.on_each(
        'resources/riak_node',
        args={
            'riak_self_name': 'riak{num}',
            'riak_hostname': 'riak_server{num}.solar',
            'riak_name': 'riak{num}@riak_server{num}.solar',
        }
    )

    slave_riak_services = riak_services.tail()

    riak_services.take(0).connect_list(
        slave_riak_services,
        mapping={
            'riak_name': 'join_to',
        }
    )

    hosts_files = nodes.on_each('resources/hosts_file')

    riak_services.connect_list_to_each(
        hosts_files,
        mapping={
            'ip': 'hosts:ip',
            'riak_hostname': 'hosts:name',
        },
        events=False
    )

    errors = resource.validate_resources()
    for r, error in errors:
        click.echo('ERROR: %s: %s' % (r.name, error))

    if errors:
        click.echo("ERRORS")
        sys.exit(1)

    hosts_files.add_deps('run/success', riak_services, 'run')
    slave_riak_services.add_reacts('run/success', slave_riak_services, 'join')
    slave_riak_services.add_reacts('leave/success', slave_riak_services, 'join')
    slave_riak_services.add_react('run/success', riak_services.take(0), 'commit')
开发者ID:aglarendil,项目名称:solar,代码行数:48,代码来源:riaks-template.py

示例6: run

# 需要导入模块: from solar.dblayer.model import ModelMeta [as 别名]
# 或者: from solar.dblayer.model.ModelMeta import remove_all [as 别名]
def run():
    ModelMeta.remove_all()

    node = cr.create('node', 'resources/ro_node', {'name': 'first' + str(time.time()),
                                                       'ip': '10.0.0.3',
                                                       'node_id': 'node1',
                                                   })[0]

    transports = cr.create('transports_node1', 'resources/transports')[0]
    transports_for_solar_agent = cr.create('transports_for_solar_agent', 'resources/transports')[0]

    ssh_transport  = cr.create('ssh_transport', 'resources/transport_ssh',
                               {'ssh_key': '/vagrant/.vagrant/machines/solar-dev1/virtualbox/private_key',
                                'ssh_user': 'vagrant'})[0]

    solar_agent_transport  = cr.create('solar_agent_transport', 'resources/transport_solar_agent',
                                  {'solar_agent_user': 'vagrant',
                                   'solar_agent_password': 'password'})[0]

    transports_for_solar_agent.connect(solar_agent_transport, {})
    ssh_transport.connect(transports_for_solar_agent,{'ssh_key': 'transports:key',
                                                 'ssh_user': 'transports:user',
                                                 'ssh_port': 'transports:port',
                                                 'name': 'transports:name'})
    # set transports_id
    transports.connect(node, {})

    # it uses reverse mappings
    ssh_transport.connect(transports, {'ssh_key': 'transports:key',
                                        'ssh_user': 'transports:user',
                                        'ssh_port': 'transports:port',
                                        'name': 'transports:name'})
    solar_agent_transport.connect(transports, {'solar_agent_user': 'transports:user',
                                           'solar_agent_port': 'transports:port',
                                           'solar_agent_password': 'transports:password',
                                           'name': 'transports:name'})


    hosts = cr.create('hosts_file', 'resources/hosts_file', {})[0]
    node.connect(hosts, {
        'ip': 'hosts:ip',
        'name': 'hosts:name'
    })
开发者ID:pigmej,项目名称:solar-resources,代码行数:45,代码来源:example.py

示例7: deploy

# 需要导入模块: from solar.dblayer.model import ModelMeta [as 别名]
# 或者: from solar.dblayer.model.ModelMeta import remove_all [as 别名]
def deploy():
    ModelMeta.remove_all()
    resources = cr.create('nodes', 'templates/nodes', {'count': 2})
    first_node, second_node = [x for x in resources if x.name.startswith('node')]
    first_transp = next(x for x in resources if x.name.startswith('transport'))

    library = cr.create('library1', 'resources/fuel_library', {})[0]
    first_node.connect(library)

    keys = cr.create('ceph_key', 'resources/ceph_keys', {})[0]
    first_node.connect(keys)

    remote_file = cr.create('ceph_key2', 'resources/remote_file',
      {'dest': '/var/lib/astute/'})[0]
    second_node.connect(remote_file)
    keys.connect(remote_file, {'ip': 'remote_ip', 'path': 'remote_path'})
    first_transp.connect(remote_file, {'transports': 'remote'})


    ceph_mon = cr.create('ceph_mon1', 'resources/ceph_mon',
        {'storage': STORAGE,
         'keystone': KEYSTONE,
         'network_scheme': NETWORK_SCHEMA,
         'ceph_monitor_nodes': NETWORK_METADATA,
         'ceph_primary_monitor_node': NETWORK_METADATA,
         'role': 'controller',
         })[0]

    managed_apt = cr.create(
      'managed_apt1', 'templates/mos_repos',
      {'node': first_node.name, 'index': 0})[-1]

    keys.connect(ceph_mon, {})
    first_node.connect(ceph_mon,
        {'ip': ['ip', 'public_vip', 'management_vip']})
    library.connect(ceph_mon, {'puppet_modules': 'puppet_modules'})
    managed_apt.connect(ceph_mon, {})
开发者ID:pigmej,项目名称:solar-resources,代码行数:39,代码来源:ceph.py

示例8: deploy

# 需要导入模块: from solar.dblayer.model import ModelMeta [as 别名]
# 或者: from solar.dblayer.model.ModelMeta import remove_all [as 别名]
def deploy():
    ModelMeta.remove_all()
    signals.Connections.clear()

    node1 = resources_compiled.RoNodeResource('node1', None, {})
    node1.ip = '10.0.0.3'
    node1.ssh_key = '/vagrant/.vagrant/machines/solar-dev1/virtualbox/private_key'
    node1.ssh_user = 'vagrant'

    rabbitmq_service1 = resources_compiled.RabbitmqServiceResource('rabbitmq_service1', None, {'management_port': 15672, 'port': 5672, 'container_name': 'rabbitmq_service1', 'image': 'rabbitmq:3-management'})
    openstack_vhost = resource.create('openstack_vhost', 'resources/rabbitmq_vhost/', {'vhost_name': 'openstack'})[0]
    openstack_rabbitmq_user = resource.create('openstack_rabbitmq_user', 'resources/rabbitmq_user/', {'user_name': 'openstack', 'password': 'openstack_password'})[0]

    ####
    # connections
    ####

    # rabbitmq
    signals.connect(node1, rabbitmq_service1)
    signals.connect(rabbitmq_service1, openstack_vhost)
    signals.connect(rabbitmq_service1, openstack_rabbitmq_user)
    signals.connect(openstack_vhost, openstack_rabbitmq_user, {'vhost_name': 'vhost_name'})


    errors = vr.validate_resources()
    if errors:
        for r, error in errors:
            print 'ERROR: %s: %s' % (r.name, error)
        sys.exit(1)


    # run
    actions.resource_action(rabbitmq_service1, 'run')
    actions.resource_action(openstack_vhost, 'run')
    actions.resource_action(openstack_rabbitmq_user, 'run')
    time.sleep(10)
开发者ID:aglarendil,项目名称:solar,代码行数:38,代码来源:example-compiled-resources.py

示例9: setup_riak

# 需要导入模块: from solar.dblayer.model import ModelMeta [as 别名]
# 或者: from solar.dblayer.model.ModelMeta import remove_all [as 别名]
def setup_riak():

    ModelMeta.remove_all()
    resources = vr.create('nodes', 'templates/nodes.yaml', {'count': 3})
    nodes = [x for x in resources if x.name.startswith('node')]
    hosts_services = [x for x in resources if x.name.startswith('hosts_file')]
    node1, node2, node3 = nodes
    hosts_services = [x for x in resources if x.name.startswith('hosts_file')]

    riak_services = []
    ips = '10.0.0.%d'
    for i in xrange(3):
        num = i + 1
        r = vr.create('riak_service%d' % num,
                      'resources/riak_node',
                      {'riak_self_name': 'riak%d' % num,
                       'storage_backend': 'leveldb',
                       'riak_hostname': 'riak_server%d.solar' % num})[0]
        r.connect(r, {'riak_self_name': 'riak_name',
                      'riak_hostname': 'riak_name'})
        riak_services.append(r)

    for i, riak in enumerate(riak_services):
        nodes[i].connect(riak)

    for i, riak in enumerate(riak_services[1:]):
        riak_services[0].connect(riak, {'riak_name': 'join_to'})

    for riak in riak_services:
        for hosts_file in hosts_services:
            riak.connect_with_events(hosts_file,
                {'riak_hostname': 'hosts:name',
                 'ip': 'hosts:ip'})

    Resource.save_all_lazy()
    errors = resource.validate_resources()
    for r, error in errors:
        click.echo('ERROR: %s: %s' % (r.name, error))
    has_errors = False

    if errors:
        click.echo("ERRORS")
        sys.exit(1)

    events = [
        Dep('hosts_file1', 'run', 'success', 'riak_service1', 'run'),
        Dep('hosts_file2', 'run', 'success', 'riak_service2', 'run'),
        Dep('hosts_file3', 'run', 'success', 'riak_service3', 'run'),

        React('riak_service2', 'run', 'success', 'riak_service2', 'join'),
        React('riak_service3', 'run', 'success', 'riak_service3', 'join'),

        # Dep('riak_service1', 'run', 'success', 'riak_service2', 'join'),
        # Dep('riak_service1', 'run', 'success', 'riak_service3', 'join'),

        # React('riak_service2', 'join', 'error', 'riak_service2', 'leave'),
        # React('riak_service3', 'join', 'error', 'riak_service3', 'leave'),

        React('riak_service2', 'leave', 'success', 'riak_service2', 'join'),
        React('riak_service3', 'leave', 'success', 'riak_service3', 'join'),

        # React('riak_service2', 'leave', 'success', 'riak_service1', 'commit_leave'),
        # React('riak_service3', 'leave', 'success', 'riak_service1', 'commit_leave'),

        # Dep('riak_service1', 'commit_leave', 'success', 'riak_service2', 'join'),
        # Dep('riak_service1', 'commit_leave', 'success', 'riak_service3', 'join'),

        React('riak_service3', 'join', 'success', 'riak_service1', 'commit'),
        React('riak_service2', 'join', 'success', 'riak_service1', 'commit')
    ]

    for event in events:
        add_event(event)

    click.echo('Use solar changes process & orch')
    sys.exit(0)
开发者ID:aglarendil,项目名称:solar,代码行数:78,代码来源:riaks.py

示例10: run

# 需要导入模块: from solar.dblayer.model import ModelMeta [as 别名]
# 或者: from solar.dblayer.model.ModelMeta import remove_all [as 别名]
def run():
    ModelMeta.remove_all()

    node = vr.create('node', 'resources/ro_node', {'name': 'first' + str(time.time()),
                                                   'ip': '10.0.0.3',
                                                   'node_id': 'node1',
                                                   })[0]

    transports = vr.create('transports_node1', 'resources/transports')[0]

    ssh_transport = vr.create('ssh_transport', 'resources/transport_ssh',
                              {'ssh_key': '/vagrant/.vagrant/machines/solar-dev1/virtualbox/private_key',
                               'ssh_user': 'vagrant'})[0]

    transports.connect(node, {})

    # it uses reverse mappings
    ssh_transport.connect(transports, {'ssh_key': 'transports:key',
                                       'ssh_user': 'transports:user',
                                       'ssh_port': 'transports:port',
                                       'name': 'transports:name'})

    hosts = vr.create('hosts_file', 'resources/hosts_file', {})[0]

    # let's add torrent transport for hosts file deployment (useless in real life)

    torrent_transport = vr.create('torrent_transport',
                                  'resources/transport_torrent',
                                  {'trackers': ['udp://open.demonii.com:1337',
                                                'udp://tracker.openbittorrent.com:80']})[0]
    # you could use any trackers as you want

    transports_for_torrent = vr.create(
        'transports_for_torrent', 'resources/transports')[0]

    transports_for_torrent.connect(torrent_transport, {})

    ssh_transport.connect_with_events(transports_for_torrent, {'ssh_key': 'transports:key',
                                                               'ssh_user': 'transports:user',
                                                               'ssh_port': 'transports:port',
                                                               'name': 'transports:name'},
                                      events={})

    transports_for_hosts = vr.create(
        'transports_for_hosts', 'resources/transports')[0]

    torrent_transport.connect(transports_for_hosts, {'trackers': 'transports:trackers',
                                                     'name': 'transports:name'})

    ssh_transport.connect(transports_for_hosts, {'ssh_key': 'transports:key',
                                                 'ssh_user': 'transports:user',
                                                 'ssh_port': 'transports:port',
                                                 'name': 'transports:name'})

    transports_for_hosts.connect(hosts)
    transports_for_hosts.connect_with_events(node, events={})

    node.connect(hosts, {
        'ip': 'hosts:ip',
        'name': 'hosts:name'
    })
开发者ID:aglarendil,项目名称:solar,代码行数:63,代码来源:example.py

示例11: clear

# 需要导入模块: from solar.dblayer.model import ModelMeta [as 别名]
# 或者: from solar.dblayer.model.ModelMeta import remove_all [as 别名]
def clear():
    ModelMeta.remove_all()
开发者ID:pigmej,项目名称:solar-resources,代码行数:4,代码来源:openstack.py

示例12: create_all

# 需要导入模块: from solar.dblayer.model import ModelMeta [as 别名]
# 或者: from solar.dblayer.model.ModelMeta import remove_all [as 别名]
def create_all():
    ModelMeta.remove_all()
    r = prepare_nodes(2)
    r.update(create_controller('node1'))
    r.update(create_compute('node2'))
    print '\n'.join(r.keys())
开发者ID:pigmej,项目名称:solar-resources,代码行数:8,代码来源:openstack.py

示例13: clear_all

# 需要导入模块: from solar.dblayer.model import ModelMeta [as 别名]
# 或者: from solar.dblayer.model.ModelMeta import remove_all [as 别名]
def clear_all():
    from solar.dblayer.model import ModelMeta
    click.echo('Clearing all resources and connections')
    ModelMeta.remove_all()
开发者ID:pigmej,项目名称:solar,代码行数:6,代码来源:resource.py

示例14: deploy

# 需要导入模块: from solar.dblayer.model import ModelMeta [as 别名]
# 或者: from solar.dblayer.model.ModelMeta import remove_all [as 别名]
def deploy():
    ModelMeta.remove_all()

    node1 = vr.create('nodes', 'templates/nodes.yaml', {})[0]
    seed = vr.create('nodes', 'templates/seed_node.yaml', {})[0]

    ssh_key = vr.create('ssh_key1', 'resources/ssh_key', {
        'keys_dir': '/vagrant/.ssh',
        'private_key': '/vagrant/.ssh/id_rsa',
        'public_key': '/vagrant/.ssh/id_rsa.pub',
        'passphrase': '',
    })[0]
    signals.connect(seed, ssh_key)

    cnets1 = vr.create('cnets1', 'resources/container_networks', {
        'networks':
            {'mgmt': {
                'bridge': 'br-int53',
                'bridge_address': '172.18.11.254/24'
            }}
        })[0]
    cnets2 = vr.create('cnets2', 'resources/container_networks', {
        'networks':
            {'mgmt': {
                'bridge': 'br-int53',
                'bridge_address': '172.18.11.253/24'
            }}
        })[0]
    signals.connect(seed, cnets1)
    signals.connect(node1, cnets2)

    vxlan_mesh1 = vr.create('vxlan_mesh1', 'resources/vxlan_mesh', {
        'id': 53,
        'parent': 'eth1',
        'master': 'br-int53'
    })[0]
    vxlan_mesh2 = vr.create('vxlan_mesh2', 'resources/vxlan_mesh', {
        'id': 53,
        'parent': 'eth1',
        'master': 'br-int53'
    })[0]
    # seed node should be connected anyway, because we need to be able to ssh
    # into containers from any node
    signals.connect(seed, vxlan_mesh1)
    signals.connect(node1, vxlan_mesh2)

    lxc_infra1 = vr.create('lxc_infra1', 'resources/lxc_host', {})[0]
    signals.connect(node1, lxc_infra1)

    lxc_hosts = range(28, 35)
    hosts_map = {}
    for idx in lxc_hosts:

        lxc_host_idx = vr.create(
            'lxc_host{}'.format(idx),
            'resources/lxc_container', lxc_template(idx))[0]
        hosts_map[idx] = lxc_host_idx

        signals.connect(node1, lxc_host_idx, {
            'ip': ['ansible_ssh_host', 'physical_host'],
            })
        # this is a required to introduce depends on relationship between lxc infre
        # and lxc container
        signals.connect(lxc_infra1, lxc_host_idx, {'provides': 'requires'})
        signals.connect(cnets2, lxc_host_idx)
        signals.connect(ssh_key, lxc_host_idx, {
            'public_key': 'pub_key',
            'private_key': 'user_key'})

    # 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': 'openstack_password'
    })[0]

    signals.connect(hosts_map[28], rabbitmq_service1, {
        'mgmt_ip': 'ip',
        'user_key': 'ssh_key',
        'user': 'ssh_user'})
    signals.connect(rabbitmq_service1, openstack_vhost)
    signals.connect(rabbitmq_service1, openstack_rabbitmq_user)
    signals.connect(openstack_vhost, openstack_rabbitmq_user, {
        'vhost_name',
    })

    print change.send_to_orchestration()
开发者ID:aglarendil,项目名称:solar,代码行数:96,代码来源:example-lxc.py


注:本文中的solar.dblayer.model.ModelMeta.remove_all方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。