diff --git a/nova/cloudpipe/pipelib.py b/nova/cloudpipe/pipelib.py index 97a8a777ef8f..073c013d639f 100644 --- a/nova/cloudpipe/pipelib.py +++ b/nova/cloudpipe/pipelib.py @@ -43,14 +43,14 @@ LOG = logging.getLogger(__name__) def is_vpn_image(image_id): - return image_id == CONF.vpn_image_id + return image_id == CONF.cloudpipe.vpn_image_id def _load_boot_script(): - with open(CONF.boot_script_template, "r") as shellfile: + with open(CONF.cloudpipe.boot_script_template, "r") as shellfile: s = string.Template(shellfile.read()) - return s.substitute(dmz_net=CONF.dmz_net, - dmz_mask=CONF.dmz_mask, + return s.substitute(dmz_net=CONF.cloudpipe.dmz_net, + dmz_mask=CONF.cloudpipe.dmz_mask, num_vpn=CONF.cnt_vpn_clients) @@ -93,19 +93,21 @@ class CloudPipe(object): LOG.debug("Launching VPN for %s", context.project_id) key_name = self.setup_key_pair(context) group_name = self.setup_security_group(context) - flavor = flavors.get_flavor_by_name(CONF.vpn_flavor) - instance_name = '%s%s' % (context.project_id, CONF.vpn_key_suffix) + flavor = flavors.get_flavor_by_name(CONF.cloudpipe.vpn_flavor) + instance_name = '%s%s' % (context.project_id, + CONF.cloudpipe.vpn_key_suffix) user_data = self.get_encoded_zip(context.project_id) return self.compute_api.create(context, flavor, - CONF.vpn_image_id, + CONF.cloudpipe.vpn_image_id, display_name=instance_name, user_data=user_data, key_name=key_name, security_group=[group_name]) def setup_security_group(self, context): - group_name = '%s%s' % (context.project_id, CONF.vpn_key_suffix) + group_name = '%s%s' % (context.project_id, + CONF.cloudpipe.vpn_key_suffix) group = {'user_id': context.user_id, 'project_id': context.project_id, 'name': group_name, @@ -131,7 +133,8 @@ class CloudPipe(object): return group_name def setup_key_pair(self, context): - key_name = '%s%s' % (context.project_id, CONF.vpn_key_suffix) + key_name = '%s%s' % (context.project_id, + CONF.cloudpipe.vpn_key_suffix) try: keypair_api = compute.api.KeypairAPI() result, private_key = keypair_api.create_key_pair(context, diff --git a/nova/conf/cloudpipe.py b/nova/conf/cloudpipe.py index bf970e28db07..c58da8618606 100644 --- a/nova/conf/cloudpipe.py +++ b/nova/conf/cloudpipe.py @@ -16,9 +16,14 @@ from oslo_config import cfg from nova.conf import paths +cloudpipe_group = cfg.OptGroup( + name='cloudpipe', + title='Cloudpipe options') + cloudpipe_opts = [ cfg.StrOpt('vpn_image_id', default='0', + deprecated_group='DEFAULT', help=""" Image ID used when starting up a cloudpipe VPN client. @@ -33,6 +38,7 @@ Possible values: """), cfg.StrOpt('vpn_flavor', default='m1.tiny', + deprecated_group='DEFAULT', help=""" Flavor for VPN instances. @@ -42,6 +48,7 @@ Possible values: """), cfg.StrOpt('boot_script_template', default=paths.basedir_def('nova/cloudpipe/bootscript.template'), + deprecated_group='DEFAULT', help=""" Template for cloudpipe instance boot script. @@ -60,6 +67,7 @@ OpenVPN server. """), cfg.IPOpt('dmz_net', default='10.0.0.0', + deprecated_group='DEFAULT', help=""" Network to push into OpenVPN config. @@ -77,6 +85,7 @@ Related options: """), cfg.IPOpt('dmz_mask', default='255.255.255.0', + deprecated_group='DEFAULT', help=""" Netmask to push into OpenVPN config. @@ -92,6 +101,7 @@ Related options: """), cfg.StrOpt('vpn_key_suffix', default='-vpn', + deprecated_group='DEFAULT', help=""" Suffix to add to project name for VPN key and secgroups @@ -103,9 +113,9 @@ Possible values: def register_opts(conf): - conf.register_opts(cloudpipe_opts) + conf.register_group(cloudpipe_group) + conf.register_opts(cloudpipe_opts, group=cloudpipe_group) def list_opts(): - # TODO(siva_krishnan) add opt group - return {'DEFAULT': cloudpipe_opts} + return {cloudpipe_group: cloudpipe_opts} diff --git a/nova/tests/functional/api_sample_tests/test_cloudpipe.py b/nova/tests/functional/api_sample_tests/test_cloudpipe.py index 6b0a9ef4bee9..58ef3a118909 100644 --- a/nova/tests/functional/api_sample_tests/test_cloudpipe.py +++ b/nova/tests/functional/api_sample_tests/test_cloudpipe.py @@ -49,11 +49,11 @@ class CloudPipeSampleTest(api_sample_base.ApiSampleTestBaseV21): def test_cloud_pipe_create(self): # Get api samples of cloud pipe extension creation. - self.flags(vpn_image_id=fake.get_valid_image_id()) + self.flags(vpn_image_id=fake.get_valid_image_id(), group='cloudpipe') subs = {'project_id': str(uuid_lib.uuid4().hex)} response = self._do_post('os-cloudpipe', 'cloud-pipe-create-req', subs) - subs['image_id'] = CONF.vpn_image_id + subs['image_id'] = CONF.cloudpipe.vpn_image_id self._verify_response('cloud-pipe-create-resp', subs, response, 200) return subs @@ -61,7 +61,7 @@ class CloudPipeSampleTest(api_sample_base.ApiSampleTestBaseV21): # Get api samples of cloud pipe extension get request. subs = self.test_cloud_pipe_create() response = self._do_get('os-cloudpipe') - subs['image_id'] = CONF.vpn_image_id + subs['image_id'] = CONF.cloudpipe.vpn_image_id self._verify_response('cloud-pipe-get-resp', subs, response, 200) def test_cloud_pipe_update(self): diff --git a/nova/tests/unit/api/openstack/compute/test_cloudpipe.py b/nova/tests/unit/api/openstack/compute/test_cloudpipe.py index 80beaadb107d..7e92556632c1 100644 --- a/nova/tests/unit/api/openstack/compute/test_cloudpipe.py +++ b/nova/tests/unit/api/openstack/compute/test_cloudpipe.py @@ -38,7 +38,7 @@ uuid = str(uuid_lib.uuid4()) def fake_vpn_instance(): return objects.Instance( - id=7, image_ref=CONF.vpn_image_id, vm_state='active', + id=7, image_ref=CONF.cloudpipe.vpn_image_id, vm_state='active', created_at=timeutils.parse_strtime('1981-10-20T00:00:00.000000'), uuid=uuid, project_id=project_id) diff --git a/nova/tests/unit/test_pipelib.py b/nova/tests/unit/test_pipelib.py index 670ce7161ea3..6748d0d3e935 100644 --- a/nova/tests/unit/test_pipelib.py +++ b/nova/tests/unit/test_pipelib.py @@ -53,7 +53,7 @@ class PipelibTest(test.TestCase): _do_test() def test_setup_security_group(self): - group_name = "%s%s" % (self.project, CONF.vpn_key_suffix) + group_name = "%s%s" % (self.project, CONF.cloudpipe.vpn_key_suffix) # First attempt, does not exist (thus its created) res1_group = self.cloudpipe.setup_security_group(self.context) @@ -64,7 +64,7 @@ class PipelibTest(test.TestCase): self.assertEqual(res1_group, res2_group) def test_setup_key_pair(self): - key_name = "%s%s" % (self.project, CONF.vpn_key_suffix) + key_name = "%s%s" % (self.project, CONF.cloudpipe.vpn_key_suffix) with utils.tempdir() as tmpdir: self.flags(keys_path=tmpdir, group='crypto') diff --git a/releasenotes/notes/add-cloudpipe-config-to-cloudpipe-group-ab96ebcb3ffc5d82.yaml b/releasenotes/notes/add-cloudpipe-config-to-cloudpipe-group-ab96ebcb3ffc5d82.yaml new file mode 100644 index 000000000000..861cbbc7e552 --- /dev/null +++ b/releasenotes/notes/add-cloudpipe-config-to-cloudpipe-group-ab96ebcb3ffc5d82.yaml @@ -0,0 +1,4 @@ +--- +upgrade: + - All cloudpipe configuration options have been added to the 'cloudpipe' + group. They should no longer be included in the 'DEFAULT' group.