• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python virtual_resource.create函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中solar.core.resource.virtual_resource.create函数的典型用法代码示例。如果您正苦于以下问题:Python create函数的具体用法?Python create怎么用?Python create使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: setup_resources

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,代码行数:26,代码来源:example-bootstrap.py


示例2: run

def run():
    ModelMeta.remove_all()

    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

    hosts1 = vr.create('hosts_file1', 'resources/hosts_file', {})[0]
    hosts2 = vr.create('hosts_file2', 'resources/hosts_file', {})[0]
    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:aglarendil,项目名称:solar,代码行数:28,代码来源:hosts.py


示例3: setup_base

def setup_base(node, librarian):
    # MARIADB
    mariadb_service = vr.create("mariadb_service1", "resources/mariadb_service", {"image": "mariadb", "port": 3306})[0]

    node.connect(mariadb_service)

    # RABBIT
    rabbitmq_service = 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]

    node.connect(rabbitmq_service)
    rabbitmq_service.connect_with_events(librarian, {"module": "modules"}, {})
    evapi.add_dep(librarian.name, rabbitmq_service.name, actions=("run", "update"))
    rabbitmq_service.connect(openstack_vhost)
    rabbitmq_service.connect(openstack_rabbitmq_user)
    openstack_vhost.connect(openstack_rabbitmq_user, {"vhost_name"})
    return {
        "mariadb_service": mariadb_service,
        "rabbitmq_service1": rabbitmq_service,
        "openstack_vhost": openstack_vhost,
        "openstack_rabbitmq_user": openstack_rabbitmq_user,
    }
开发者ID:prmtl,项目名称:solar,代码行数:30,代码来源:openstack.py


示例4: setup_neutron_agent

def setup_neutron_agent(node, neutron_server_puppet):
    # NEUTRON ML2 PLUGIN & ML2-OVS AGENT WITH GRE
    neutron_agents_ml2 = vr.create('neutron_agents_ml2', 'resources/neutron_agents_ml2_ovs_puppet', {
        # TODO(bogdando) these should come from the node network resource
        'enable_tunneling': True,
        'tunnel_types': ['gre'],
        'local_ip': '10.1.0.13' # should be the IP addr of the br-mesh int.
    })[0]
    node.connect(neutron_agents_ml2)
    evapi.add_dep(neutron_server_puppet.name, neutron_agents_ml2.name, actions=('run',))

    # NEUTRON DHCP, L3, metadata agents
    neutron_agents_dhcp = vr.create('neutron_agents_dhcp', 'resources/neutron_agents_dhcp_puppet', {})[0]
    node.connect(neutron_agents_dhcp)
    evapi.add_dep(neutron_server_puppet.name, neutron_agents_dhcp.name, actions=('run',))

    neutron_agents_l3 = vr.create('neutron_agents_l3', 'resources/neutron_agents_l3_puppet', {
        # TODO(bogdando) these should come from the node network resource
        'metadata_port': 8775,
        'external_network_bridge': 'br-floating',
    })[0]
    node.connect(neutron_agents_l3)
    evapi.add_dep(neutron_server_puppet.name, neutron_agents_l3.name, actions=('run',))

    neutron_agents_metadata = vr.create('neutron_agents_metadata', 'resources/neutron_agents_metadata_puppet', {
        'sh2ared_secret': 'secret',
    })[0]
    node.connect(neutron_agents_metadata)
    neutron_server_puppet.connect(neutron_agents_metadata, {
        'auth_host', 'auth_port', 'auth_password',
        'auth_tenant', 'auth_user',
    })
    return {'neutron_agents_ml2': neutron_agents_ml2,
            'neutron_agents_dhcp': neutron_agents_dhcp,
            'neutron_agents_metadata': neutron_agents_metadata}
开发者ID:aglarendil,项目名称:solar,代码行数:35,代码来源:openstack.py


示例5: deploy

def deploy():
    db.clear()
    resources = vr.create('nodes', 'templates/nodes.yaml', {'count': 2})
    first_node, second_node = [x for x in resources if x.name.startswith('solar-dev')]

    library2 = vr.create('library2', 'resources/fuel_library',
        {'temp_directory': '/tmp/solar',
       'puppet_modules': '/etc/fuel/modules',
       'git':{'branch': 'master', 'repository': 'https://github.com/stackforge/fuel-library'},
       'librarian_puppet_simple': 'true'})[0]
    
    ceph_compute = vr.create('ceph_compute1', 'resources/ceph_compute',
        {'storage': STORAGE,
         'keystone': KEYSTONE,
         'network_scheme': NETWORK_SCHEMA,
         'ceph_monitor_nodes': NETWORK_METADATA,
         'ceph_primary_monitor_node': NETWORK_METADATA,
         'role': 'compute',
         })[0]

    second_node.connect(ceph_compute, {}) 

    library2.connect(ceph_compute, {'puppet_modules': 'puppet_modules'})

    evapi.add_dep(second_node.name, ceph_compute.name, actions=('run',))
开发者ID:cvieri,项目名称:ceph_compute,代码行数:25,代码来源:ceph.py


示例6: prepare_nodes

def prepare_nodes(nodes_count):
    resources = vr.create('nodes', 'templates/nodes_with_transports.yaml', {"count": nodes_count})
    nodes = [x for x in resources if x.name.startswith('node')]
    resources = vr.create('nodes_network', 'templates/nodes_network.yaml', {"count": nodes_count})
    nodes_sdn = [x for x in resources if x.name.startswith('node')]
    r = {}

    for node, node_sdn in zip(nodes, nodes_sdn):
        r[node.name] = node
        r[node_sdn.name] = node_sdn

        # LIBRARIAN
        librarian = vr.create('librarian_{}'.format(node.name), 'resources/librarian', {})[0]
        r[librarian.name] = librarian

        node.connect(librarian, {})

        # NETWORKING
        # TODO(bogdando) node's IPs should be populated as br-mgmt IPs, but now are hardcoded in templates
        signals.connect(node, node_sdn)
        node_sdn.connect_with_events(librarian, {'module': 'modules'}, {})
        evapi.add_dep(librarian.name, node_sdn.name, actions=('run', 'update'))

        signals.connect(node, node_sdn)
        node_sdn.connect_with_events(librarian, {'module': 'modules'}, {})
        evapi.add_dep(librarian.name, node_sdn.name, actions=('run', 'update'))

    return r
开发者ID:aglarendil,项目名称:solar,代码行数:28,代码来源:openstack.py


示例7: run

def run():
    db.clear()

    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

    hosts1 = vr.create('hosts_file1', 'resources/hosts_file', {})[0]
    hosts2 = vr.create('hosts_file2', 'resources/hosts_file', {})[0]
    signals.connect(node1, hosts1, {
        'name': 'hosts:name',
        'ip': 'hosts:ip',
    })

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

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

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


示例8: setup_base

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

    node.connect(mariadb_service)

    # RABBIT
    rabbitmq_service = 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]

    node.connect(rabbitmq_service)
    rabbitmq_service.connect_with_events(librarian, {'module': 'modules'}, {})
    evapi.add_dep(librarian.name, rabbitmq_service.name, actions=('run', 'update'))
    rabbitmq_service.connect(openstack_vhost)
    rabbitmq_service.connect(openstack_rabbitmq_user)
    openstack_vhost.connect(openstack_rabbitmq_user, {
        'vhost_name',
    })
    return {'mariadb_service': mariadb_service,
            'rabbitmq_service1': rabbitmq_service,
            'openstack_vhost': openstack_vhost,
            'openstack_rabbitmq_user': openstack_rabbitmq_user}
开发者ID:aglarendil,项目名称:solar,代码行数:35,代码来源:openstack.py


示例9: deploy

def deploy():
    db.clear()
    resources = vr.create('nodes', 'templates/nodes.yaml', {'count': 1})
    first_node = next(x for x in resources if x.name.startswith('node'))

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

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

    ceph_mon = vr.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 = vr.create(
      'managed_apt1', 'templates/mos_repos.yaml',
      {'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:rustyrobot,项目名称:solar,代码行数:29,代码来源:ceph.py


示例10: setup_riak

def setup_riak(nodes_num=None, hosts_mapping=False):

    if nodes_num is None:
        nodes_num = NODES
    db.clear()

    resources = vr.create("nodes", "templates/nodes.yaml", {"count": nodes_num})
    nodes = [x for x in resources if x.name.startswith("node")]
    hosts_services = [x for x in resources if x.name.startswith("hosts_file")]

    riak_services = []
    ips = "10.0.0.%d"
    for i in xrange(nodes_num):
        num = i + 1
        r = vr.create(
            "riak_service%d" % num,
            "resources/riak_node",
            {
                "riak_self_name": "riak%d" % num,
                "riak_hostname": "riak_server%d.solar" % num,
                "riak_name": "riak%[email protected]_server%d.solar" % (num, num),
            },
        )[0]
        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"})

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

    res_errors = resource.validate_resources()
    for r, error in res_errors:
        click.echo("ERROR: %s: %s" % (r.name, error))
    has_errors = False

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

    events = []
    for x in xrange(nodes_num):
        i = x + 1
        if hosts_mapping:
            events.append(Dep("hosts_file%d" % i, "run", "success", "riak_service%d" % i, "run"))
        if i >= 2:
            events.append(React("riak_service%d" % i, "run", "success", "riak_service%d" % i, "join"))
        events.append(React("riak_service%d" % i, "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,代码行数:59,代码来源:riaks_big.py


示例11: setup_cinder_volume

def setup_cinder_volume(node, cinder_puppet):
    # CINDER VOLUME
    cinder_volume = vr.create('cinder_volume_{}'.format(node.name), 'resources/volume_group',
            {'path': '/root/cinder.img', 'volume_name': 'cinder-volume'})[0]
    node.connect(cinder_volume)

    cinder_volume_puppet = vr.create('cinder_volume_puppet', 'resources/cinder_volume_puppet', {})[0]
    node.connect(cinder_volume_puppet)
    cinder_puppet.connect(cinder_volume_puppet)
    evapi.add_react(cinder_puppet.name, cinder_volume_puppet.name, actions=('update',))
    cinder_volume.connect(cinder_volume_puppet, {'volume_name': 'volume_group'})
    return {'cinder_volume_puppet': cinder_volume_puppet}
开发者ID:aglarendil,项目名称:solar,代码行数:12,代码来源:openstack.py


示例12: setup_neutron_compute

def setup_neutron_compute(node, librarian, neutron_puppet, neutron_server_puppet):
    # NEUTRON FOR COMPUTE (node1)
    # Deploy chain neutron -> (plugins) -> ( agents )
    name = node.name
    neutron_puppet2 = vr.create("neutron_puppet_{}".format(name), "resources/neutron_puppet", {})[0]

    neutron_puppet2.connect_with_events(librarian, {"module": "modules"}, {})
    evapi.add_dep(librarian.name, neutron_puppet2.name, actions=("run", "update"))
    dep = evapi.Dep(librarian.name, "update", state="SUCESS", child=neutron_puppet2.name, child_action="run")
    evapi.add_event(dep)

    node.connect(neutron_puppet2)
    neutron_puppet.connect(
        neutron_puppet2,
        {
            "rabbit_host",
            "rabbit_port",
            "rabbit_user",
            "rabbit_password",
            "rabbit_virtual_host",
            "package_ensure",
            "core_plugin",
        },
    )

    # NEUTRON OVS PLUGIN & AGENT WITH GRE FOR COMPUTE (node1)
    neutron_plugins_ml22 = vr.create("neutron_plugins_ml_{}".format(name), "resources/neutron_plugins_ml2_puppet", {})[
        0
    ]
    node.connect(neutron_plugins_ml22)
    evapi.add_dep(neutron_puppet2.name, neutron_plugins_ml22.name, actions=("run",))
    evapi.add_dep(neutron_server_puppet.name, neutron_plugins_ml22.name, actions=("run",))

    neutron_agents_ml22 = vr.create(
        "neutron_agents_ml_{}".format(name),
        "resources/neutron_agents_ml2_ovs_puppet",
        {
            # TODO(bogdando) these should come from the node network resource
            "enable_tunneling": True,
            "tunnel_types": ["gre"],
            "local_ip": "10.1.0.14",  # Should be the IP addr of the br-mesh int.
        },
    )[0]
    node.connect(neutron_agents_ml22)
    evapi.add_dep(neutron_puppet2.name, neutron_agents_ml22.name, actions=("run",))
    evapi.add_dep(neutron_server_puppet.name, neutron_agents_ml22.name, actions=("run",))

    return {
        "neutron_puppet2": neutron_puppet2,
        "neutron_plugins_ml22": neutron_plugins_ml22,
        "neutron_agents_ml22": neutron_agents_ml22,
    }
开发者ID:prmtl,项目名称:solar,代码行数:52,代码来源:openstack.py


示例13: setup_cinder_volume

def setup_cinder_volume(node, cinder_puppet):
    # CINDER VOLUME
    cinder_volume = vr.create(
        "cinder_volume_{}".format(node.name),
        "resources/volume_group",
        {"path": "/root/cinder.img", "volume_name": "cinder-volume"},
    )[0]
    node.connect(cinder_volume)

    cinder_volume_puppet = vr.create("cinder_volume_puppet", "resources/cinder_volume_puppet", {})[0]
    node.connect(cinder_volume_puppet)
    cinder_puppet.connect(cinder_volume_puppet)
    evapi.add_react(cinder_puppet.name, cinder_volume_puppet.name, actions=("update",))
    cinder_volume.connect(cinder_volume_puppet, {"volume_name": "volume_group"})
    return {"cinder_volume_puppet": cinder_volume_puppet}
开发者ID:prmtl,项目名称:solar,代码行数:15,代码来源:openstack.py


示例14: setup_cinder_scheduler

def setup_cinder_scheduler(node, cinder_puppet):
    # CINDER SCHEDULER
    cinder_scheduler_puppet = vr.create('cinder_scheduler_puppet', 'resources/cinder_scheduler_puppet', {})[0]
    node.connect(cinder_scheduler_puppet)
    cinder_puppet.connect(cinder_scheduler_puppet)
    evapi.add_react(cinder_puppet.name, cinder_scheduler_puppet.name, actions=('update',))
    return {'cinder_scheduler_puppet': cinder_scheduler_puppet}
开发者ID:aglarendil,项目名称:solar,代码行数:7,代码来源:openstack.py


示例15: test_create_resource

def test_create_resource():
    node_path = os.path.join(
        os.path.dirname(os.path.realpath(__file__)),
        'resource_fixtures', 'node')
    resources = vr.create('node1', node_path)
    assert len(resources) == 1
    assert resources[0].name == 'node1'
开发者ID:torgartor21,项目名称:solar,代码行数:7,代码来源:test_virtual_resource.py


示例16: create

    def create(cls, count, resource_path, args={}):
        """Create a number of resources of the same type, with optional args.

        args -- an optional dict with create arguments. You can use
          "{num}" -- index of resource in the list
          "{resource_path_name}" -- name of resource from the `resource_path`
            argument
        """

        created_resources = []

        resource_path_name = os.path.split(resource_path)[-1]

        for num in range(count):
            kwargs = {
                'num': num,
                'resource_path_name': resource_path_name,
            }
            kwargs['name'] = '{resource_path_name}-{num}'.format(**kwargs)

            args_fmt = cls.args_fmt(args, kwargs)

            r = vr.create('{name}'.format(**kwargs),
                          resource_path,
                          args_fmt)[0]

            created_resources.append(r)

        return ResourceListTemplate(created_resources)
开发者ID:CGenie,项目名称:solar,代码行数:29,代码来源:template.py


示例17: run

def run():
    db.clear()

    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

    hosts1 = vr.create("hosts_file1", "resources/hosts_file", {})[0]
    hosts2 = vr.create("hosts_file2", "resources/hosts_file", {})[0]
    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:rustyrobot,项目名称:solar,代码行数:16,代码来源:hosts.py


示例18: setup_openrc

def setup_openrc(node, keystone_puppet, admin_user):
    # OPENRC
    openrc = vr.create("openrc_file", "resources/openrc_file", {})[0]

    node.connect(openrc)
    keystone_puppet.connect(openrc, {"ip": "keystone_host", "admin_port": "keystone_port"})
    admin_user.connect(openrc, {"user_name": "user_name", "user_password": "password", "tenant_name": "tenant"})
    return {"openrc_file": openrc}
开发者ID:prmtl,项目名称:solar,代码行数:8,代码来源:openstack.py


示例19: setup_nova_conductor

def setup_nova_conductor(node, nova_puppet, nova_api_puppet):
    # NOVA CONDUCTOR
    nova_conductor_puppet = vr.create("nova_conductor_puppet", "resources/nova_conductor_puppet", {})[0]
    node.connect(nova_conductor_puppet)
    nova_puppet.connect(nova_conductor_puppet)
    evapi.add_dep(nova_api_puppet.name, nova_conductor_puppet.name, actions=("run",))
    evapi.add_react(nova_puppet.name, nova_conductor_puppet.name, actions=("update",))
    return {"nova_conductor": nova_conductor_puppet}
开发者ID:prmtl,项目名称:solar,代码行数:8,代码来源:openstack.py


示例20: setup_openrc

def setup_openrc(node, keystone_puppet, admin_user):
    # OPENRC
    openrc = vr.create('openrc_file', 'resources/openrc_file', {})[0]

    node.connect(openrc)
    keystone_puppet.connect(openrc, {'ip': 'keystone_host', 'admin_port':'keystone_port'})
    admin_user.connect(openrc, {'user_name': 'user_name','user_password':'password', 'tenant_name': 'tenant'})
    return {'openrc_file' : openrc}
开发者ID:aglarendil,项目名称:solar,代码行数:8,代码来源:openstack.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python signals.connect函数代码示例发布时间:2022-05-27
下一篇:
Python composer.create函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap