File: authenticate.py

package info (click to toggle)
rally-openstack 3.0.0-9
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 8,968 kB
  • sloc: python: 53,131; sh: 262; makefile: 38
file content (190 lines) | stat: -rw-r--r-- 7,744 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
# Copyright 2014 Red Hat, Inc. <http://www.redhat.com>
#
#    Licensed under the Apache License, Version 2.0 (the "License"); you may
#    not use this file except in compliance with the License. You may obtain
#    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.

from rally_openstack.common import consts

from rally.task import atomic
from rally.task import validation

from rally_openstack.task import scenario


"""Scenarios for Authentication mechanism."""


@validation.add("required_platform", platform="openstack", users=True)
@scenario.configure(name="Authenticate.keystone", platform="openstack")
class Keystone(scenario.OpenStackScenario):

    @atomic.action_timer("authenticate.keystone")
    def run(self):
        """Check Keystone Client."""
        self.clients("keystone")


@validation.add("number", param_name="repetitions", minval=1)
@validation.add("required_platform", platform="openstack", users=True)
@scenario.configure(name="Authenticate.validate_glance", platform="openstack")
class ValidateGlance(scenario.OpenStackScenario):

    def run(self, repetitions):
        """Check Glance Client to ensure validation of token.

        Creation of the client does not ensure validation of the token.
        We have to do some minimal operation to make sure token gets validated.
        In following we are checking for non-existent image.

        :param repetitions: number of times to validate
        """
        glance_client = self.clients("glance")
        image_name = "__intentionally_non_existent_image___"
        with atomic.ActionTimer(self, "authenticate.validate_glance"):
            for i in range(repetitions):
                list(glance_client.images.list(name=image_name))


@validation.add("number", param_name="repetitions", minval=1)
@validation.add("required_platform", platform="openstack", users=True)
@scenario.configure(name="Authenticate.validate_nova", platform="openstack")
class ValidateNova(scenario.OpenStackScenario):

    def run(self, repetitions):
        """Check Nova Client to ensure validation of token.

        Creation of the client does not ensure validation of the token.
        We have to do some minimal operation to make sure token gets validated.

        :param repetitions: number of times to validate
        """
        nova_client = self.clients("nova")
        with atomic.ActionTimer(self, "authenticate.validate_nova"):
            for i in range(repetitions):
                nova_client.flavors.list()


@validation.add("number", param_name="repetitions", minval=1)
@validation.add("required_platform", platform="openstack", users=True)
@scenario.configure(name="Authenticate.validate_ceilometer",
                    platform="openstack")
class ValidateCeilometer(scenario.OpenStackScenario):

    def run(self, repetitions):
        """Check Ceilometer Client to ensure validation of token.

        Creation of the client does not ensure validation of the token.
        We have to do some minimal operation to make sure token gets validated.

        :param repetitions: number of times to validate
        """
        ceilometer_client = self.clients("ceilometer")
        with atomic.ActionTimer(self, "authenticate.validate_ceilometer"):
            for i in range(repetitions):
                ceilometer_client.meters.list()


@validation.add("number", param_name="repetitions", minval=1)
@validation.add("required_platform", platform="openstack", users=True)
@scenario.configure(name="Authenticate.validate_cinder", platform="openstack")
class ValidateCinder(scenario.OpenStackScenario):

    def run(self, repetitions):
        """Check Cinder Client to ensure validation of token.

        Creation of the client does not ensure validation of the token.
        We have to do some minimal operation to make sure token gets validated.

        :param repetitions: number of times to validate
        """
        cinder_client = self.clients("cinder")
        with atomic.ActionTimer(self, "authenticate.validate_cinder"):
            for i in range(repetitions):
                cinder_client.volume_types.list()


@validation.add("number", param_name="repetitions", minval=1)
@validation.add("required_platform", platform="openstack", users=True)
@scenario.configure(name="Authenticate.validate_neutron", platform="openstack")
class ValidateNeutron(scenario.OpenStackScenario):

    def run(self, repetitions):
        """Check Neutron Client to ensure validation of token.

        Creation of the client does not ensure validation of the token.
        We have to do some minimal operation to make sure token gets validated.

        :param repetitions: number of times to validate
        """
        neutron_client = self.clients("neutron")
        with atomic.ActionTimer(self, "authenticate.validate_neutron"):
            for i in range(repetitions):
                neutron_client.list_networks()


@validation.add("number", param_name="repetitions", minval=1)
@validation.add("required_platform", platform="openstack", users=True)
@scenario.configure(name="Authenticate.validate_octavia", platform="openstack")
class ValidateOctavia(scenario.OpenStackScenario):

    def run(self, repetitions):
        """Check Octavia Client to ensure validation of token.

        Creation of the client does not ensure validation of the token.
        We have to do some minimal operation to make sure token gets validated.

        :param repetitions: number of times to validate
        """
        octavia_client = self.clients("octavia")
        with atomic.ActionTimer(self, "authenticate.validate_octavia"):
            for i in range(repetitions):
                octavia_client.load_balancer_list()


@validation.add("number", param_name="repetitions", minval=1)
@validation.add("required_platform", platform="openstack", users=True)
@scenario.configure(name="Authenticate.validate_heat", platform="openstack")
class ValidateHeat(scenario.OpenStackScenario):

    def run(self, repetitions):
        """Check Heat Client to ensure validation of token.

        Creation of the client does not ensure validation of the token.
        We have to do some minimal operation to make sure token gets validated.

        :param repetitions: number of times to validate
        """
        heat_client = self.clients("heat")
        with atomic.ActionTimer(self, "authenticate.validate_heat"):
            for i in range(repetitions):
                list(heat_client.stacks.list(limit=0))


@validation.add("number", param_name="repetitions", minval=1)
@validation.add("required_platform", platform="openstack", users=True)
@validation.add("required_services",
                services=[consts.Service.MONASCA])
@scenario.configure(name="Authenticate.validate_monasca", platform="openstack")
class ValidateMonasca(scenario.OpenStackScenario):

    def run(self, repetitions):
        """Check Monasca Client to ensure validation of token.

        Creation of the client does not ensure validation of the token.
        We have to do some minimal operation to make sure token gets validated.

        :param repetitions: number of times to validate
        """
        monasca_client = self.clients("monasca")
        with atomic.ActionTimer(self, "authenticate.validate_monasca"):
            for i in range(repetitions):
                list(monasca_client.metrics.list(limit=0))