Пример #1
0
 def create_self_signed_certificate(target_certificate_path,
                                    target_key_path, common_name):
     openssl = util.sh_bake(sh.openssl)
     # Includes SAN to allow this cert to be valid for localhost (by name),
     # 127.0.0.1 (IP), and including the CN in the IP list, as some clients
     # ignore the CN when SAN is present. While this may only apply to
     # HTTPS (RFC 2818), including it here is probably best in case of SSL
     # library implementation 'fun'.
     openssl.req(
         '-x509',
         '-newkey',
         'rsa:2048',
         '-sha256',
         '-keyout',
         target_key_path,
         '-out',
         target_certificate_path,
         '-days',
         '365',
         '-nodes',
         '-subj',
         '/CN={ip} '
         '/subjectAltName=IP:127.0.0.1,DNS:localhost,IP:{ip}'.format(
             ip=common_name, ),
     ).wait()
 def __init__(self, tmpdir, attributes, ssh_key, logger):
     self.terraform = sh_bake(sh.terraform)
     self.tmpdir = tmpdir
     self.attributes = attributes
     self.ssh_key = ssh_key
     self.logger = logger
     self.inputs = self._get_default_inputs()
     self.inputs_file = self.tmpdir / 'inputs.json'
     os.mkdir(self.tmpdir / 'scripts')
Пример #3
0
 def __init__(self, tmpdir, attributes, ssh_key, logger):
     self.terraform = sh_bake(sh.terraform)
     self.tmpdir = tmpdir
     self.attributes = attributes
     self.ssh_key = ssh_key
     self.logger = logger
     self.inputs = self._get_default_inputs()
     self.inputs_file = self.tmpdir / 'inputs.json'
     os.mkdir(self.tmpdir / 'scripts')
Пример #4
0
def create_cluster_object(ssh_key, clean=False):
    logger.info('Cloudify manager context will be stored in: %s', tmpdir)
    cfy = sh_bake(sh.cfy)
    attributes = get_attributes(logger)
    hosts = TestHosts(cfy,
                      ssh_key,
                      tmpdir,
                      attributes,
                      logger,
                      upload_plugins=not clean)
    return hosts
Пример #5
0
def create_cluster_object(ssh_key, clean=False):
    logger.info('Cloudify manager context will be stored in: %s', tmpdir)
    cfy = sh_bake(sh.cfy)
    attributes = get_attributes(logger)
    hosts = TestHosts(
            cfy,
            ssh_key,
            tmpdir,
            attributes,
            logger,
            upload_plugins=not clean)
    return hosts
Пример #6
0
def cfy(module_tmpdir, logger):
    os.environ['CFY_WORKDIR'] = module_tmpdir
    logger.info('CFY_WORKDIR is set to %s', module_tmpdir)
    # Copy CLI configuration file if exists in home folder
    # this way its easier to customize the configuration when running
    # tests locally.
    cli_config_path = Path(os.path.expanduser('~/.cloudify/config.yaml'))
    if cli_config_path.exists():
        logger.info('Using CLI configuration file from: %s', cli_config_path)
        new_cli_config_dir = module_tmpdir / '.cloudify'
        new_cli_config_dir.mkdir()
        cli_config_path.copy(new_cli_config_dir / 'config.yaml')
    cfy = util.sh_bake(sh.cfy)
    cfy(['--version'])
    return cfy
 def create_self_signed_certificate(target_certificate_path,
                                    target_key_path,
                                    common_name):
     openssl = util.sh_bake(sh.openssl)
     # Includes SAN to allow this cert to be valid for localhost (by name),
     # 127.0.0.1 (IP), and including the CN in the IP list, as some clients
     # ignore the CN when SAN is present. While this may only apply to
     # HTTPS (RFC 2818), including it here is probably best in case of SSL
     # library implementation 'fun'.
     openssl.req(
         '-x509', '-newkey', 'rsa:2048', '-sha256',
         '-keyout', target_key_path,
         '-out', target_certificate_path,
         '-days', '365', '-nodes',
         '-subj',
         '/CN={ip} '
         '/subjectAltName=IP:127.0.0.1,DNS:localhost,IP:{ip}'.format(
             ip=common_name,
         ),
     ).wait()
Пример #8
0
 def __init__(self,
              cfy,
              ssh_key,
              tmpdir,
              attributes,
              logger,
              number_of_managers=1):
     super(CloudifyCluster, self).__init__()
     self._logger = logger
     self._attributes = attributes
     self._tmpdir = tmpdir
     self._ssh_key = ssh_key
     self._cfy = cfy
     self._number_of_managers = number_of_managers
     self._terraform = util.sh_bake(sh.terraform)
     self._terraform_inputs_file = self._tmpdir / 'terraform-vars.json'
     self._managers = None
     self.preconfigure_callback = None
     self._managers_config = [
         self._get_default_manager_config()
         for _ in range(number_of_managers)
     ]
Пример #9
0
    def __init__(self,
                 cfy,
                 ssh_key,
                 tmpdir,
                 attributes,
                 logger,
                 number_of_instances=1,
                 instances=None,
                 tf_template=None,
                 template_inputs=None,
                 upload_plugins=True,
                 request=None):
        """
        instances: supply a list of VM instances.
        This allows pre-configuration to happen before starting the hosts, or
        for a list of instances of different versions to be created at once.
        if instances is provided, number_of_instances will be ignored
        """

        super(TestHosts, self).__init__()
        self._logger = logger
        self._attributes = attributes
        self._tmpdir = tmpdir
        self._ssh_key = ssh_key
        self._cfy = cfy
        self._terraform = util.sh_bake(sh.terraform)
        self._terraform_inputs_file = self._tmpdir / 'terraform-vars.json'
        self._tf_template = tf_template or 'openstack-vm.tf.template'
        self.preconfigure_callback = None
        if instances is not None:
            self.instances = instances
        else:
            self.instances = [
                CURRENT_MANAGER(upload_plugins=upload_plugins)
                for _ in range(number_of_instances)
            ]
        self._template_inputs = template_inputs or {'servers': self.instances}
        self._request = request
    def __init__(self,
                 cfy,
                 ssh_key,
                 tmpdir,
                 attributes,
                 logger,
                 number_of_instances=1,
                 instances=None,
                 tf_template=None,
                 template_inputs=None,
                 upload_plugins=True,
                 request=None):
        """
        instances: supply a list of VM instances.
        This allows pre-configuration to happen before starting the hosts, or
        for a list of instances of different versions to be created at once.
        if instances is provided, number_of_instances will be ignored
        """

        super(TestHosts, self).__init__()
        self._logger = logger
        self._attributes = attributes
        self._tmpdir = tmpdir
        self._ssh_key = ssh_key
        self._cfy = cfy
        self._terraform = util.sh_bake(sh.terraform)
        self._terraform_inputs_file = self._tmpdir / 'terraform-vars.json'
        self._tf_template = tf_template or 'openstack-vm.tf.template'
        self.preconfigure_callback = None
        if instances is not None:
            self.instances = instances
        else:
            self.instances = [
                CURRENT_MANAGER(upload_plugins=upload_plugins)
                for _ in range(number_of_instances)]
        self._template_inputs = template_inputs or {'servers': self.instances}
        self._request = request
Пример #11
0
#    * limitations under the License.


import tempfile
import shutil
import json

import sh
from path import path

from cloudify_cli.utils import (load_cloudify_working_dir_settings,
                                get_configuration_path)
from cosmo_tester.framework.util import sh_bake, YamlPatcher


cfy = sh_bake(sh.cfy)


DEFAULT_EXECUTE_TIMEOUT = 1800


class CfyHelper(object):

    def __init__(self,
                 cfy_workdir=None,
                 management_ip=None,
                 testcase=None):
        self._cfy_workdir = cfy_workdir
        self._testcase = testcase
        self.tmpdir = False
        if cfy_workdir is None:
Пример #12
0
#    * limitations under the License.

__author__ = 'dank'

import os
import logging

import sh
from path import path

from cosmo_tester.framework.util import sh_bake


logger = logging.getLogger('git_helper')
logger.setLevel(logging.INFO)
git = sh_bake(sh.git)


def clone(url, basedir, branch=None):
    branch = branch or os.environ.get('BRANCH_NAME_CORE', 'master')

    repo_name = url.split('.git')[0].split('/')[-1]

    target = path(os.path.join(basedir, 'git', repo_name))

    logger.info("Cloning {0} to {1}".format(url, target))
    git.clone(url, str(target)).wait()
    with target:
        logger.info("Checking out to {0} branch".format(branch))
        git.checkout(branch).wait()
    return target.abspath()
import requests
from retrying import retry
import sh
import yaml

import fabric.api as fab
from cloudify.workflows import local
from cloudify_cli import constants as cli_constants
from cosmo_tester.framework.testenv import TestCase
from cosmo_tester.framework import util
from fabric.context_managers import settings as fab_env, cd, shell_env


# The cfy helper doesn't provide an init method, so we'll do it ourselves
cfy = util.sh_bake(sh.cfy)

# If we get a recycled floating IP we'll have a bad day without this
fab.env['disable_known_hosts'] = True

CHECK_URL = 'www.google.com'
HELLO_WORLD_EXAMPLE_NAME = 'cloudify-hello-world-example'
EXAMPLE_URL = 'https://github.com/cloudify-cosmo/{0}/archive/{1}.tar.gz'


class FabException(Exception):
    """
    Custom exception which replaces the standard SystemExit which is raised
    by fabric on errors.
    """
    pass
Пример #14
0
# distributed under the License is distributed on an "AS IS" BASIS,
#    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#    * See the License for the specific language governing permissions and
#    * limitations under the License.

import os
import logging

import sh
from path import path

from cosmo_tester.framework.util import sh_bake

logger = logging.getLogger('git_helper')
logger.setLevel(logging.INFO)
git = sh_bake(sh.git)


def clone(url, basedir, branch=None):
    branch = branch or os.environ.get('BRANCH_NAME_CORE', 'master')

    repo_name = url.split('.git')[0].split('/')[-1]

    target = path(os.path.join(basedir, 'git', repo_name))

    logger.info("Cloning {0} to {1}".format(url, target))
    git.clone(url, str(target)).wait()
    with target:
        logger.info("Checking out to {0} branch".format(branch))
        git.checkout(branch).wait()
    return target.abspath()
Пример #15
0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
#    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#    * See the License for the specific language governing permissions and
#    * limitations under the License.

import sh

from cloudify_cli import constants
from cloudify_rest_client import CloudifyClient

from cosmo_tester.framework import util
from cosmo_tester.test_suites.test_security.security_test_base import \
    SecurityTestBase, TEST_CFY_USERNAME, TEST_CFY_PASSWORD

openssl = util.sh_bake(sh.openssl)


class SSLTestBase(SecurityTestBase):

    def setUp(self):
        super(SSLTestBase, self).setUp()
        self.cert_path = ''
        self.key_path = ''

    def set_rest_client(self):
        self.client = CloudifyClient(
            host=self.env.management_ip,
            port=constants.SECURED_REST_PORT,
            protocol=constants.SECURED_PROTOCOL,
            headers=util.get_auth_header(username=TEST_CFY_USERNAME,
# distributed under the License is distributed on an "AS IS" BASIS,
#    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#    * See the License for the specific language governing permissions and
#    * limitations under the License.

import os
import sh

from cloudify_cli import constants
from cloudify_rest_client import CloudifyClient

from cosmo_tester.framework import util
from cosmo_tester.test_suites.test_security.security_test_base import \
    SecurityTestBase, TEST_CFY_USERNAME, TEST_CFY_PASSWORD

openssl = util.sh_bake(sh.openssl)


class SSLTestBase(SecurityTestBase):

    def setUp(self):
        super(SSLTestBase, self).setUp()
        self.cert_path = ''
        self.key_path = ''

    def _set_credentials_env_vars(self):
        super(SSLTestBase, self)._set_credentials_env_vars()
        os.environ[constants.CLOUDIFY_SSL_TRUST_ALL] = 'true'

    def set_rest_client(self):
        self.client = CloudifyClient(
Пример #17
0
import requests
from retrying import retry
import sh
import yaml

import fabric.api as fab
from cloudify.workflows import local
from cloudify_rest_client import CloudifyClient
from cloudify_cli import constants as cli_constants
from cosmo_tester.framework.testenv import TestCase
from cosmo_tester.framework.util import sh_bake
from fabric.context_managers import settings as fab_env, cd

# The cfy helper doesn't provide an init method, so we'll do it ourselves
cfy = sh_bake(sh.cfy)

# If we get a recycled floating IP we'll have a bad day without this
fab.env['disable_known_hosts'] = True

CHECK_URL = 'www.google.com'
HELLO_WORLD_EXAMPLE_NAME = 'cloudify-hello-world-example'
EXAMPLE_URL = 'https://github.com/cloudify-cosmo/{0}/archive/{1}.tar.gz'


class FabException(Exception):
    """
    Custom exception which replaces the standard SystemExit which is raised
    by fabric on errors.
    """
    pass