Пример #1
0
 def get_vswitch(self):
     self.sync_vswitch()
     condition = res_ops.gen_query_conditions('ecsVpcUuid', '=', self.vpc.uuid)
     vswitch = hyb_ops.query_ecs_vswitch_local(condition)
     if vswitch:
         self.vswitch = vswitch[0]
     else:
         self.create_vswitch()
Пример #2
0
 def get_vpc(self, has_vpn_gateway=False):
     self.sync_vpc(return_val=False)
     vpc_all = hyb_ops.query_ecs_vpc_local()
     if has_vpn_gateway:
         self.sync_vswitch()
         cond_vs = res_ops.gen_query_conditions('uuid', '=', self.vpn_gateway.vSwitchUuid)
         vs = hyb_ops.query_ecs_vswitch_local(cond_vs)[0]
         ecs_vpc = [vpc for vpc in vpc_all if vpc.uuid == vs.ecsVpcUuid]
     else:
         ecs_vpc = [vpc for vpc in vpc_all if vpc.status.lower() == 'available']
     if ecs_vpc:
         self.vpc = ecs_vpc[0]
     else:
         self.create_vpc()
Пример #3
0
 def create_vswitch(self):
     self.sync_vswitch()
     cond_vpc_vs = res_ops.gen_query_conditions('ecsVpcUuid', '=', self.vpc.uuid)
     vpc_vs = hyb_ops.query_ecs_vswitch_local(cond_vpc_vs)
     if vpc_vs:
         vs_cidr = [vs.cidrBlock.split('.')[-2] for vs in vpc_vs]
         cidr_val = list(set(str(i) for i in xrange(255)).difference(set(vs_cidr)))
     else:
         cidr_val = [str(i) for i in xrange(200, 255)]
     vpc_cidr_list = self.vpc.cidrBlock.split('.')
     vpc_cidr_list[2] = random.choice(cidr_val)
     vpc_cidr_list[3] = '0/24'
     vswitch_cidr = '.'.join(vpc_cidr_list)
     self.vs_name = 'zstack-test-vswitch-%s' % _postfix
     self.vswitch = hyb_ops.create_ecs_vswtich_remote(self.vpc.uuid, self.iz.uuid, self.vs_name, vswitch_cidr)
     time.sleep(10)
     self.check_resource('create', 'vSwitchId', self.vswitch.vSwitchId, 'query_ecs_vswitch_local')