Skip to content

Commit

Permalink
Merge pull request #93 from grycap/devel
Browse files Browse the repository at this point in the history
Fix update op
  • Loading branch information
micafer authored Oct 4, 2021
2 parents 8be4079 + 564a531 commit fe3208a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion ec3
Original file line number Diff line number Diff line change
Expand Up @@ -1789,7 +1789,7 @@ class CmdUpdate:
parser.add_argument("clustername", help="name of the cluster")
parser.add_argument("--add", action="append", help="add a piece of RADL")
parser.add_argument("-a", "--auth-file", type=argparse.FileType('r'), dest="auth_file", nargs=1, help="append new entries to the authorization file")
parser.set_defaults(func=CmdReconfigure.run)
parser.set_defaults(func=CmdUpdate.run)

@staticmethod
def run(options):
Expand Down
7 changes: 4 additions & 3 deletions templates/kubernetes.radl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ network private ()

system front (
cpu.count>=2 and
memory.size>=2048m and
memory.size>=4g and
net_interface.0.connection = 'private' and
net_interface.0.dns_name = 'kubeserver' and
net_interface.1.connection = 'public' and
Expand Down Expand Up @@ -69,8 +69,9 @@ configure front (
)

system wn (
memory.size>=2048m and
net_interface.0.connection='private'
memory.size>=4g and
net_interface.0.connection='private' and
ec3_node_type = 'wn'
)

configure wn (
Expand Down
12 changes: 8 additions & 4 deletions test/test_ec3.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
sys.path.append(".")

from IM2.radl.radl import RADL, system, network
from IM2.radl.radl_parse import parse_radl
from ec3 import ClusterStore, CLI, CmdLaunch, CmdList, CmdTemplates, CmdDestroy, CmdReconfigure, CmdClone, CmdStop, CmdRestart, CmdSsh, CmdUpdate

cluster_data = """system front (
Expand Down Expand Up @@ -551,10 +552,9 @@ def test_ssh(self, display, cluster_store):
@patch('ec3.ClusterStore')
@patch('ec3.CLI.display')
def test_update(self, display, cluster_store, requests):
Options = namedtuple('Options', ['restapi', 'json', 'clustername', 'reload', 'yes',
'auth_file', 'add', 'new_template', 'force'])
options = Options(restapi=['http://server.com:8800'], json=False, clustername='name', reload=False, yes=True,
auth_file=[], add=["system wn ( cpu.count = 4 )"], new_template=None, force=False)
Options = namedtuple('Options', ['restapi', 'clustername', 'auth_file', 'add'])
options = Options(restapi=['http://server.com:8800'], clustername='name',
auth_file=[], add=["system wn ( cpu.count = 4 )"])

cluster_store.list.return_value = ["name"]
radl, _ = self.gen_radl()
Expand All @@ -567,6 +567,10 @@ def test_update(self, display, cluster_store, requests):
with self.assertRaises(SystemExit) as ex:
CmdUpdate.run(options)
self.assertEquals("0" ,str(ex.exception))
self.assertEquals(requests.call_args_list[0][0][0], "POST")
self.assertEquals(requests.call_args_list[0][0][1], "http://server.com/infrastructures/infid")
radlo = parse_radl(requests.call_args_list[0][1]['data'])
self.assertEquals(radlo.get(system("wn")).getValue("cpu.count"), 4)

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

0 comments on commit fe3208a

Please sign in to comment.