def __init__(self, dcs):
self.dcs = dcs
- def compute_action_start(self, dc_label, compute_name, image, network=None, command=None):
+ def compute_action_start(self, dc_label, compute_name, image, network, command):
"""
- Start a new compute instance: A docker container
+ Start a new compute instance: A docker container (note: zerorpc does not support keyword arguments)
:param dc_label: name of the DC
:param compute_name: compute container name
:param image: image name
"""
# TODO what to return UUID / given name / internal name ?
logging.debug("RPC CALL: compute start")
+ logging.info('nwlist2: {0}'.format(network))
try:
c = self.dcs.get(dc_label).startCompute(
compute_name, image=image, command=command, network=network)
logging.exception("RPC error.")
return ex.message
+ def compute_profile(self, dc_label, compute_name, image, kwargs):
+ # note: zerorpc does not support keyword arguments
+
+ # start vnf
+ vnf_status = self.compute_action_start(self, dc_label, compute_name, image,
+ kwargs.get('network'),
+ kwargs.get('command'))
+
+ # start traffic source (with fixed ip addres, no use for now...)
+ self.compute_action_start(self, dc_label, 'psrc', 'profile_source', [{'id':'output','ip':'10.0.10.1/24'}], None)
+
+
+
+
+
def datacenter_list(self):
logging.debug("RPC CALL: datacenter list")
try:
except Exception as ex:
logging.exception("RPC error.")
return ex.message
+
+'''
+if __name__ == "__main__":
+ test = MultiDatacenterApi({})
+ test.compute_profile('dc1','vnf1', 'image',network='',command='test',other='other')
+'''
+
logging.exception("RPC error.")
return ex.message
+
+
if args.get("network") is not None:
nw_list = self._parse_network(args.get("network"))
+ pp.pprint('nwlist1: {0}'.format(nw_list))
+
r = self.c.compute_action_start(
args.get("datacenter"),
args.get("name"),
args.get("image"),
- network=nw_list,
- command=args.get("docker_command")
+ nw_list,
+ args.get("docker_command")
)
pp.pprint(r)
args.get("datacenter"), args.get("name"))
pp.pprint(r)
+ def profile(self, args):
+ nw_list = list()
+ if args.get("network") is not None:
+ nw_list = self._parse_network(args.get("network"))
+ logging.info('nwlist: {0}'.format(nw_list))
+ r = self.c.compute_profile(
+ args.get("datacenter"),
+ args.get("name"),
+ args.get("image"),
+ network=nw_list,
+ command=args.get("docker_command"),
+ input=args.get("input"),
+ output=args.get("output")
+ )
+ pp.pprint(r)
+
def _parse_network(self, network_str):
'''
parse the options for all network interfaces of the vnf
"--net", dest="network",
help="Network properties of compute instance e.g. \
'10.0.0.123/8' or '10.0.0.123/8,11.0.0.123/24' for multiple interfaces.")
+parser.add_argument(
+ "--input", "-in", dest="input",
+ help="input interface of the vnf to profile")
+parser.add_argument(
+ "--output", "-out", dest="output",
+ help="output interface of the vnf to profile")
def main(argv):
"--metric", "-m", dest="metric",\r
help="tx_bytes, rx_bytes, tx_packets, rx_packets")\r
\r
+\r
def main(argv):\r
#print "This is the son-emu monitor CLI."\r
#print "Arguments: %s" % str(argv)\r
# 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
+ logging.info('nwlist: {0}'.format(network))
for nw in network:
# TODO we cannot use TCLink here (see: https://github.com/mpeuster/dockernet/issues/3)
+ logging.info('nw: {0}'.format(nw))
self.net.addLink(d, self.switch, params1=nw, cls=Link)
# do bookkeeping
self.containers[name] = d