Ejemplo n.º 1
0
 def verify(self):
     # Do a little check to make sure actually have that interface/s
     public_interface = self._getstr('public_interface')
     vlan_interface = self._getstr('vlan_interface', public_interface)
     if not utils.is_interface(public_interface):
         msg = "Public interface %r is not a known interface" % (
             public_interface)
         raise exceptions.ConfigException(msg)
     if not utils.is_interface(vlan_interface):
         msg = "VLAN interface %r is not a known interface" % (
             vlan_interface)
         raise exceptions.ConfigException(msg)
     # Driver specific interface checks
     drive_canon = canon_virt_driver(self._getstr('virt_driver'))
     if drive_canon == 'xenserver':
         xs_flat_ifc = self._getstr('xs_flat_interface', XS_DEF_INTERFACE)
         if xs_flat_ifc and not utils.is_interface(xs_flat_ifc):
             msg = "Xenserver flat interface %s is not a known interface" % (
                 xs_flat_ifc)
             raise exceptions.ConfigException(msg)
     elif drive_canon == 'libvirt':
         flat_interface = self._getstr('flat_interface')
         if flat_interface and not utils.is_interface(flat_interface):
             msg = "Libvirt flat interface %s is not a known interface" % (
                 flat_interface)
             raise exceptions.ConfigException(msg)
Ejemplo n.º 2
0
    def _configure_network_settings(self, nova_conf):
        # TODO this might not be right....
        if 'quantum' in self.options:
            nova_conf.add('network_manager', QUANTUM_MANAGER)
            hostip = self.cfg.get('host', 'ip')
            nova_conf.add('quantum_connection_host',
                          self.cfg.getdefaulted('quantum', 'q_host', hostip))
            nova_conf.add('quantum_connection_port',
                          self.cfg.getdefaulted('quantum', 'q_port', '9696'))
            if self.cfg.get('quantum', 'q_plugin') == 'openvswitch':
                for (key, value) in QUANTUM_OPENSWITCH_OPS.items():
                    nova_conf.add(key, value)
            if 'melange' in self.options:
                nova_conf.add('quantum_ipam_lib', QUANTUM_IPAM_LIB)
                nova_conf.add('use_melange_mac_generation', True)
                nova_conf.add(
                    'melange_host',
                    self.cfg.getdefaulted('melange', 'm_host', hostip))
                nova_conf.add(
                    'melange_port',
                    self.cfg.getdefaulted('melange', 'm_port', '9898'))
        else:
            nova_conf.add(
                'network_manager', NET_MANAGER_TEMPLATE %
                (self._getstr('network_manager', DEF_NET_MANAGER)))

        # Configs dhcp bridge stuff???
        # TODO: why is this the same as the nova.conf?
        nova_conf.add('dhcpbridge_flagfile',
                      sh.joinpths(self.cfg_dir, API_CONF))

        # Network prefix for the IP network that all the projects for future VM guests reside on. Example: 192.168.0.0/12
        nova_conf.add('fixed_range', self._getstr('fixed_range'))

        # The value for vlan_interface may default to the the current value
        # of public_interface. We'll grab the value and keep it handy.
        public_interface = self._getstr('public_interface')
        vlan_interface = self._getstr('vlan_interface', public_interface)

        # Do a little check to make sure actually have that interface/s
        if not utils.is_interface(public_interface):
            msg = "Public interface %s is not a known interface" % (
                public_interface)
            raise exceptions.ConfigException(msg)

        if not utils.is_interface(vlan_interface):
            msg = "VLAN interface %s is not a known interface" % (
                vlan_interface)
            raise exceptions.ConfigException(msg)

        nova_conf.add('public_interface', public_interface)
        nova_conf.add('vlan_interface', vlan_interface)

        # This forces dnsmasq to update its leases table when an instance is terminated.
        nova_conf.add('force_dhcp_release', True)
Ejemplo n.º 3
0
 def _check_ug(self):
     (user, group) = self._get_apache_user_group()
     if not sh.user_exists(user):
         msg = "No user named %s exists on this system!" % (user)
         raise excp.ConfigException(msg)
     if not sh.group_exists(group):
         msg = "No group named %s exists on this system!" % (group)
         raise excp.ConfigException(msg)
     if user in BAD_APACHE_USERS:
         msg = ("You may want to adjust your configuration, "
                "(user=%s, group=%s) will not work with apache!" %
                (user, group))
         raise excp.ConfigException(msg)
Ejemplo n.º 4
0
 def verify(self, distro):
     # Some sanity checks against the given distro
     d_name = distro.name
     if d_name not in self.distro_support:
         msg = "Distro %r not supported" % (d_name)
         raise excp.ConfigException(msg)
     for c in self.wanted_components:
         if not distro.known_component(c):
             raise RuntimeError("Distro %r does not support component %r" %
                                (d_name, c))
Ejemplo n.º 5
0
 def _configure_virt_driver(self, nova_conf):
     drive_canon = _canon_virt_driver(self._getstr('virt_driver'))
     nova_conf.add('connection_type',
                   VIRT_DRIVER_CON_MAP.get(drive_canon, drive_canon))
     # Special driver settings
     if drive_canon == 'xenserver':
         nova_conf.add(
             'xenapi_connection_url',
             self._getstr('xa_connection_url', XA_DEF_CONNECTION_URL))
         nova_conf.add('xenapi_connection_username',
                       self._getstr('xa_connection_username', XA_DEF_USER))
         nova_conf.add('xenapi_connection_password',
                       self.cfg.get("passwords", "xenapi_connection"))
         nova_conf.add('noflat_injected', True)
         xs_flat_ifc = self._getstr('xs_flat_interface', XS_DEF_INTERFACE)
         if not utils.is_interface(xs_flat_ifc):
             msg = "Xenserver flat interface %s is not a known interface" % (
                 xs_flat_ifc)
             raise exceptions.ConfigException(msg)
         nova_conf.add('flat_interface', xs_flat_ifc)
         nova_conf.add(
             'firewall_driver', FIRE_MANAGER_TEMPLATE %
             (self._getstr('xs_firewall_driver', DEF_FIREWALL_DRIVER)))
         nova_conf.add(
             'flat_network_bridge',
             self._getstr('xs_flat_network_bridge', XS_DEF_BRIDGE))
     elif drive_canon == 'libvirt':
         nova_conf.add(
             'firewall_driver', FIRE_MANAGER_TEMPLATE %
             (self._getstr('libvirt_firewall_driver', DEF_FIREWALL_DRIVER)))
         nova_conf.add(
             'flat_network_bridge',
             self._getstr('flat_network_bridge', DEF_FLAT_VIRT_BRIDGE))
         flat_interface = self._getstr('flat_interface')
         if flat_interface:
             if not utils.is_interface(flat_interface):
                 msg = "Libvirt flat interface %s is not a known interface" % (
                     flat_interface)
                 raise exceptions.ConfigException(msg)
             nova_conf.add('flat_interface', flat_interface)
Ejemplo n.º 6
0
 def download(self):
     locations = self._get_download_locations()
     base_dir = self.app_dir
     for location_info in locations:
         uri_tuple = location_info["uri"]
         branch_tuple = location_info.get("branch")
         sub_dir = location_info.get("subdir")
         target_loc = base_dir
         if sub_dir:
             target_loc = sh.joinpths(base_dir, sub_dir)
         branch = None
         if branch_tuple:
             (cfg_section, cfg_key) = branch_tuple
             branch = self.cfg.get(cfg_section, cfg_key)
             if not branch:
                 msg = "No branch entry found at config location [%s]" % \
                     (cfg_helpers.make_id(cfg_section, cfg_key))
                 raise excp.ConfigException(msg)
         (cfg_section, cfg_key) = uri_tuple
         uri = self.cfg.get(cfg_section, cfg_key)
         if not uri:
             msg = "No uri entry found at config location [%s]" % \
                 (cfg_helpers.make_id(cfg_section, cfg_key))
             raise excp.ConfigException(msg)
         # Activate da download!
         self.tracewriter.download_happened(target_loc, uri)
         dirs_made = self._do_download(uri, target_loc, branch)
         # Here we ensure this is always added so that
         # if a keep old happens then this of course
         # won't be recreated, but if u uninstall without keeping old
         # then this won't be deleted this time around
         # adding it in is harmless and will make sure its removed.
         if target_loc not in dirs_made:
             dirs_made.append(target_loc)
         self.tracewriter.dirs_made(*dirs_made)
     return len(locations)