

def create_ip_addrs_by_rules(self, cluster, rules):
    "Manually create VIPs in database basing on given rules\n\n        Format exmaple for rules\n        {\n            'management': {\n                'haproxy': '192.168.0.1',\n                'vrouter': '192.168.0.2',\n            }\n        }\n\n        :param cluster: cluster ORM instance\n        :param rules: mapping of networks and VIPs information needed\n            for proper database entry creation\n        "
    created_ips = []
    for net_group in cluster.network_groups:
        if (net_group.name not in rules):
            continue
        vips_by_names = rules[net_group.name]
        for (vip_name, ip_addr) in six.iteritems(vips_by_names):
            ip = IPAddr(network=net_group.id, ip_addr=ip_addr, vip_name=vip_name)
            self.db.add(ip)
            created_ips.append(ip)
    if created_ips:
        self.db.flush()
    return created_ips

dataset/ETHPy150Open openstack/fuel-web/nailgun/nailgun/test/base.py EnvironmentManager.create_ip_addrs_by_rules/original