示例#1
0
    def test_network_deployment(self):
        # Create a list of node templates to verify.
        aws_nodes = [
            'nat_gateway', 'nat_gateway_ip', 'private_subnet_routetable',
            'public_subnet_routetable', 'private_subnet', 'public_subnet',
            'internet_gateway', 'vpc'
        ]
        # Prepare to call clean up method whenever test pass/fail
        self.addCleanup(self.remove_deployment, 'aws-example-network',
                        aws_nodes)

        # Create Deployment (Blueprint already uploaded.)
        if utils.create_deployment('aws-example-network'):
            raise Exception('Deployment aws-example-network failed.')
        # Install Deployment.
        if utils.execute_install('aws-example-network'):
            raise Exception('Install aws-example-network failed.')
        # Get list of nodes in the deployment.
        deployment_nodes = \
            utils.get_deployment_resources_by_node_type_substring(
                'aws', self.node_type_prefix)
        # Check that the nodes really exist.
        self.check_resources_in_deployment_created(deployment_nodes, aws_nodes)

        self.check_nodecellar()

        self.check_external_nodecellar()
 def check_nodecellar(self):
     aws_nodes = [
         'security_group', 'haproxy_nic', 'nodejs_nic', 'mongo_nic',
         'nodecellar_ip'
     ]
     monitored_nodes = [
         'haproxy_frontend_host', 'nodejs_host', 'mongod_host'
     ]
     failed = utils.install_nodecellar(
         blueprint_file_name=self.blueprint_file_name)
     if failed:
         raise Exception('Nodecellar install failed.')
     del failed
     self.addCleanup(self.cleanup_deployment, 'nc')
     failed = utils.execute_scale('nc', scalable_entity_name='nodejs_group')
     if failed:
         raise Exception('Nodecellar scale failed.')
     del failed
     deployment_nodes = \
         utils.get_deployment_resources_by_node_type_substring(
             'nc', 'cloudify')
     self.check_resources_in_deployment_created(deployment_nodes, aws_nodes)
     self.check_resources_in_deployment_created(deployment_nodes,
                                                monitored_nodes)
     blueprint_dir = tempfile.mkdtemp()
     blueprint_zip = os.path.join(blueprint_dir, 'blueprint.zip')
     blueprint_archive = 'nodecellar-auto-scale-auto-heal-blueprint-master'
     download_path = \
         os.path.join(blueprint_dir, blueprint_archive, 'aws.yaml')
     blueprint_path = utils.create_blueprint(utils.NODECELLAR,
                                             blueprint_zip, blueprint_dir,
                                             download_path)
     skip_transform = [
         'aws', 'vpc', 'public_subnet', 'private_subnet',
         'ubuntu_trusty_ami'
     ]
     new_blueprint_path = utils.create_external_resource_blueprint(
         blueprint_path,
         aws_nodes,
         deployment_nodes,
         resource_id_attr='aws_resource_id',
         nodes_to_keep_without_transform=skip_transform)
     failed = utils.execute_command(
         'cfy install {0} -b nc-external'.format(new_blueprint_path))
     if failed:
         raise Exception('Nodecellar external install failed.')
     failed = utils.execute_uninstall('nc-external')
     if failed:
         raise Exception('Nodecellar external uninstall failed.')
     failed = utils.execute_uninstall('nc')
     if failed:
         raise Exception('Nodecellar uninstall failed.')
     del failed
     self.check_resources_in_deployment_deleted(deployment_nodes, aws_nodes)
     self.check_resources_in_deployment_deleted(deployment_nodes,
                                                monitored_nodes)
示例#3
0
    def get_resources_from_deployment(
        self,
        deployment_id,
        node_type,
    ):

        return utils.get_deployment_resources_by_node_type_substring(
            deployment_id,
            node_type,
        )
示例#4
0
    def remove_deployment(self, deployment_id, nodes_to_check):

        # UnDeploy the application
        execute_command('cfy executions start uninstall '
                        '-p ignore_failure=true -d {0}'.format(deployment_id))

        deployment_nodes = \
            get_deployment_resources_by_node_type_substring(
                deployment_id, self.node_type_prefix)

        self.check_resources_in_deployment_deleted(deployment_nodes,
                                                   nodes_to_check)
示例#5
0
 def install_deployment_proxy_external(self, blueprint_id):
     parent_id = '{0}-existing'.format(blueprint_id)
     utils.execute_command(
         'cfy blueprints upload cloudify_deployment_proxy/'
         'examples/test-blueprint-existing.yaml -b {0}'.format(parent_id))
     utils.create_deployment(parent_id, inputs={'test_id': blueprint_id})
     utils.execute_install(parent_id)
     rs = utils.get_deployment_resources_by_node_type_substring(
         parent_id, 'cloudify.nodes.DeploymentProxy')
     deployment_outputs = \
         rs[0]['instances'][0]['runtime_properties']['deployment']
     if 'output1' not in deployment_outputs['outputs']:
         raise Exception('output1 not in {0}'.format(deployment_outputs))
示例#6
0
 def install_cloud_init(self, blueprint_id):
     utils.execute_command(
         'cfy blueprints upload cloudify_cloudinit/'
         'examples/simple.yaml -b {0}'.format(blueprint_id))
     utils.create_deployment(blueprint_id)
     utils.execute_install(blueprint_id)
     rs = utils.get_deployment_resources_by_node_type_substring(
         blueprint_id, 'cloudify.nodes.CloudInit.CloudConfig')
     cloud_config = \
         rs[0]['instances'][0]['runtime_properties']['cloud_config']
     if '#cloud-config' not in cloud_config:
         raise Exception('{0} not in {1}'.format('#cloud-config',
                                                 cloud_config))
     utils.execute_uninstall(blueprint_id)
示例#7
0
 def install_rest(self, blueprint_id):
     utils.execute_command(
         'cfy blueprints upload cloudify_rest/'
         'examples/example-4-blueprint.yaml -b {0}'.format(blueprint_id))
     utils.create_deployment(blueprint_id,
                             inputs={'commit': os.environ['CIRCLE_SHA1']})
     utils.execute_install(blueprint_id)
     rs = utils.get_deployment_resources_by_node_type_substring(
         blueprint_id, 'cloudify.rest.Requests')
     rest_instance = rs[0]['instances'][0]['runtime_properties']
     if 'commit' not in rest_instance['result_propeties']:
         raise Exception('{0} not in {1}'.format(
             'commit', rest_instance['result_propeties']))
     utils.execute_uninstall(blueprint_id)
    def remove_deployment(self, deployment_id, nodes_to_check):

        # UnDeploy the application
        utils.execute_command(
            'cfy executions start uninstall '
            '-p ignore_failure=true -d {0}'.format(
                deployment_id))

        deployment_nodes = \
            utils.get_deployment_resources_by_node_type_substring(
                deployment_id, self.node_type_prefix)

        self.check_resources_in_deployment_deleted(
            deployment_nodes, nodes_to_check
        )
示例#9
0
 def get_nc_deployment_nodes():
     return\
         utils.get_deployment_resources_by_node_type_substring('nc',
                                                               'cloudify')
    def get_resources_from_deployment(self, deployment_id, node_type,):

        return utils.get_deployment_resources_by_node_type_substring(
            deployment_id, node_type,)