Skip to content

Commit

Permalink
Merge pull request #16 from grycap/devel
Browse files Browse the repository at this point in the history
Devel
  • Loading branch information
micafer authored May 23, 2018
2 parents 70800cb + c6021d4 commit 0bb5359
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 2 deletions.
4 changes: 4 additions & 0 deletions changelog
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,7 @@ RADL 1.10
* Enable to specify a port range in outports: 1:10/tcp.
* New class outpots to store OutPorts data: now network.parseOutPorts returns list of outports objects.
* Fix error getting IP of system in case of two nets and first one does not have an ip assigned.

RADL 1.11

* Fix error adding new aspect with replace option.
2 changes: 1 addition & 1 deletion radl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@


__all__ = ['radl_lex','radl_parse','radl_json','radl']
__version__ = '1.1.0'
__version__ = '1.1.1'
14 changes: 13 additions & 1 deletion radl/radl.py
Original file line number Diff line number Diff line change
Expand Up @@ -1154,7 +1154,10 @@ def add(self, aspect, ifpresent="error"):
if ifpresent == "error":
raise Exception("Aspect with the same id was found.")
elif ifpresent == "replace":
aspect_list.remove(old_aspect[0])
for i, elem in enumerate(aspect_list):
if elem.getId() == old_aspect[0].getId():
del aspect_list[i]
break
aspect_list.append(aspect)
return True
elif ifpresent == "ignore":
Expand Down Expand Up @@ -1233,6 +1236,15 @@ def check(self):
for i in [ f for fs in [self.networks, self.ansible_hosts, self.systems, self.deploys,
self.configures, [self.contextualize]] for f in fs ]:
i.check(self)

snames = [s.name for s in self.systems]
if len(set(snames)) != len(snames):
raise RADLParseException("Some System name duplicated.")

nids = [s.id for s in self.networks]
if len(set(nids)) != len(nids):
raise RADLParseException("Some Network name duplicated.")

return True

def get_system_by_name(self, name):
Expand Down
37 changes: 37 additions & 0 deletions test/TestRADL.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,5 +331,42 @@ def test_radl_with_two_public_nets(self):
r.check()
self.assertEqual(r.getPublicIP(), "10.0.0.1")

def test_add(self):
str_radl1 = """
network public ( outbound = 'yes')
network private ( )
system front (
disk.0.image.url = 'one://some/id' and
cpu.count >= 1 and
net_interface.1.connection = 'private' and
net_interface.0.dns_name = 'front' and
memory.size >= 2048m and
net_interface.0.connection = 'public'
)
system vnode-1 (
)
system vnode-2 (
)
deploy front 1 azure
"""

radl1 = parse_radl(str_radl1)

str_radl2 = """
system vnode-2 (
)
deploy vnode-2 1
"""

radl2 = parse_radl(str_radl2)

s = radl2.systems[0].clone()
radl1.add(s, "replace")
radl1.check()

if __name__ == "__main__":
unittest.main()

0 comments on commit 0bb5359

Please sign in to comment.