File: availability_zones.py

package info (click to toggle)
python-novaclient 2%3A18.12.0-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 2,856 kB
  • sloc: python: 24,300; makefile: 24; sh: 13
file content (91 lines) | stat: -rw-r--r-- 3,226 bytes parent folder | download | duplicates (6)
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
# 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 novaclient.tests.unit.fixture_data import base


class V1(base.Fixture):

    base_url = 'os-availability-zone'

    zone_info_key = 'availabilityZoneInfo'
    zone_name_key = 'zoneName'
    zone_state_key = 'zoneState'

    def setUp(self):
        super(V1, self).setUp()

        get_os_availability_zone = {
            self.zone_info_key: [
                {
                    self.zone_name_key: "zone-1",
                    self.zone_state_key: {"available": True},
                    "hosts": None
                },
                {
                    self.zone_name_key: "zone-2",
                    self.zone_state_key: {"available": False},
                    "hosts": None
                }
            ]
        }

        self.requests_mock.get(self.url(),
                               json=get_os_availability_zone,
                               headers=self.json_headers)

        get_os_zone_detail = {
            self.zone_info_key: [
                {
                    self.zone_name_key: "zone-1",
                    self.zone_state_key: {"available": True},
                    "hosts": {
                        "fake_host-1": {
                            "nova-compute": {
                                "active": True,
                                "available": True,
                                "updated_at": '2012-12-26 14:45:25'
                            }
                        }
                    }
                },
                {
                    self.zone_name_key: "internal",
                    self.zone_state_key: {"available": True},
                    "hosts": {
                        "fake_host-1": {
                            "nova-sched": {
                                "active": True,
                                "available": True,
                                "updated_at": '2012-12-26 14:45:25'
                            }
                        },
                        "fake_host-2": {
                            "nova-network": {
                                "active": True,
                                "available": False,
                                "updated_at": '2012-12-26 14:45:24'
                            }
                        }
                    }
                },
                {
                    self.zone_name_key: "zone-2",
                    self.zone_state_key: {"available": False},
                    "hosts": None
                }
            ]
        }

        self.requests_mock.get(self.url('detail'),
                               json=get_os_zone_detail,
                               headers=self.json_headers)