Exemplo n.º 1
0
    def setUpClass(cls):

        super(UITestCase, cls).setUpClass()

        keystone_client = ksclient.Client(username=cfg.common.user,
                                          password=cfg.common.password,
                                          tenant_name=cfg.common.tenant,
                                          auth_url=cfg.common.keystone_url)

        cls.murano_client = mclient('1', endpoint=cfg.common.murano_url,
                                    token=keystone_client.auth_token)

        glance_endpoint = keystone_client.service_catalog.url_for(
            service_type='image', endpoint_type='publicURL')
        glance = gclient('1', endpoint=glance_endpoint,
                         token=keystone_client.auth_token)

        image_list = []
        for i in glance.images.list():
            image_list.append(i)

        cls.demo_image = cls.get_image_name('demo', image_list)
        cls.linux_image = cls.get_image_name('linux', image_list)
        cls.windows_image = cls.get_image_name('windows', image_list)
        cls.keypair = cfg.common.keypair_name
        cls.asp_git_repository = cfg.common.asp_git_repository

        cls.elements = ConfigParser.RawConfigParser()
        cls.elements.read('common.ini')
        cls.logger = logging.getLogger(__name__)
Exemplo n.º 2
0
    def setUpClass(cls):
        super(UITestCase, cls).setUpClass()
        keystone_client = ksclient.Client(username=cfg.common.user,
                                          password=cfg.common.password,
                                          tenant_name=cfg.common.tenant,
                                          auth_url=cfg.common.keystone_url)

        cls.murano_client = mclient('1', endpoint=cfg.common.murano_url,
                                    token=keystone_client.auth_token)

        glance_endpoint = keystone_client.service_catalog.url_for(
            service_type='image', endpoint_type='publicURL')
        glance = gclient('1', endpoint=glance_endpoint,
                         token=keystone_client.auth_token)

        cls.headers = {'X-Auth-Token': keystone_client.auth_token}

        image_list = []
        for i in glance.images.list():
            image_list.append(i)

        cls.demo_image = cls.get_image_name('demo', image_list)
        cls.linux_image = cls.get_image_name('linux', image_list)
        cls.windows_image = cls.get_image_name('windows', image_list)
        cls.keypair = cfg.common.keypair_name
        cls.asp_git_repository = cfg.common.asp_git_repository
        cls.tomcat_repository = cfg.common.tomcat_repository

        cls.elements = ConfigParser.RawConfigParser()
        cls.elements.read('common.ini')
        cls.logger = logging.getLogger(__name__)

        cls.location = os.path.realpath(
            os.path.join(os.getcwd(), os.path.dirname(__file__)))

        def archive_app(app_name):
            __folderpath__ = os.path.join(cls.location, "{0}".format(app_name))
            __rootlen__ = len(__folderpath__) + 1
            with zipfile.ZipFile(os.path.join(
                    cls.location,
                    "{0}.zip".format(app_name)), "w") as zf:
                for dirname, _, files in os.walk(__folderpath__):
                    for filename in files:
                        fn = os.path.join(dirname, filename)
                        zf.write(fn, fn[__rootlen__:])

        archive_app('PostgreSQL')
        archive_app('AppForUploadTest')

        def upload_package(package_name, body):

            files = {'%s' % package_name: open(
                os.path.join(cls.location, 'PostgreSQL.zip'), 'rb')}

            post_body = {'JsonString': json.dumps(body)}
            request_url = '{endpoint}{url}'.format(
                endpoint=cfg.common.murano_url,
                url='/v1/catalog/packages')

            return requests.post(request_url,
                                 files=files,
                                 data=post_body,
                                 headers=cls.headers).json()['id']

        cls.postgre_id = upload_package(
            'PostgreSQL',
            {"categories": ["Web"], "tags": ["tag"]})
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.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 argparse
from keystoneclient.v2_0 import client as ksclient
from muranoclient.client import Client as mclient

parser = argparse.ArgumentParser()
parser.add_argument("--user", type=str)
parser.add_argument("--password", type=str)
parser.add_argument("--tenant", type=str)
parser.add_argument("--keystone_url", type=str, default="http://localhost:5000/v2.0/")
parser.add_argument("--murano_url", type=str)
args = parser.parse_args()

keystone_client = ksclient.Client(
    username=args.user, password=args.password, tenant_name=args.tenant, auth_url=args.keystone_url
)

murano_client = mclient("1", endpoint=args.murano_url, token=keystone_client.auth_token)

for env in murano_client.environments.list():
    murano_client.environments.delete(env.id)