Package yakumo :: Package smoketests :: Module st55_host_aggregate_admin
[hide private]
[frames] | no frames]

Source Code for Module yakumo.smoketests.st55_host_aggregate_admin

 1  #!/usr/bin/env python 
 2  # 
 3  # Copyright 2014-2017 by Akira Yoshiyama <akirayoshiyama@gmail.com>. 
 4  # All Rights Reserved. 
 5  # 
 6  #    Licensed under the Apache License, Version 2.0 (the "License"); you may 
 7  #    not use this file except in compliance with the License. You may obtain 
 8  #    a copy of the License at 
 9  # 
10  #         http://www.apache.org/licenses/LICENSE-2.0 
11  # 
12  #    Unless required by applicable law or agreed to in writing, software 
13  #    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 
14  #    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 
15  #    License for the specific language governing permissions and limitations 
16  #    under the License. 
17  """Compute API Test (Host Aggregates)""" 
18   
19   
20  import time 
21   
22  from yakumo.smoketest import * 
23  from yakumo import utils 
24   
25   
26 -def main(c, **kwargs):
27 28 metadata = {'foo': 'bar', 'foo2': 'bar2'} 29 LOG.info("Metadata: %s", metadata) 30 31 hosts = [_.host for _ in c.nova.service.find(binary='nova-compute')] 32 33 LOG.info("Create Aggregate #1") 34 name = get_random_str('aggregate') 35 with c.aggregate.create(name=name, 36 availability_zone='foo', 37 metadata=metadata) as a: 38 39 LOG.debug("list aggregates: %s", [_.name for _ in c.aggregate.list()]) 40 41 test("Aggregate #1 name is " + name, a.name == name) 42 test("Aggregate #1 is availability_zone", 43 a.availability_zone == 'foo') 44 45 LOG.debug("Initial metadata: %s", a.metadata) 46 test("Metadata has %s" % metadata, a.metadata == metadata) 47 48 m = {'foo2': 'bar4', 'foo3': 'bar3'} 49 LOG.debug("Set metadata : %s", m) 50 metadata.update(m) 51 a.set_metadata(**m) 52 LOG.debug("Updated metadata: %s", a.metadata) 53 test("Metadata has %s" % metadata, a.metadata == metadata) 54 55 m = ['foo', 'foo2'] 56 LOG.debug("Unset metadata : %s", m) 57 for key in m: 58 metadata.pop(key) 59 a.unset_metadata(*m) 60 LOG.debug("Updated metadata: %s", a.metadata) 61 test("Metadata has %s" % metadata, a.metadata == metadata) 62 63 LOG.debug("Initial hosts: %s", a.hosts) 64 65 LOG.debug("Register hosts: %s", hosts) 66 a.add_hosts(*hosts) 67 LOG.debug("Updated hosts: %s", a.hosts) 68 test("Aggregate has hosts: %s" % hosts, a.hosts == hosts) 69 70 LOG.debug("Unregister hosts: %s", hosts) 71 a.remove_hosts(*hosts) 72 LOG.debug("Updated hosts: %s", a.hosts) 73 test("Aggregate has no hosts", a.hosts == []) 74 75 test("Aggregate #1 is deleted", a not in c.server.list())
76 77 78 if __name__ == '__main__': 79 c = utils.get_client() 80 81 LOG.debug("list aggregates: %s", [_.name for _ in c.aggregate.list()]) 82 main(c) 83 LOG.debug("list aggregates: %s", [_.name for _ in c.aggregate.list()]) 84 85 show_test_summary() 86