Added new ability to specify the network interface and changes for this.
Made force mode by default on (since I think this is what people will want).
This commit is contained in:
@@ -34,6 +34,9 @@ rabbit_host = ${RABBIT_HOST:-$(host:ip)}
|
||||
# Sys log enabled or not
|
||||
syslog = 0
|
||||
|
||||
# Which net interface to attempt to detect an ip on
|
||||
net_interface = eth0
|
||||
|
||||
[host]
|
||||
|
||||
# Set api host endpoint
|
||||
|
||||
@@ -21,9 +21,11 @@ import ConfigParser
|
||||
from devstack import env
|
||||
from devstack import exceptions as excp
|
||||
from devstack import log as logging
|
||||
from devstack import settings
|
||||
from devstack import shell as sh
|
||||
from devstack import utils
|
||||
|
||||
|
||||
LOG = logging.getLogger("devstack.cfg")
|
||||
PW_TMPL = "Enter a password for %s: "
|
||||
ENV_PAT = re.compile(r"^\s*\$\{([\w\d]+):\-(.*)\}\s*$")
|
||||
@@ -90,8 +92,10 @@ class EnvConfigParser(ConfigParser.RawConfigParser):
|
||||
return value_gotten
|
||||
if section == 'host' and option == 'ip':
|
||||
LOG.debug("Host ip from configuration/environment was empty, programatically attempting to determine it.")
|
||||
host_ip = utils.get_host_ip()
|
||||
LOG.debug("Determined host ip to be: \"%s\"" % (host_ip))
|
||||
netifc = self.get("default", "net_interface") or "eth0"
|
||||
netifc = netifc.strip()
|
||||
host_ip = utils.get_host_ip(netifc, settings.IPV4)
|
||||
LOG.debug("Determined host ip to be: \"%s\" from network interface: %s" % (host_ip, netifc))
|
||||
return host_ip
|
||||
elif section == 'passwords':
|
||||
key = self._makekey(section, option)
|
||||
|
||||
@@ -41,7 +41,7 @@ CFG_SECTION = 'DEFAULT'
|
||||
#this db will be dropped and created
|
||||
DB_NAME = "glance"
|
||||
|
||||
#special subcomponents that is used in starting to know that images should be uploaded
|
||||
#special subcomponents/options that are used in starting to know that images should be uploaded
|
||||
IMG_START = "upload-images"
|
||||
|
||||
#what to start
|
||||
@@ -181,9 +181,12 @@ def describe(opts=None):
|
||||
{description}
|
||||
Component options:
|
||||
{component_opts}
|
||||
"""
|
||||
copts = """
|
||||
{img_upload} - uploads test images to glance.
|
||||
"""
|
||||
params = dict()
|
||||
params['component_opts'] = "TBD"
|
||||
params['component_opts'] = copts.strip("\n").format(img_upload=IMG_START)
|
||||
params['module_name'] = __name__
|
||||
params['description'] = __doc__ or "Handles actions for the glance component."
|
||||
out = description.format(**params)
|
||||
|
||||
@@ -75,8 +75,8 @@ def parse():
|
||||
stop_un_group.add_option("-f", "--force",
|
||||
action="store_true",
|
||||
dest="force",
|
||||
help="force ACTION even if no trace file found",
|
||||
default=False)
|
||||
help="force ACTION even if no trace file found (default: %default)",
|
||||
default=True)
|
||||
parser.add_option_group(stop_un_group)
|
||||
|
||||
misc_group = OptionGroup(parser, "Miscellaneous options")
|
||||
|
||||
@@ -37,8 +37,6 @@ POST_INSTALL = 'post-install'
|
||||
# Default interfaces for network ip detection
|
||||
IPV4 = 'IPv4'
|
||||
IPV6 = 'IPv6'
|
||||
DEFAULT_NET_INTERFACE = 'eth0'
|
||||
DEFAULT_NET_INTERFACE_IP_VERSION = IPV4
|
||||
|
||||
# Component name mappings
|
||||
NOVA = "nova"
|
||||
|
||||
@@ -59,7 +59,7 @@ def execute(*cmd, **kwargs):
|
||||
LOG.debug('Running shell cmd: [%s]' % (str_cmd))
|
||||
else:
|
||||
execute_cmd = cmd
|
||||
LOG.debug('Running cmd: [%s]' % (' '.join(str_cmd)))
|
||||
LOG.debug('Running cmd: [%s]' % ((str_cmd)))
|
||||
|
||||
if process_input is not None:
|
||||
LOG.debug('With stdin: %s' % (process_input))
|
||||
|
||||
@@ -89,16 +89,16 @@ def load_json(fn):
|
||||
return json.loads(data)
|
||||
|
||||
|
||||
def get_host_ip():
|
||||
def get_host_ip(def_net_ifc, def_ip_version):
|
||||
ip = None
|
||||
interfaces = get_interfaces()
|
||||
def_info = interfaces.get(settings.DEFAULT_NET_INTERFACE)
|
||||
def_info = interfaces.get(def_net_ifc)
|
||||
if def_info:
|
||||
ipinfo = def_info.get(settings.DEFAULT_NET_INTERFACE_IP_VERSION)
|
||||
ipinfo = def_info.get(def_ip_version)
|
||||
if ipinfo:
|
||||
ip = ipinfo.get('addr')
|
||||
if ip is None:
|
||||
msg = "Your host does not have an ip address!"
|
||||
msg = "Your host does not have an ip address on interface: %s using ip version: %s!" % (def_net_ifc, def_ip_version)
|
||||
raise excp.NoIpException(msg)
|
||||
return ip
|
||||
|
||||
|
||||
Reference in New Issue
Block a user