summaryrefslogtreecommitdiff
path: root/nova/cloudpipe
diff options
context:
space:
mode:
authorMark McLoughlin <markmc@redhat.com>2013-01-08 08:13:12 +0000
committerMark McLoughlin <markmc@redhat.com>2013-01-09 08:15:43 +0000
commit39a46f48bfcaae1ca4500ba145c1c08c6bf009f1 (patch)
treee6c6ea5637c8d1d2fc90b93cdce345ad71a0d6f2 /nova/cloudpipe
parent41ef13a34c4fa41052ae72cc87e552dfd8ed91ba (diff)
downloadnova-39a46f48bfcaae1ca4500ba145c1c08c6bf009f1.tar.gz
Move vpn_image_id to pipelib
Apart from checking whether a given image is the cloudpipe image, the vpn_image_id option is only used within pipelib itself. Add a is_vpn_image() helper method and move the option into pipelib. Some rejiggering of how pipelib imports ec2 opts is required to avoid circular imports. blueprint: scope-config-opts Change-Id: Ie984b2bb81681c24d3cee803082960083992a535
Diffstat (limited to 'nova/cloudpipe')
-rw-r--r--nova/cloudpipe/pipelib.py38
1 files changed, 26 insertions, 12 deletions
diff --git a/nova/cloudpipe/pipelib.py b/nova/cloudpipe/pipelib.py
index c165b44ffb..19cbf32535 100644
--- a/nova/cloudpipe/pipelib.py
+++ b/nova/cloudpipe/pipelib.py
@@ -39,6 +39,9 @@ from nova import utils
cloudpipe_opts = [
+ cfg.StrOpt('vpn_image_id',
+ default='0',
+ help='image id used when starting up a cloudpipe vpn server'),
cfg.StrOpt('vpn_instance_type',
default='m1.tiny',
help=_('Instance type for vpn instances')),
@@ -55,15 +58,33 @@ cloudpipe_opts = [
CONF = cfg.CONF
CONF.register_opts(cloudpipe_opts)
-CONF.import_opt('ec2_dmz_host', 'nova.api.ec2.cloud')
-CONF.import_opt('ec2_port', 'nova.api.ec2.cloud')
-CONF.import_opt('vpn_image_id', 'nova.config')
CONF.import_opt('vpn_key_suffix', 'nova.config')
-CONF.import_opt('cnt_vpn_clients', 'nova.network.manager')
LOG = logging.getLogger(__name__)
+def is_vpn_image(image_id):
+ return image_id == CONF.vpn_image_id
+
+
+def _load_boot_script():
+ shellfile = open(CONF.boot_script_template, "r")
+ try:
+ s = string.Template(shellfile.read())
+ finally:
+ shellfile.close()
+
+ CONF.import_opt('ec2_dmz_host', 'nova.api.ec2.cloud')
+ CONF.import_opt('ec2_port', 'nova.api.ec2.cloud')
+ CONF.import_opt('cnt_vpn_clients', 'nova.network.manager')
+
+ return s.substitute(cc_dmz=CONF.ec2_dmz_host,
+ cc_port=CONF.ec2_port,
+ dmz_net=CONF.dmz_net,
+ dmz_mask=CONF.dmz_mask,
+ num_vpn=CONF.cnt_vpn_clients)
+
+
class CloudPipe(object):
def __init__(self):
self.compute_api = compute.API()
@@ -74,14 +95,7 @@ class CloudPipe(object):
filename = "payload.zip"
zippath = os.path.join(tmpdir, filename)
z = zipfile.ZipFile(zippath, "w", zipfile.ZIP_DEFLATED)
- shellfile = open(CONF.boot_script_template, "r")
- s = string.Template(shellfile.read())
- shellfile.close()
- boot_script = s.substitute(cc_dmz=CONF.ec2_dmz_host,
- cc_port=CONF.ec2_port,
- dmz_net=CONF.dmz_net,
- dmz_mask=CONF.dmz_mask,
- num_vpn=CONF.cnt_vpn_clients)
+ boot_script = _load_boot_script()
# genvpn, sign csr
crypto.generate_vpn_files(project_id)
z.writestr('autorun.sh', boot_script)