:param compute_name: compute container name
:param image: image name
:param command: command to execute
- :param network:
- :return: networks list({"ip": "10.0.0.254/8"}, {"ip": "11.0.0.254/24"})
+ :param network: list of all interface of the vnf, with their parameters (id=id1,ip=x.x.x.x/x),...
+ :return: networks list({"id":"input","ip": "10.0.0.254/8"}, {"id":"output","ip": "11.0.0.254/24"})
"""
# TODO what to return UUID / given name / internal name ?
logging.debug("RPC CALL: compute start")
def start(self, args):
nw_list = list()
if args.get("network") is not None:
- networks = args.get("network").split(",")
- for nw in networks:
- nw_list.append({"ip": nw})
+ nw_list = self._parse_network(args.get("network"))
+
r = self.c.compute_action_start(
args.get("datacenter"),
args.get("name"),
args.get("datacenter"), args.get("name"))
pp.pprint(r)
+ def _parse_network(self, network_str):
+ '''
+ parse the options for all network interfaces of the vnf
+ :param network_str: (id=x,ip=x.x.x.x/x), ...
+ :return: list of dicts [{"id":x,"ip":"x.x.x.x/x"}, ...]
+ '''
+ nw_list = list()
+ networks = network_str[1:-1].split('),(')
+ for nw in networks:
+ nw_dict = dict(tuple(e.split('=')) for e in nw.split(','))
+ nw_list.append(nw_dict)
+
+ return nw_list
+
+
parser = argparse.ArgumentParser(description='son-emu compute')
parser.add_argument(
memswap_limit="%dm" % int(mem_limit) if mem_limit > 0 else None # lets set swap to mem limit for now
)
# connect all given networks
+ # if no --net option is given, network = [{}], so 1 empty dict in the list
+ # this results in 1 default interface with a default ip address
for nw in network:
# TODO we cannot use TCLink here (see: https://github.com/mpeuster/dockernet/issues/3)
self.net.addLink(d, self.switch, params1=nw, cls=Link)