+ LOG.info("Deploying context '%s' DONE", self.name)
+
+ def add_server_port(self, server):
+ # use private ip from first port in first network
+ try:
+ private_port = next(iter(server.ports.values()))[0]
+ except IndexError:
+ LOG.exception("Unable to find first private port in %s", server.ports)
+ raise
+ server.private_ip = self.stack.outputs[private_port["stack_name"]]
+ server.interfaces = {}
+ for network_name, ports in server.ports.items():
+ for port in ports:
+ # port['port'] is either port name from mapping or default network_name
+ server.interfaces[port['port']] = self.make_interface_dict(network_name,
+ port['port'],
+ port['stack_name'],
+ self.stack.outputs)
+
+ def make_interface_dict(self, network_name, port, stack_name, outputs):
+ private_ip = outputs[stack_name]
+ mac_address = outputs[h_join(stack_name, "mac_address")]
+ # these are attributes of the network, not the port
+ output_subnet_cidr = outputs[h_join(self.name, network_name,
+ 'subnet', 'cidr')]
+
+ # these are attributes of the network, not the port
+ output_subnet_gateway = outputs[h_join(self.name, network_name,
+ 'subnet', 'gateway_ip')]
+
+ return {
+ "private_ip": private_ip,
+ "subnet_id": outputs[h_join(stack_name, "subnet_id")],
+ "subnet_cidr": output_subnet_cidr,
+ "network": str(ipaddress.ip_network(output_subnet_cidr).network_address),
+ "netmask": str(ipaddress.ip_network(output_subnet_cidr).netmask),
+ "gateway_ip": output_subnet_gateway,
+ "mac_address": mac_address,
+ "device_id": outputs[h_join(stack_name, "device_id")],
+ "network_id": outputs[h_join(stack_name, "network_id")],
+ # this should be == vld_id for NSB tests
+ "network_name": network_name,
+ # to match vnf_generic
+ "local_mac": mac_address,
+ "local_ip": private_ip,
+ }