def resource_setup(cls):
        super(SSHActionsTestsV2, cls).resource_setup()

        # Modify security group for accessing VM via SSH.
        cls._create_security_group_rule_ssh()

        # Create keypair (public and private keys).
        cls.private_key, cls.public_key = utils.generate_key_pair()
        cls.key_name = 'mistral-functional-tests-key'

        # If ZUUL_PROJECT is specified, it means
        # tests are running on Jenkins gate.

        if os.environ.get('ZUUL_PROJECT'):
            cls.key_dir = "/opt/stack/new/.ssh/"

            if not path.exists(cls.key_dir):
                os.mkdir(cls.key_dir)
        else:
            cls.key_dir = SSH_KEYS_DIRECTORY

        utils.save_text_to(cls.private_key,
                           cls.key_dir + cls.key_name,
                           overwrite=True)

        LOG.info("Private key saved to %s" % cls.key_dir + cls.key_name)

        # Create keypair in nova.
        cls.mgr.keypairs_client.create_keypair(name=cls.key_name,
                                               public_key=cls.public_key)

        # Start servers and provide key_name.
        # Note: start public vm only after starting the guest one,
        # so we can track public vm launching using ssh, but can't
        # do the same with guest VM.
        cls.guest_vm = cls._create_server('mistral-guest-vm',
                                          key_name=cls.key_name)
        cls.public_vm = cls._create_server('mistral-public-vm',
                                           key_name=cls.key_name)

        cls._wait_until_server_active(cls.public_vm['id'])

        cls.public_vm_ip = cls._associate_floating_ip_to_server(
            cls.public_vm['id'])

        # Wait until server is up.
        cls._wait_until_server_up(cls.public_vm_ip)

        # Update servers info.
        cls.public_vm = cls.server_client.show_server(
            cls.public_vm['id']).get('server')

        cls.guest_vm = cls.server_client.show_server(
            cls.guest_vm['id']).get('server')
    def resource_setup(cls):
        super(SSHActionsTestsV2, cls).resource_setup()

        # Modify security group for accessing VM via SSH.
        cls._create_security_group_rule_ssh()

        # Create keypair (public and private keys).
        cls.private_key, cls.public_key = utils.generate_key_pair()
        cls.key_name = 'mistral-functional-tests-key'

        # If ZUUL_PROJECT is specified, it means
        # tests are running on Jenkins gate.

        if os.environ.get('ZUUL_PROJECT'):
            cls.key_dir = "/opt/stack/new/.ssh/"

            if not path.exists(cls.key_dir):
                os.mkdir(cls.key_dir)
        else:
            cls.key_dir = SSH_KEYS_DIRECTORY

        utils.save_text_to(
            cls.private_key,
            cls.key_dir + cls.key_name,
            overwrite=True
        )

        LOG.info(
            "Private key saved to %s" % cls.key_dir + cls.key_name
        )

        # Create keypair in nova.
        cls.mgr.keypairs_client.create_keypair(
            name=cls.key_name,
            public_key=cls.public_key
        )

        # Start servers and provide key_name.
        # Note: start public vm only after starting the guest one,
        # so we can track public vm launching using ssh, but can't
        # do the same with guest VM.
        cls.guest_vm = cls._create_server(
            'mistral-guest-vm',
            key_name=cls.key_name
        )
        cls.public_vm = cls._create_server(
            'mistral-public-vm',
            key_name=cls.key_name
        )

        cls._wait_until_server_active(cls.public_vm['id'])

        cls.public_vm_ip = cls._associate_floating_ip_to_server(
            cls.public_vm['id']
        )

        # Wait until server is up.
        cls._wait_until_server_up(cls.public_vm_ip)

        # Update servers info.
        cls.public_vm = cls.mgr.servers_client.show_server(
            cls.public_vm['id']
        ).get('server')

        cls.guest_vm = cls.mgr.servers_client.show_server(
            cls.guest_vm['id']
        ).get('server')