def hello_world(request, cfy, manager, attributes, ssh_key, tmpdir, logger): tenant = prepare_and_get_test_tenant(request.param, manager, cfy) hw = HelloWorldExample(cfy, manager, attributes, ssh_key, logger, tmpdir, tenant=tenant, suffix=request.param) if 'windows' in request.param: hw.blueprint_file = 'openstack-windows-blueprint.yaml' hw.inputs.update({ 'flavor': attributes['large_flavor_name'], }) else: hw.blueprint_file = 'openstack-blueprint.yaml' hw.inputs.update({ 'agent_user': attributes['{os}_username'.format(os=request.param)], }) if request.param == 'rhel_7': hw.inputs.update({ 'flavor': attributes['medium_flavor_name'], }) hw.inputs.update({ 'image': attributes['{os}_image_name'.format(os=request.param)], }) if request.param == 'centos_6': hw.disable_iptables = True yield hw hw.cleanup()
def _test_agent(agent_type, cfy, manager, attributes): agent_blueprints = { 'a3_2': 'agent/3-2-agent-blueprint/3-2-agent-mispelled-blprint.yaml', 'ssh': 'agent/ssh-agent-blueprint/ssh-agent-blueprint.yaml', } blueprint_path = util.get_resource_path(agent_blueprints[agent_type]) tenant = prepare_and_get_test_tenant( 'agent_{}'.format(agent_type), manager, cfy, ) blueprint_id = deployment_id = agent_type with set_client_tenant(manager, tenant): manager.client.blueprints.upload(blueprint_path, blueprint_id) manager.client.deployments.create( deployment_id, blueprint_id, inputs={ 'ip_address': manager.ip_address, 'user': attributes.default_linux_username, 'private_key_path': manager.remote_private_key_path }, skip_plugins_validation=True) try: cfy.executions.start.install(['-d', deployment_id, '--tenant-name', tenant]) finally: cfy.executions.start.uninstall(['-d', deployment_id, '--tenant-name', tenant])
def _test_agent(agent_type, cfy, manager, attributes): agent_blueprints = { 'a3_2': 'agent/3-2-agent-blueprint/3-2-agent-mispelled-blprint.yaml', 'ssh': 'agent/ssh-agent-blueprint/ssh-agent-blueprint.yaml', } blueprint_path = util.get_resource_path(agent_blueprints[agent_type]) tenant = prepare_and_get_test_tenant( 'agent_{}'.format(agent_type), manager, cfy, ) blueprint_id = deployment_id = agent_type with set_client_tenant(manager, tenant): manager.client.blueprints.upload(blueprint_path, blueprint_id) manager.client.deployments.create( deployment_id, blueprint_id, inputs={ 'ip_address': manager.ip_address, 'user': attributes.default_linux_username, 'private_key_path': manager.remote_private_key_path }, skip_plugins_validation=True) try: cfy.executions.start.install(['-d', deployment_id, '--tenant-name', tenant]) finally: cfy.executions.start.uninstall(['-d', deployment_id, '--tenant-name', tenant])
def hello_world(request, cfy, manager, attributes, ssh_key, tmpdir, logger): tenant = prepare_and_get_test_tenant(request.param, manager, cfy) hw = HelloWorldExample( cfy, manager, attributes, ssh_key, logger, tmpdir, tenant=tenant, suffix=request.param) if 'windows' in request.param: hw.blueprint_file = 'openstack-windows-blueprint.yaml' hw.inputs.update({ 'flavor': attributes['large_flavor_name'], }) else: hw.blueprint_file = 'openstack-blueprint.yaml' hw.inputs.update({ 'agent_user': attributes['{os}_username'.format(os=request.param)], }) if request.param == 'rhel_7': hw.inputs.update({ 'flavor': attributes['medium_flavor_name'], }) hw.inputs.update({ 'image': attributes['{os}_image_name'.format(os=request.param)], }) if request.param == 'centos_6': hw.disable_iptables = True yield hw hw.cleanup()
def test_ubuntu_trusty_provided_userdata_agent(cfy, manager, attributes, tmpdir, logger): name = 'cloudify_agent' os_name = 'ubuntu_14_04' tenant = prepare_and_get_test_tenant( 'userdataprov_{}'.format(os_name), manager, cfy, ) install_userdata = _install_script( name=name, windows=False, user=attributes.ubuntu_14_04_username, manager=manager, attributes=attributes, tmpdir=tmpdir, logger=logger, tenant=tenant, ) _test_linux_userdata_agent( cfy, manager, attributes, os_name, install_method='provided', name=name, install_userdata=install_userdata, tenant=tenant, )
def test_windows_provided_userdata_agent(cfy, manager, attributes, tmpdir, logger): name = 'cloudify_agent' tenant = prepare_and_get_test_tenant( 'userdataprov_windows_2012', manager, cfy, ) install_userdata = _install_script( name=name, windows=True, user=attributes.windows_2012_username, manager=manager, attributes=attributes, tmpdir=tmpdir, logger=logger, tenant=tenant, ) test_windows_userdata_agent( cfy, manager, attributes, install_method='provided', name=name, install_userdata=install_userdata, tenant=tenant, )
def distributed_ha_hello_worlds(cfy, distributed_installation, attributes, ssh_key, tmpdir, logger): # Pick a manager to operate on, and trust the cluster to work with us manager = distributed_installation.instances[0] hws = [] for i in range(0, 2): tenant = prepare_and_get_test_tenant( 'clusterhello{num}'.format(num=i), manager, cfy, ) hw = centos_hello_world( cfy, manager, attributes, ssh_key, logger, tmpdir, tenant=tenant, suffix=str(i), ) hws.append(hw) yield hws for hw in hws: if hw.cleanup_required: logger.info('Cleaning up hello world...') manager.use() hw.cleanup()
def nodecellar(request, cfy, manager, attributes, ssh_key, tmpdir, logger): tenant = prepare_and_get_test_tenant(request.param, manager, cfy) nc = NodeCellarExample( cfy, manager, attributes, ssh_key, logger, tmpdir, tenant=tenant, suffix=request.param) nc.blueprint_file = '{type}-blueprint.yaml'.format(type=request.param) yield nc
def test_ubuntu_trusty_provided_userdata_agent(cfy, manager, attributes, tmpdir, logger): name = 'cloudify_agent' os_name = 'ubuntu_14_04' tenant = prepare_and_get_test_tenant( 'userdataprov_{}'.format(os_name), manager, cfy, ) install_userdata = _install_script( name=name, windows=False, user=attributes.ubuntu_14_04_username, manager=manager, attributes=attributes, tmpdir=tmpdir, logger=logger, tenant=tenant, ) _test_linux_userdata_agent( cfy, manager, attributes, os_name, install_method='provided', name=name, install_userdata=install_userdata, tenant=tenant, )
def nodecellar(cfy, manager, attributes, ssh_key, tmpdir, logger): tenant = util.prepare_and_get_test_tenant('nc_autoheal', manager, cfy) nc = NodeCellarExample( cfy, manager, attributes, ssh_key, logger, tmpdir, tenant=tenant, suffix='autoheal') nc.blueprint_file = 'openstack-blueprint.yaml' yield nc nc.cleanup()
def distributed_nodecellar(cfy, distributed_installation, attributes, ssh_key, tmpdir, logger): manager = distributed_installation.manager manager.use() tenant = prepare_and_get_test_tenant(TENANT_NAME, manager, cfy) nc = NodeCellarExample(cfy, manager, attributes, ssh_key, logger, tmpdir, tenant=tenant, suffix='simple') nc.blueprint_file = 'simple-blueprint-with-secrets.yaml' yield nc
def _test_agent_alive_after_reboot(cfy, manager, attributes, os_name, suffix=None): suffix = suffix or os_name os_blueprints = { 'centos_7': 'agent/reboot-vm-blueprint/reboot-unix-vm-blueprint.yaml', 'ubuntu_14_04': ( 'agent/reboot-vm-blueprint/reboot-unix-vm-blueprint.yaml' ), 'windows_2012': ( 'agent/reboot-vm-blueprint/reboot-winrm-vm-blueprint.yaml' ), } blueprint_name = os_blueprints[os_name] tenant = prepare_and_get_test_tenant(suffix, manager, cfy) inputs = { 'image': attributes['{os}_image_name'.format(os=os_name)], 'flavor': attributes['medium_flavor_name'], 'user': attributes['{os}_username'.format(os=os_name)], 'network_name': attributes['network_name'], 'private_key_path': manager.remote_private_key_path, 'keypair_name': attributes['keypair_name'], } blueprint_path = util.get_resource_path(blueprint_name) inputs['value'] = os_name blueprint_id = deployment_id = os_name with set_client_tenant(manager, tenant): manager.client.blueprints.upload(blueprint_path, blueprint_id) manager.client.deployments.create( deployment_id, blueprint_id, inputs=inputs, skip_plugins_validation=True) try: cfy.executions.start.install(['-d', deployment_id, '--tenant-name', tenant]) cfy.executions.start.execute_operation( deployment_id=deployment_id, parameters={ 'operation': 'cloudify.interfaces.reboot_test.reboot', 'node_ids': ['host'] }, tenant_name=tenant) finally: cfy.executions.start.uninstall(['-d', deployment_id, '--tenant-name', tenant]) with set_client_tenant(manager, tenant): app = manager.client.node_instances.list( node_id='application', deployment_id=deployment_id, )[0] assert os_name == app.runtime_properties['value']
def _test_agent_alive_after_reboot(cfy, manager, attributes, os_name, suffix=None): suffix = suffix or os_name os_blueprints = { 'centos_7': 'agent/reboot-vm-blueprint/reboot-unix-vm-blueprint.yaml', 'ubuntu_14_04': ( 'agent/reboot-vm-blueprint/reboot-unix-vm-blueprint.yaml' ), 'windows_2012': ( 'agent/reboot-vm-blueprint/reboot-winrm-vm-blueprint.yaml' ), } blueprint_name = os_blueprints[os_name] tenant = prepare_and_get_test_tenant(suffix, manager, cfy) inputs = { 'image': attributes['{os}_image_name'.format(os=os_name)], 'flavor': attributes['medium_flavor_name'], 'user': attributes['{os}_username'.format(os=os_name)], 'network_name': attributes['network_name'], 'private_key_path': manager.remote_private_key_path, 'keypair_name': attributes['keypair_name'], } blueprint_path = util.get_resource_path(blueprint_name) inputs['value'] = os_name blueprint_id = deployment_id = os_name with set_client_tenant(manager, tenant): manager.client.blueprints.upload(blueprint_path, blueprint_id) manager.client.deployments.create( deployment_id, blueprint_id, inputs=inputs, skip_plugins_validation=True) try: cfy.executions.start.install(['-d', deployment_id, '--tenant-name', tenant]) cfy.executions.start.execute_operation( deployment_id=deployment_id, parameters={ 'operation': 'cloudify.interfaces.reboot_test.reboot', 'node_ids': ['host'] }, tenant_name=tenant) finally: cfy.executions.start.uninstall(['-d', deployment_id, '--tenant-name', tenant]) with set_client_tenant(manager, tenant): app = manager.client.node_instances.list( node_id='application', deployment_id=deployment_id, )[0] assert os_name == app.runtime_properties['value']
def nodecellar_hostpool(hostpool, cfy, manager, attributes, ssh_key, tmpdir, logger): tenant = util.prepare_and_get_test_tenant('nc_hostpool', manager, cfy) nc = HostpoolNodeCellarExample( hostpool, cfy, manager, attributes, ssh_key, logger, tmpdir, tenant=tenant, suffix='nc_hostpool') nc.blueprint_file = 'host-pool-blueprint.yaml' nc.skip_plugins_validation = True yield nc nc.cleanup()
def nodecellar(request, cfy, managers, attributes, ssh_key, tmpdir, logger): manager = managers[0] manager.use() tenant = prepare_and_get_test_tenant(TENANT_NAME, manager, cfy) nc = NodeCellarExample( cfy, manager, attributes, ssh_key, logger, tmpdir, tenant=tenant, suffix='simple') nc.blueprint_file = 'simple-blueprint-with-secrets.yaml' # nc.blueprint_file = 'openstack-blueprint.yaml' # alternative bp for test yield nc
def test_windows_userdata_agent(cfy, manager, attributes, install_method='init_script', name=None, install_userdata=None, os_name='windows_2012', tenant=None): user = attributes.windows_2012_username file_path = 'C:\\Users\\{0}\\test_file'.format(user) userdata = '#ps1_sysnative\n' \ 'Set-Content {1} "{0}"'.format(EXPECTED_FILE_CONTENT, file_path) if install_userdata: userdata = create_multi_mimetype_userdata([userdata, install_userdata]) if not tenant: tenant = prepare_and_get_test_tenant( 'inst_userdata_{}'.format(os_name), manager, cfy, ) else: if not tenant: tenant = prepare_and_get_test_tenant( 'userdata_{}'.format(os_name), manager, cfy, ) inputs = { 'image': attributes.windows_2012_image_name, 'user': user, 'flavor': attributes.medium_flavor_name, 'os_family': 'windows', 'userdata': userdata, 'file_path': file_path, 'install_method': install_method, 'name': name, 'keypair_name': attributes.keypair_name, 'private_key_path': manager.remote_private_key_path, 'network_name': attributes.network_name } _test_userdata_agent(cfy, manager, inputs, tenant)
def _test_windows_common( cfy, manager, attributes, blueprint_path, inputs, os_name, tenant, deployment_id_prefix): user = attributes.windows_2012_username if not tenant: tenant = prepare_and_get_test_tenant( '{0}_{1}'.format(deployment_id_prefix, os_name), manager, cfy ) effective_inputs = { 'image': attributes.windows_2012_image_name, 'flavor': attributes.medium_flavor_name, 'user': user, 'network_name': attributes.network_name, 'private_key_path': manager.remote_private_key_path, 'keypair_name': attributes.keypair_name, } if inputs: effective_inputs.update(inputs) blueprint_id = deployment_id = '{0}_{1}'.format( deployment_id_prefix, time.time()) blueprint_path = util.get_resource_path(blueprint_path) with set_client_tenant(manager, tenant): manager.client.blueprints.upload(blueprint_path, blueprint_id) manager.client.deployments.create( deployment_id, blueprint_id, inputs=effective_inputs, skip_plugins_validation=True) cfy.executions.start.install(['-d', deployment_id, '--tenant-name', tenant]) try: cfy.executions.start.execute_operation( deployment_id=deployment_id, parameters={ 'operation': 'test.interface.test', 'node_ids': ['test_app'] }, tenant_name=tenant) finally: cfy.executions.start.uninstall(['-d', deployment_id, '--tenant-name', tenant])
def _test_windows_common( cfy, manager, attributes, blueprint_path, inputs, os_name, tenant, deployment_id_prefix): user = attributes.windows_2012_username if not tenant: tenant = prepare_and_get_test_tenant( '{0}_{1}'.format(deployment_id_prefix, os_name), manager, cfy ) effective_inputs = { 'image': attributes.windows_2012_image_name, 'flavor': attributes.medium_flavor_name, 'user': user, 'network_name': attributes.network_name, 'private_key_path': manager.remote_private_key_path, 'keypair_name': attributes.keypair_name, } if inputs: effective_inputs.update(inputs) blueprint_id = deployment_id = '{0}_{1}'.format( deployment_id_prefix, time.time()) blueprint_path = util.get_resource_path(blueprint_path) with set_client_tenant(manager, tenant): manager.client.blueprints.upload(blueprint_path, blueprint_id) manager.client.deployments.create( deployment_id, blueprint_id, inputs=effective_inputs, skip_plugins_validation=True) cfy.executions.start.install(['-d', deployment_id, '--tenant-name', tenant]) try: cfy.executions.start.execute_operation( deployment_id=deployment_id, parameters={ 'operation': 'test.interface.test', 'node_ids': ['test_app'] }, tenant_name=tenant) finally: cfy.executions.start.uninstall(['-d', deployment_id, '--tenant-name', tenant])
def hello_world(cfy, manager, attributes, ssh_key, tmpdir, logger): tenant = prepare_and_get_test_tenant('dep_update', manager, cfy) hw = centos_hello_world(cfy, manager, attributes, ssh_key, logger, tmpdir, tenant=tenant, suffix='update') yield hw hw.cleanup()
def hello_world(cfy, manager, attributes, ssh_key, tmpdir, logger): tenant = prepare_and_get_test_tenant('dep_update', manager, cfy) hw = centos_hello_world(cfy, manager, attributes, ssh_key, logger, tmpdir, tenant=tenant, suffix='update') yield hw hw.cleanup()
def nodecellar(cfy, manager, attributes, ssh_key, tmpdir, logger): tenant = util.prepare_and_get_test_tenant('nc_autoheal', manager, cfy) nc = NodeCellarExample(cfy, manager, attributes, ssh_key, logger, tmpdir, tenant=tenant, suffix='autoheal') nc.blueprint_file = 'openstack-blueprint.yaml' yield nc nc.cleanup()
def test_centos_7_userdata_agent(cfy, manager, attributes): os_name = 'centos_7' tenant = prepare_and_get_test_tenant( 'userdata_{}'.format(os_name), manager, cfy, ) _test_linux_userdata_agent( cfy, manager, attributes, os_name=os_name, tenant=tenant, )
def get_hello_worlds(cfy, manager, attributes, ssh_key, tmpdir, logger): if is_community(): tenants = ['default_tenant'] else: tenants = [ prepare_and_get_test_tenant(name, manager, cfy) for name in ('hello1', 'hello2') ] hellos = [] for tenant in tenants: hello = centos_hello_world(cfy, manager, attributes, ssh_key, logger, tmpdir, tenant, suffix=tenant) hellos.append(hello) return hellos
def nodecellar(cfy, manager, attributes, ssh_key, tmpdir, logger): tenant = prepare_and_get_test_tenant('nc_scale', manager, cfy) nc = NodeCellarExample(cfy, manager, attributes, ssh_key, logger, tmpdir, tenant=tenant, suffix='scale') nc.blueprint_file = 'openstack-haproxy-blueprint.yaml' nc.inputs['number_of_instances'] = 1 yield nc nc.cleanup()
def test_ubuntu_trusty_userdata_agent(cfy, manager, attributes): os_name = 'ubuntu_14_04' tenant = prepare_and_get_test_tenant( 'userdata_{}'.format(os_name), manager, cfy, ) _test_linux_userdata_agent( cfy, manager, attributes, os_name=os_name, tenant=tenant, )
def distributed_nodecellar(cfy, distributed_installation, attributes, ssh_key, tmpdir, logger): manager = distributed_installation.manager manager.use() tenant = prepare_and_get_test_tenant(TENANT_NAME, manager, cfy) nc = NodeCellarExample(cfy, manager, attributes, ssh_key, logger, tmpdir, tenant=tenant, suffix='simple') nc.blueprint_file = 'simple-blueprint-with-secrets.yaml' yield nc
def _make_network_hello_worlds(cfy, managers, attributes, ssh_key, tmpdir, logger): # The first manager is the initial one manager = managers[0] manager.use() hellos = [] # Add a MultiNetworkHelloWorld per management network for network_name, network_id in attributes.network_names.iteritems(): tenant = prepare_and_get_test_tenant('{0}_tenant'.format(network_name), manager, cfy) hello = MultiNetworkHelloWorld(cfy, manager, attributes, ssh_key, logger, tmpdir, tenant=tenant, suffix=network_name) hello.blueprint_file = 'openstack-blueprint.yaml' hello.inputs.update({ 'agent_user': attributes.centos_7_username, 'image': attributes.centos_7_image_name, 'manager_network_name': network_name, 'network_name': network_id }) # Make sure the post_bootstrap network is first if network_name == NETWORK_2: hellos.insert(0, hello) else: hellos.append(hello) # Add one more hello world, that will run on the `default` network # implicitly hw = centos_hello_world(cfy, manager, attributes, ssh_key, logger, tmpdir, tenant=DEFAULT_TENANT_NAME, suffix='default_network') hellos.append(hw) yield hellos for hello in hellos: hello.cleanup()
def hostpool(cfy, manager, attributes, ssh_key, logger, tmpdir): tenant = util.prepare_and_get_test_tenant('hostpool', manager, cfy) hp = HostPoolExample(cfy, manager, attributes, ssh_key, logger, tmpdir, tenant=tenant, suffix='hostpool') hp.blueprint_file = util.get_resource_path('hostpool/service-blueprint.yaml') # noqa hp.skip_plugins_validation = True # verification is unrolled here because we want to validate and yield # the service for further testing before uninstalling it hp.upload_blueprint() hp.create_deployment() hp.install() hp.verify_installation() yield hp hp.uninstall() hp.delete_deployment() hp.cleanup()
def test_windows_provided_userdata_agent(cfy, manager, attributes, tmpdir, logger): name = 'cloudify_agent' tenant = prepare_and_get_test_tenant( 'userdataprov_windows_2012', manager, cfy, ) install_userdata = _install_script( name=name, windows=True, user=attributes.windows_2012_username, manager=manager, attributes=attributes, tmpdir=tmpdir, logger=logger, tenant=tenant, ) user = attributes.windows_2012_username file_path = 'C:\\Users\\{0}\\test_file'.format(user) userdata = '#ps1_sysnative\n' \ 'Set-Content {1} "{0}"'.format(EXPECTED_FILE_CONTENT, file_path) userdata = create_multi_mimetype_userdata([userdata, install_userdata]) inputs = { 'image': attributes.windows_2012_image_name, 'user': user, 'flavor': attributes.medium_flavor_name, 'os_family': 'windows', 'userdata': userdata, 'file_path': file_path, 'install_method': 'provided', 'name': name, 'keypair_name': attributes.keypair_name, 'private_key_path': manager.remote_private_key_path, 'network_name': attributes.network_name } _test_userdata_agent(cfy, manager, inputs, tenant)
def _make_network_hello_worlds(cfy, managers, attributes, ssh_key, tmpdir, logger): # The first manager is the initial one manager = managers[0] manager.use() hellos = [] # Add a MultiNetworkHelloWorld per management network for network_name, network_id in attributes.network_names.iteritems(): tenant = prepare_and_get_test_tenant( '{0}_tenant'.format(network_name), manager, cfy ) hello = MultiNetworkHelloWorld( cfy, manager, attributes, ssh_key, logger, tmpdir, tenant=tenant, suffix=network_name) hello.blueprint_file = 'openstack-blueprint.yaml' hello.inputs.update({ 'agent_user': attributes.centos_7_username, 'image': attributes.centos_7_image_name, 'manager_network_name': network_name, 'network_name': network_id }) # Make sure the post_bootstrap network is first if network_name == NETWORK_2: hellos.insert(0, hello) else: hellos.append(hello) # Add one more hello world, that will run on the `default` network # implicitly hw = centos_hello_world(cfy, manager, attributes, ssh_key, logger, tmpdir, tenant=DEFAULT_TENANT_NAME, suffix='default_network') hellos.append(hw) yield hellos for hello in hellos: hello.cleanup()
def distributed_ha_hello_worlds(cfy, distributed_installation, attributes, ssh_key, tmpdir, logger): # Pick a manager to operate on, and trust the cluster to work with us manager = distributed_installation.instances[0] hws = [] for i in range(0, 2): tenant = prepare_and_get_test_tenant( 'clusterhello{num}'.format(num=i), manager, cfy, ) hw = centos_hello_world( cfy, manager, attributes, ssh_key, logger, tmpdir, tenant=tenant, suffix=str(i), ) hws.append(hw) yield hws for hw in hws: if hw.cleanup_required: logger.info('Cleaning up hello world...') manager.use() hw.cleanup()