allowing cord-tester setup to skip onoscord configuration and adding onf manifest
Change-Id: I6817491b9c876585fb5c47a802a1c3490223b726
diff --git a/src/test/setup/cord-test.py b/src/test/setup/cord-test.py
index 81854d4..4838e49 100755
--- a/src/test/setup/cord-test.py
+++ b/src/test/setup/cord-test.py
@@ -873,7 +873,7 @@
if not synchronizer:
print('Specify synchronizer to use for the ONOS cord instance. Eg: vtn, fabric, cord')
sys.exit(1)
- onos_cord = OnosCord(onos_ip, onos_cord_loc, service_profile, synchronizer)
+ onos_cord = OnosCord(onos_ip, onos_cord_loc, service_profile, synchronizer, skip = test_manifest.skip_onos_restart)
try:
test_server = cord_test_server_start(daemonize = False, cord_test_host = test_host, cord_test_port = test_port,
@@ -1168,7 +1168,7 @@
if not synchronizer:
print('Specify synchronizer to use for the ONOS cord instance. Eg: vtn, fabric, cord')
sys.exit(1)
- onos_cord = OnosCord(onos_ip, onos_cord_loc, service_profile, synchronizer)
+ onos_cord = OnosCord(onos_ip, onos_cord_loc, service_profile, synchronizer, skip = test_manifest.skip_onos_restart)
Container.IMAGE_PREFIX = test_manifest.image_prefix
#don't spawn onos if the user had started it externally
@@ -1236,17 +1236,18 @@
ctlr_addr = ','.join(onos_ips)
print('Onos IP %s' %ctlr_addr)
- if onos_ip is not None:
- print('Installing ONOS cord apps')
- try:
- Onos.install_cord_apps(onos_ip = onos_ip)
- except: pass
+ if not test_manifest.skip_onos_restart:
+ if onos_ip is not None:
+ print('Installing ONOS cord apps')
+ try:
+ Onos.install_cord_apps(onos_ip = onos_ip)
+ except: pass
- print('Installing cord tester ONOS app %s' %args.app)
- try:
- for ip in onos_ips:
- OnosCtrl.install_app(args.app, onos_ip = ip)
- except: pass
+ print('Installing cord tester ONOS app %s' %args.app)
+ try:
+ for ip in onos_ips:
+ OnosCtrl.install_app(args.app, onos_ip = ip)
+ except: pass
if voltha_loc:
#start voltha
@@ -1396,7 +1397,7 @@
if args.onos_cord:
#try restoring the onos cord instance
try:
- onos_cord = OnosCord(args.onos_ip, args.onos_cord, args.service_profile, args.synchronizer, start = False)
+ onos_cord = OnosCord(args.onos_ip, args.onos_cord, args.service_profile, args.synchronizer, start = False, skip = test_manifest.skip_onos_restart)
onos_cord.restore(force = True)
except Exception as e:
print(e)
@@ -1628,6 +1629,8 @@
parser_run.add_argument('-expose-port', '--expose-port', action='store_true',
help='Start ONOS by exposing the controller ports to the host.'
'Add +1 for every other onos/cluster instance when running more than 1 ONOS instances')
+ parser_run.add_argument('-skip-onos-restart', '--skip-onos-restart', action='store_true',
+ help = 'Skips restarting/configuring of onoscord')
parser_run.set_defaults(func=runTest)
parser_setup = subparser.add_parser('setup', help='Setup cord tester environment')
@@ -1683,6 +1686,8 @@
parser_setup.add_argument('-expose-port', '--expose-port', action='store_true',
help='Start ONOS by exposing the controller ports to the host.'
'Add +1 for every other onos/cluster instance when running more than 1 ONOS instances')
+ parser_setup.add_argument('-skip-onos-restart', '--skip-onos-restart', action='store_true',
+ help = 'Skips restarting/configuring of onoscord')
parser_setup.set_defaults(func=setupCordTester)
parser_xos = subparser.add_parser('xos', help='Building xos into cord tester environment')
@@ -1736,6 +1741,8 @@
parser_cleanup.add_argument('-m', '--manifest', default='', type=str, help='Provide test manifest')
parser_cleanup.add_argument('-voltha-loc', '--voltha-loc', default='', type=str,
help='Specify the voltha location')
+ parser_cleanup.add_argument('-skip-onos-restart', '--skip-onos-restart', action='store_true',
+ help = 'Skips restarting/configuring of onoscord')
parser_cleanup.set_defaults(func=cleanupTests)
c = Client(**(kwargs_from_env()))
diff --git a/src/test/setup/manifest-onf-cord.json b/src/test/setup/manifest-onf-cord.json
new file mode 100644
index 0000000..b8445e2
--- /dev/null
+++ b/src/test/setup/manifest-onf-cord.json
@@ -0,0 +1,15 @@
+{
+ "onos_instances": 1,
+ "olt": true,
+ "start_switch": true,
+ "onos_image": "onosproject/onos:latest",
+ "onos" : "172.21.0.2",
+ "onos_cord" : "/opt/onos_cord",
+ "service_profile" : "rcord",
+ "synchronizer" : "vtn",
+ "docker_network" : "onoscord_default",
+ "log_level" : "INFO",
+ "jvm_heap_size" : "1G",
+ "karaf_version" : "3.0.8",
+ "skip_onos_restart": "true"
+}
diff --git a/src/test/setup/olt_config.json b/src/test/setup/olt_config.json
index e744293..35ab577 100644
--- a/src/test/setup/olt_config.json
+++ b/src/test/setup/olt_config.json
@@ -8,13 +8,13 @@
"port" : "fabric", "type" : "reserved", "s_tag" : 222, "c_tag" : 111
},
{
- "port" : "fabric", "type" : "dhcp", "s_tag" : 304, "c_tag" : 304
+ "port" : "fabric", "type" : "reserved", "s_tag" : 333, "c_tag" : 888
},
{
- "port" : "fabric", "type" : "dhcp", "s_tag" : 304, "c_tag" : 305
+ "port" : "fabric", "type" : "reserved", "s_tag" : 555, "c_tag" : 999
},
{
- "port" : "fabric", "type" : "dhcp", "s_tag" : 304, "c_tag" : 306
+ "port" : "fabric", "type" : "reserved", "s_tag" : 666, "c_tag" : 661
},
{
"port" : "fabric", "type" : "dhcp", "s_tag" : 304, "c_tag" : 307
diff --git a/src/test/utils/CordContainer.py b/src/test/utils/CordContainer.py
index 0050eb0..341a4eb 100644
--- a/src/test/utils/CordContainer.py
+++ b/src/test/utils/CordContainer.py
@@ -359,65 +359,66 @@
old_service_profile = '/opt/cord/orchestration/service-profile/cord-pod'
cord_profile = '/opt/cord_profile'
- def __init__(self, onos_ip, conf, service_profile, synchronizer, start = True, boot_delay = 5):
- if not os.access(conf, os.F_OK):
- raise Exception('ONOS cord configuration location %s is invalid' %conf)
- self.old_cord = False
- if os.access(self.old_service_profile, os.F_OK):
- self.old_cord = True
- self.onos_ip = onos_ip
- self.onos_cord_dir = conf
- self.boot_delay = boot_delay
- self.synchronizer = synchronizer
- self.service_profile = service_profile
- self.docker_yaml = os.path.join(conf, 'docker-compose.yml')
- self.docker_yaml_saved = os.path.join(conf, 'docker-compose.yml.saved')
- self.onos_config_dir = os.path.join(conf, 'config')
- self.onos_cfg_save_loc = os.path.join(conf, 'network-cfg.json.saved')
- instance_active = False
- #if we have a wrapper onos instance already active, back out
- if os.access(self.onos_config_dir, os.F_OK) or os.access(self.docker_yaml_saved, os.F_OK):
- instance_active = True
- else:
- if start is True:
- os.mkdir(self.onos_config_dir)
- shutil.copy(self.docker_yaml, self.docker_yaml_saved)
+ def __init__(self, onos_ip, conf, service_profile, synchronizer, start = True, boot_delay = 5, skip = False):
+ if not skip:
+ if not os.access(conf, os.F_OK):
+ raise Exception('ONOS cord configuration location %s is invalid' %conf)
+ self.old_cord = False
+ if os.access(self.old_service_profile, os.F_OK):
+ self.old_cord = True
+ self.onos_ip = onos_ip
+ self.onos_cord_dir = conf
+ self.boot_delay = boot_delay
+ self.synchronizer = synchronizer
+ self.service_profile = service_profile
+ self.docker_yaml = os.path.join(conf, 'docker-compose.yml')
+ self.docker_yaml_saved = os.path.join(conf, 'docker-compose.yml.saved')
+ self.onos_config_dir = os.path.join(conf, 'config')
+ self.onos_cfg_save_loc = os.path.join(conf, 'network-cfg.json.saved')
+ instance_active = False
+ #if we have a wrapper onos instance already active, back out
+ if os.access(self.onos_config_dir, os.F_OK) or os.access(self.docker_yaml_saved, os.F_OK):
+ instance_active = True
+ else:
+ if start is True:
+ os.mkdir(self.onos_config_dir)
+ shutil.copy(self.docker_yaml, self.docker_yaml_saved)
- self.start_wrapper = instance_active is False and start is True
- ##update the docker yaml with the config volume
- with open(self.docker_yaml, 'r') as f:
- yaml_config = yaml.load(f)
- image = yaml_config['services'].keys()[0]
- cord_conf_dir_basename = os.path.basename(self.onos_cord_dir.replace('-', '').replace('_', ''))
- xos_onos_name = '{}_{}_1'.format(cord_conf_dir_basename, image)
- if not yaml_config['services'][image].has_key('volumes'):
- yaml_config['services'][image]['volumes'] = []
- volumes = yaml_config['services'][image]['volumes']
- config_volumes = filter(lambda e: e.find(self.onos_config_dir_guest) >= 0, volumes)
- if not config_volumes:
- config_volume = '{}:{}'.format(self.onos_config_dir, self.onos_config_dir_guest)
- volumes.append(config_volume)
- if self.start_wrapper:
- docker_yaml_changed = '{}-changed'.format(self.docker_yaml)
- with open(docker_yaml_changed, 'w') as wf:
- yaml.dump(yaml_config, wf)
- os.rename(docker_yaml_changed, self.docker_yaml)
- self.volumes = volumes
+ self.start_wrapper = instance_active is False and start is True
+ ##update the docker yaml with the config volume
+ with open(self.docker_yaml, 'r') as f:
+ yaml_config = yaml.load(f)
+ image = yaml_config['services'].keys()[0]
+ cord_conf_dir_basename = os.path.basename(self.onos_cord_dir.replace('-', '').replace('_', ''))
+ xos_onos_name = '{}_{}_1'.format(cord_conf_dir_basename, image)
+ if not yaml_config['services'][image].has_key('volumes'):
+ yaml_config['services'][image]['volumes'] = []
+ volumes = yaml_config['services'][image]['volumes']
+ config_volumes = filter(lambda e: e.find(self.onos_config_dir_guest) >= 0, volumes)
+ if not config_volumes:
+ config_volume = '{}:{}'.format(self.onos_config_dir, self.onos_config_dir_guest)
+ volumes.append(config_volume)
+ if self.start_wrapper:
+ docker_yaml_changed = '{}-changed'.format(self.docker_yaml)
+ with open(docker_yaml_changed, 'w') as wf:
+ yaml.dump(yaml_config, wf)
+ os.rename(docker_yaml_changed, self.docker_yaml)
+ self.volumes = volumes
- ##Create an container instance of xos onos
- super(OnosCord, self).__init__(xos_onos_name, image, tag = '', quagga_config = Onos.QUAGGA_CONFIG)
- self.last_cfg = None
- if self.start_wrapper:
- #fetch the current config of onos cord instance and save it
- try:
- self.last_cfg = OnosCtrl.get_config(controller = onos_ip)
- json_data = json.dumps(self.last_cfg, indent=4)
- with open(self.onos_cfg_save_loc, 'w') as f:
- f.write(json_data)
- except:
- pass
- #start the container back with the shared onos config volume
- self.start()
+ ##Create an container instance of xos onos
+ super(OnosCord, self).__init__(xos_onos_name, image, tag = '', quagga_config = Onos.QUAGGA_CONFIG)
+ self.last_cfg = None
+ if self.start_wrapper:
+ #fetch the current config of onos cord instance and save it
+ try:
+ self.last_cfg = OnosCtrl.get_config(controller = onos_ip)
+ json_data = json.dumps(self.last_cfg, indent=4)
+ with open(self.onos_cfg_save_loc, 'w') as f:
+ f.write(json_data)
+ except:
+ pass
+ #start the container back with the shared onos config volume
+ self.start()
def cliEnter(self):
retries = 0
diff --git a/src/test/utils/TestManifest.py b/src/test/utils/TestManifest.py
index 5d29f37..72876f4 100644
--- a/src/test/utils/TestManifest.py
+++ b/src/test/utils/TestManifest.py
@@ -72,6 +72,7 @@
self.voltha_enable = args.voltha_enable
self.voltha_container_mode = args.voltha_container_mode
self.expose_port = args.expose_port
+ self.skip_onos_restart = args.skip_onos_restart
else:
with open(self.manifest, 'r') as fd:
data = json.load(fd)
@@ -109,3 +110,4 @@
self.expose_port = data.get('expose_port', False)
if self.voltha_enable and self.voltha_container_mode:
self.expose_port = True
+ self.skip_onos_restart = data.get('skip_onos_restart', False)