Ejemplo n.º 1
0
 def test_rbac_lbaasv2_plugin(self):
     '''
     Validate contrail neutron lbaasv2 plugin for rbac
     steps:
         1. Add user1 as role1
         2. create project acl rule *.* role1:CRUD
         3. create loadbalancer as user1
     '''
     self.add_user_to_project(self.user1, self.role1)
     user1_conn = self.get_connections(self.user1, self.pass1)
     rules = [{
         'rule_object': '*',
         'rule_field': None,
         'perms': [{
             'role': self.role1,
             'crud': 'CRUD'
         }]
     }]
     proj_rbac = self.create_rbac_acl(rules=rules)
     vn = self.create_vn(connections=user1_conn)
     vm_ip = get_random_ip(vn.get_cidrs()[0])
     members = {'address': [vm_ip]}
     lb_name = get_random_name('rbac-lb')
     assert self.create_lbaas(connections=user1_conn,
                              lb_name=lb_name,
                              network_id=vn.uuid,
                              members=members,
                              hm_probe_type='PING')
Ejemplo n.º 2
0
def get_random_ip_list(max_list_length=4):
    list_length = random.randint(1, max_list_length)
    final_list = []
    for i in range(0, list_length):
        cidr = get_random_cidr()
        random_ip = get_random_ip(cidr)
        final_list.append(random_ip)
    return final_list
Ejemplo n.º 3
0
def get_random_ip_list(max_list_length=4):
    list_length = random.randint(1, max_list_length)
    final_list = []
    for i in range(0, list_length):
        cidr = get_random_cidr()
        random_ip = get_random_ip(cidr)
        final_list.append(random_ip)
    return final_list
Ejemplo n.º 4
0
def get_route_dict_list(cidr, max_length=4):
    list_length = random.randint(1, max_length)
    final_list = []

    for i in range(0, list_length):
        route_dict = {'destination': get_random_cidr(),
                      'nexthop': str(get_random_ip(cidr))}
        final_list.append(route_dict)
    return final_list
Ejemplo n.º 5
0
def get_route_dict_list(cidr, max_length=4):
    list_length = random.randint(1, max_length)
    final_list = []

    for i in range(0, list_length):
        route_dict = {
            'destination': get_random_cidr(),
            'nexthop': str(get_random_ip(cidr))
        }
        final_list.append(route_dict)
    return final_list
Ejemplo n.º 6
0
def get_fixed_ip_dict_list(subnet_id, cidr, max_length=1):
    # Need to test separately for a list of fixed ips
    list_length = random.randint(1, max_length)
    final_list = []
    for i in range(0, list_length):
        fixed_ip_dict = {}
        random_ip = get_random_ip(cidr)
        if subnet_id is not None:
            fixed_ip_dict['subnet_id'] = subnet_id
        fixed_ip_dict['ip_address'] = random_ip
        final_list.append(fixed_ip_dict)
    return final_list
Ejemplo n.º 7
0
def get_fixed_ip_dict_list(subnet_id, cidr, max_length=1):
    # Need to test separately for a list of fixed ips
    list_length = random.randint(1, max_length)
    final_list = []
    for i in range(0, list_length):
        fixed_ip_dict = {}
        random_ip = get_random_ip(cidr)
        if subnet_id is not None:
            fixed_ip_dict['subnet_id'] = subnet_id
        fixed_ip_dict['ip_address'] = random_ip
        final_list.append(fixed_ip_dict)
    return final_list
Ejemplo n.º 8
0
 def test_rbac_lbaasv2_plugin(self):
     '''
     Validate contrail neutron lbaasv2 plugin for rbac
     steps:
         1. Add user1 as role1
         2. create project acl rule *.* role1:CRUD
         3. create loadbalancer as user1
     '''
     self.add_user_to_project(self.user1, self.role1)
     user1_conn = self.get_connections(self.user1, self.pass1)
     rules = [{'rule_object': '*',
               'rule_field': None,
               'perms': [{'role': self.role1, 'crud': 'CRUD'}]
              }]
     proj_rbac = self.create_rbac_acl(rules=rules)
     vn = self.create_vn(connections=user1_conn)
     vm_ip = get_random_ip(vn.get_cidrs()[0])
     members = {'address': [vm_ip]}
     lb_name = get_random_name('rbac-lb')
     assert self.create_lbaas(connections=user1_conn,
                              lb_name=lb_name, network_id=vn.uuid,
                              members=members, hm_probe_type='PING')