OW2 Consortium contrail

Rev

Rev 2691 | Rev 2792 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2691 Rev 2693
1
'''
1
'''
2
Copyright (c) 2010-2012, Contrail consortium.
2
Copyright (c) 2010-2012, Contrail consortium.
3
All rights reserved.
3
All rights reserved.
4

4

5
Redistribution and use in source and binary forms, 
5
Redistribution and use in source and binary forms, 
6
with or without modification, are permitted provided
6
with or without modification, are permitted provided
7
that the following conditions are met:
7
that the following conditions are met:
8

8

9
 1. Redistributions of source code must retain the
9
 1. Redistributions of source code must retain the
10
    above copyright notice, this list of conditions
10
    above copyright notice, this list of conditions
11
    and the following disclaimer.
11
    and the following disclaimer.
12
 2. Redistributions in binary form must reproduce
12
 2. Redistributions in binary form must reproduce
13
    the above copyright notice, this list of 
13
    the above copyright notice, this list of 
14
    conditions and the following disclaimer in the
14
    conditions and the following disclaimer in the
15
    documentation and/or other materials provided
15
    documentation and/or other materials provided
16
    with the distribution.
16
    with the distribution.
17
 3. Neither the name of the <ORGANIZATION> nor the
-
 
-
 
17
 3. Neither the name of the Contrail consortium nor the
18
    names of its contributors may be used to endorse
18
    names of its contributors may be used to endorse
19
    or promote products derived from this software 
19
    or promote products derived from this software 
20
    without specific prior written permission.
20
    without specific prior written permission.
21

21

22
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
22
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
23
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
23
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
24
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
24
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
25
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
26
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
27
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
28
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
29
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
29
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
30
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
30
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
31
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
31
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
32
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
33
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
34
OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34
OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35
POSSIBILITY OF SUCH DAMAGE.
35
POSSIBILITY OF SUCH DAMAGE.
36

36

37

37

38
Created on Mar 9, 2011
38
Created on Mar 9, 2011
39

39

40
@package conpaas.core
40
@package conpaas.core
41
@author: ielhelw
41
@author: ielhelw
42
@file
42
@file
43
'''
43
'''
44

44

45
'''
45
'''
46

46

47
    This class represents the abstraction of a node.
47
    This class represents the abstraction of a node.
48
    A basic node is represented by a vmid and an ip
48
    A basic node is represented by a vmid and an ip
49
    address. This class can be extented with more
49
    address. This class can be extented with more
50
    information about the node, specific to each
50
    information about the node, specific to each
51
    service. 
51
    service. 
52

52

53
'''
53
'''
54
class ServiceNode(object):
54
class ServiceNode(object):
55

55

56
  def __init__(self, vmid, ip, cloud_name):
56
  def __init__(self, vmid, ip, cloud_name):
57
      self.vmid = vmid
57
      self.vmid = vmid
58
      self.ip = ip
58
      self.ip = ip
59
      self.cloud_name = cloud_name
59
      self.cloud_name = cloud_name
60
  
60
  
61
  def __repr__(self):
61
  def __repr__(self):
62
      return 'ServiceNode(vmid=%s, ip=%s)' % (str(self.vmid), self.ip)
62
      return 'ServiceNode(vmid=%s, ip=%s)' % (str(self.vmid), self.ip)
63
  
63
  
64
  def __cmp__(self, other):
64
  def __cmp__(self, other):
65
      if self.vmid == other.vmid and \
65
      if self.vmid == other.vmid and \
66
      self.cloud_name == other.cloud_name: 
66
      self.cloud_name == other.cloud_name: 
67
          return 0
67
          return 0
68
      elif self.vmid < other.vmid: return -1
68
      elif self.vmid < other.vmid: return -1
69
      else: return 1
69
      else: return 1