- m = re.search(r"apiaddresses:\n- (\d+\.\d+\.\d+\.\d+):17070", results.script)
- apiaddress = m.group(1)
-
- """Add IP Table rule
-
- In order to route the traffic to the private ip of the Juju controller
- we use a DNAT rule to tell the machine that the destination for the
- private address is the public address of the machine where the Juju
- controller is running in LXD. That machine will have a complimentary
- iptables rule, routing traffic to the appropriate LXD container.
- """
-
- script = IPTABLES_SCRIPT.format(apiaddress, api)
-
- # Run this in a retry loop, because dpkg may be running and cause the
- # script to fail.
- retry = 10
- attempts = 0
- delay = 15
-
- while attempts <= retry:
- try:
- attempts += 1
- stdout, stderr = await self._run_configure_script(script)
- break
- except Exception as e:
- self.log.debug("Waiting for dpkg, sleeping {} seconds".format(delay))
- if attempts > retry:
- raise e
- else:
- await asyncio.sleep(delay)
- # Slowly back off the retry
- delay += 15
+ if proxy:
+ m = re.search(r"apiaddresses:\n- (\d+\.\d+\.\d+\.\d+):17070", results.script)
+ apiaddress = m.group(1)
+
+ """Add IP Table rule
+
+ In order to route the traffic to the private ip of the Juju controller
+ we use a DNAT rule to tell the machine that the destination for the
+ private address is the public address of the machine where the Juju
+ controller is running in LXD. That machine will have a complimentary
+ iptables rule, routing traffic to the appropriate LXD container.
+ """
+
+ script = IPTABLES_SCRIPT.format(apiaddress, proxy)
+
+ # Run this in a retry loop, because dpkg may be running and cause the
+ # script to fail.
+ retry = 10
+ attempts = 0
+ delay = 15
+
+ while attempts <= retry:
+ try:
+ attempts += 1
+ stdout, stderr = await self._run_configure_script(script)
+ break
+ except Exception as e:
+ self.log.debug("Waiting for dpkg, sleeping {} seconds".format(delay))
+ if attempts > retry:
+ raise e
+ else:
+ await asyncio.sleep(delay)
+ # Slowly back off the retry
+ delay += 15