VR CsAddress fixes:

* cleanup imports,
* fix to_str(),
* improve & fix service post_config logic
* don't arpPing when there's no gateway
This commit is contained in:
Ronald van Zantvoort 2016-05-13 17:28:39 +02:00 committed by Wido den Hollander
parent 6055ed6ed6
commit d14a484374

View File

@ -15,15 +15,13 @@
# KIND, either express or implied. See the License for the # KIND, either express or implied. See the License for the
# specific language governing permissions and limitations # specific language governing permissions and limitations
# under the License. # under the License.
from CsDatabag import CsDataBag, CsCmdLine
from CsApp import CsApache, CsDnsmasq, CsPasswdSvc
import CsHelper
import logging import logging
from netaddr import IPAddress, IPNetwork from netaddr import IPAddress, IPNetwork
import CsHelper
import subprocess import subprocess
import time import time
import CsHelper
from CsDatabag import CsDataBag
from CsApp import CsApache, CsDnsmasq, CsPasswdSvc
from CsRoute import CsRoute from CsRoute import CsRoute
from CsRule import CsRule from CsRule import CsRule
@ -198,7 +196,7 @@ class CsInterface:
return self.get_attr("add") return self.get_attr("add")
def to_str(self): def to_str(self):
pprint(self.address) return self.address
class CsDevice: class CsDevice:
@ -293,8 +291,9 @@ class CsIP:
interfaces = [CsInterface(address, self.config)] interfaces = [CsInterface(address, self.config)]
CsHelper.reconfigure_interfaces(self.cl, interfaces) CsHelper.reconfigure_interfaces(self.cl, interfaces)
self.set_mark() self.set_mark()
if 'gateway' in self.address:
self.arpPing() self.arpPing()
CsRpsrfs(self.dev).enable() CsRpsrfs(self.dev).enable()
@ -514,14 +513,17 @@ class CsIP:
self.fw_vpcrouter() self.fw_vpcrouter()
# On deletion nw_type will no longer be known # On deletion nw_type will no longer be known
if self.get_type() in ["guest"] and self.config.is_vpc(): if self.get_type() in ('guest'):
if self.config.is_vpc() or self.config.is_router():
CsDevice(self.dev, self.config).configure_rp() CsDevice(self.dev, self.config).configure_rp()
logging.error( logging.error(
"Not able to setup source-nat for a regular router yet") "Not able to setup source-nat for a regular router yet")
if self.config.has_dns() or self.config.is_dhcp():
dns = CsDnsmasq(self) dns = CsDnsmasq(self)
dns.add_firewall_rules() dns.add_firewall_rules()
if self.config.has_metadata():
app = CsApache(self) app = CsApache(self)
app.setup() app.setup()
@ -685,3 +687,4 @@ class CsRpsrfs:
if count < 2: if count < 2:
logging.debug("Single CPU machine") logging.debug("Single CPU machine")
return count return count