summaryrefslogtreecommitdiffstats
path: root/nova
diff options
context:
space:
mode:
authorAndy Southgate <andy.southgate@citrix.com>2011-02-15 12:15:49 +0000
committerAndy Southgate <andy.southgate@citrix.com>2011-02-15 12:15:49 +0000
commit2dfcfccd74821851c965ee2912fd315e25e7f838 (patch)
tree564c9545b44fa82aacb3ebb51d961a902612bd56 /nova
parent46456155d42dd8a668b370fa84972c388094e1d8 (diff)
OS-55: Moved conn_common code into disk.py
Diffstat (limited to 'nova')
-rw-r--r--nova/virt/conn_common.py51
-rw-r--r--nova/virt/disk.py27
-rw-r--r--nova/virt/libvirt_conn.py3
-rw-r--r--nova/virt/xenapi/vm_utils.py3
4 files changed, 29 insertions, 55 deletions
diff --git a/nova/virt/conn_common.py b/nova/virt/conn_common.py
deleted file mode 100644
index 5550b50c1..000000000
--- a/nova/virt/conn_common.py
+++ /dev/null
@@ -1,51 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright (c) 2010 Citrix Systems, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from nova import context
-from nova import db
-from nova import exception
-from nova import flags
-from nova import log as logging
-from nova import utils
-
-LOG = logging.getLogger('nova.virt.conn_common')
-FLAGS = flags.FLAGS
-
-flags.DEFINE_string('injected_network_template',
- utils.abspath('virt/interfaces.template'),
- 'Template file for injected network')
-
-
-def get_injectables(inst):
- key = str(inst['key_data'])
- net = None
- network_ref = db.network_get_by_instance(context.get_admin_context(),
- inst['id'])
- if network_ref['injected']:
- admin_context = context.get_admin_context()
- address = db.instance_get_fixed_address(admin_context, inst['id'])
- ra_server = network_ref['ra_server']
- if not ra_server:
- ra_server = "fd00::"
- with open(FLAGS.injected_network_template) as f:
- net = f.read() % {'address': address,
- 'netmask': network_ref['netmask'],
- 'gateway': network_ref['gateway'],
- 'broadcast': network_ref['broadcast'],
- 'dns': network_ref['dns'],
- 'ra_server': ra_server}
-
- return key, net
diff --git a/nova/virt/disk.py b/nova/virt/disk.py
index 98121df2a..cee1ffbce 100644
--- a/nova/virt/disk.py
+++ b/nova/virt/disk.py
@@ -26,6 +26,8 @@ import os
import tempfile
import time
+from nova import context
+from nova import db
from nova import exception
from nova import flags
from nova import log as logging
@@ -38,6 +40,9 @@ flags.DEFINE_integer('minimum_root_size', 1024 * 1024 * 1024 * 10,
'minimum size in bytes of root partition')
flags.DEFINE_integer('block_size', 1024 * 1024 * 256,
'block_size to use for dd')
+flags.DEFINE_string('injected_network_template',
+ utils.abspath('virt/interfaces.template'),
+ 'Template file for injected network')
def extend(image, size):
@@ -155,6 +160,28 @@ def _free_device(device):
_DEVICES.append(device)
+def get_injectables(inst):
+ key = str(inst['key_data'])
+ net = None
+ network_ref = db.network_get_by_instance(context.get_admin_context(),
+ inst['id'])
+ if network_ref['injected']:
+ admin_context = context.get_admin_context()
+ address = db.instance_get_fixed_address(admin_context, inst['id'])
+ ra_server = network_ref['ra_server']
+ if not ra_server:
+ ra_server = "fd00::"
+ with open(FLAGS.injected_network_template) as f:
+ net = f.read() % {'address': address,
+ 'netmask': network_ref['netmask'],
+ 'gateway': network_ref['gateway'],
+ 'broadcast': network_ref['broadcast'],
+ 'dns': network_ref['dns'],
+ 'ra_server': ra_server}
+
+ return key, net
+
+
def inject_data_into_fs(fs, key, net, execute):
"""Injects data into a filesystem already mounted by the caller.
Virt connections can call this directly if they mount their fs
diff --git a/nova/virt/libvirt_conn.py b/nova/virt/libvirt_conn.py
index 45d8754ab..806f35a81 100644
--- a/nova/virt/libvirt_conn.py
+++ b/nova/virt/libvirt_conn.py
@@ -62,7 +62,6 @@ from nova.compute import instance_types
from nova.compute import power_state
from nova.virt import disk
from nova.virt import images
-from nova.virt import conn_common
libvirt = None
libxml2 = None
@@ -621,7 +620,7 @@ class LibvirtConnection(object):
if not inst['kernel_id']:
target_partition = "1"
- key, net = conn_common.get_injectables(inst)
+ key, net = disk.get_injectables(inst)
if key or net:
inst_name = inst['name']
diff --git a/nova/virt/xenapi/vm_utils.py b/nova/virt/xenapi/vm_utils.py
index fa60c44c3..603cef1f6 100644
--- a/nova/virt/xenapi/vm_utils.py
+++ b/nova/virt/xenapi/vm_utils.py
@@ -41,7 +41,6 @@ from nova.compute import power_state
from nova.virt import disk
from nova.virt import images
from nova.virt.xenapi import HelperBase
-from nova.virt import conn_common
from nova.virt.xenapi.volume_utils import StorageError
@@ -453,7 +452,7 @@ class VMHelper(HelperBase):
# if at all, so determine whether it's required first, and then do
# everything
mount_required = False
- key, net = conn_common.get_injectables(instance)
+ key, net = disk.get_injectables(instance)
if key is not None or net is not None:
mount_required = True