~hopem/nova/precise-updates-sru-lp1119248

« back to all changes in this revision

Viewing changes to nova/scheduler/filters/affinity_filter.py

  • Committer: Package Import Robot
  • Author(s): Adam Gandelman
  • Date: 2012-08-27 14:50:40 UTC
  • mfrom: (79.1.3 precise-proposed)
  • Revision ID: package-import@ubuntu.com-20120827145040-vlkdab5i0smvnhei
Tags: 2012.1.3+stable-20120827-4d2a4afe-0ubuntu1
* New upstream snapshot, fixes FTBFS in -proposed. (LP: #1041120)
* Resynchronize with stable/essex (4d2a4afe):
  - [5d63601] Inappropriate exception handling on kvm live/block migration
    (LP: #917615)
  - [ae280ca] Deleted floating ips can cause instance delete to fail
    (LP: #1038266)

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
 
39
39
    def host_passes(self, host_state, filter_properties):
40
40
        context = filter_properties['context']
41
 
        scheduler_hints = filter_properties['scheduler_hints']
 
41
        scheduler_hints = filter_properties.get('scheduler_hints') or {}
42
42
        me = host_state.host
43
43
 
44
 
        all_hosts = self._all_hosts(context)
45
44
        affinity_uuids = scheduler_hints.get('different_host', [])
46
45
        if affinity_uuids:
 
46
            all_hosts = self._all_hosts(context)
47
47
            return not any([i for i in affinity_uuids
48
48
                              if all_hosts.get(i) == me])
49
49
        # With no different_host key
57
57
 
58
58
    def host_passes(self, host_state, filter_properties):
59
59
        context = filter_properties['context']
60
 
        scheduler_hints = filter_properties['scheduler_hints']
 
60
        scheduler_hints = filter_properties.get('scheduler_hints') or {}
61
61
        me = host_state.host
62
62
 
63
 
        all_hosts = self._all_hosts(context)
64
63
        affinity_uuids = scheduler_hints.get('same_host', [])
65
64
        if affinity_uuids:
 
65
            all_hosts = self._all_hosts(context)
66
66
            return any([i for i in affinity_uuids
67
67
                          if all_hosts.get(i) == me])
68
68
        # With no same_host key
71
71
 
72
72
class SimpleCIDRAffinityFilter(AffinityFilter):
73
73
    def host_passes(self, host_state, filter_properties):
74
 
        scheduler_hints = filter_properties['scheduler_hints']
 
74
        scheduler_hints = filter_properties.get('scheduler_hints') or {}
75
75
 
76
76
        affinity_cidr = scheduler_hints.get('cidr', '/24')
77
77
        affinity_host_addr = scheduler_hints.get('build_near_host_ip')