Ejemplo n.º 1
0
    def delete_all_ipam_subnets(self, *args, **kwargs):
        banner("PCC.Ipam Subnet Delete All")
        self._load_kwargs(kwargs)

        try:
            conn = BuiltIn().get_variable_value("${PCC_CONN}")
        except Exception as e:
            raise e
        
        failed_del=[]
        response = pcc.get_subnet_objs(conn)
        
        if not get_response_data(response):
            print("No subnet found for delete !!")
            return "OK"
            
        for data in get_response_data(response):
            print("Response To Look :-"+str(data))
            print("Subnet {} and id {} is deleting....".format(data['name'],data['id']))
            self.id=data['id']
            del_response=pcc.delete_subnet_obj_by_id(conn, str(self.id))
            if del_response['Result']['status']==200:
                continue
            else:
                print("Delete Response:"+str(del_response))
                failed_del.append(data['name'])
                continue
        if failed_del:
            print("Could not delete following Subnets: "+str(failed_del))
            return "Error"
        return "OK"
Ejemplo n.º 2
0
    def verify_ipam_subnet_updated(self, *args, **kwargs):
        banner("PCC.Verify Ipam Subnet Updated")
        self._load_kwargs(kwargs)
        print("Kwargs:"+str(kwargs))

        if self.name == None:
            print("Name is Empty, Please provide valid name.")
            return "Error"
        try:
            conn = BuiltIn().get_variable_value("${PCC_CONN}")
        except Exception as e:
            raise e

        timeout = time.time() + PCCSERVER_TIMEOUT
  
        response = pcc.get_subnet_objs(conn)
        for data in get_response_data(response):
            if str(data['name']).lower() == str(self.name).lower():
                print("Data to Look:"+str(data))
                for key in kwargs:
                    if data[key]==kwargs[key]:
                        continue
                    else:
                        print("Not Updated Propery, there is mismatch {}!={}".format(data[key],kwargs[key]))
                        return "Error"        
        return "OK"                
Ejemplo n.º 3
0
def get_subnet_id_by_name(conn: dict, Name: str) -> int:
    """
    Get Id of Subnet with matching Name from PCC
    [Args]
        (dict) conn: Connection dictionary obtained after logging in
        (str) Name: Name of Subnet
    [Returns]
        (int) Id: Id of the matchining subnet name, or
            None: if no match found, or
        (dict) Error response: If Exception occured
    """
    try:
        list_of_subnets = pcc.get_subnet_objs(conn)['Result']['Data']
        for subnet in list_of_subnets:
            if str(subnet['name']) == str(Name):
                return subnet['id']
        return None
    except Exception as e:
        return {"Error": str(e)}
Ejemplo n.º 4
0
    def wait_until_ipam_subnet_ready(self, *args, **kwargs):
        banner("PCC.Wait Until Ipam Subnet Ready")
        self._load_kwargs(kwargs)

        if self.name == None:
            return None
        try:
            conn = BuiltIn().get_variable_value("${PCC_CONN}")
        except Exception as e:
            raise e

        timeout = time.time() + PCCSERVER_TIMEOUT
  
        response = pcc.get_subnet_objs(conn)
        for data in get_response_data(response):
            if str(data['name']).lower() == str(self.name).lower():
                print("Response To Look :-"+str(data))
                return "OK"                
            time.sleep(5)
        print("Could not find any entry for subnet "+str(self.name)+" on PCC UI")
        return "Error"
Ejemplo n.º 5
0
    def wait_until_ipam_subnet_deleted(self, *args, **kwargs):
        banner("PCC.Wait Until Ipam Subnet Deleted")
        self._load_kwargs(kwargs)

        if self.name == None:
            return None
        try:
            conn = BuiltIn().get_variable_value("${PCC_CONN}")
        except Exception as e:
            raise e

        timeout = time.time() + PCCSERVER_TIMEOUT
        
        time.sleep(30)
        response = pcc.get_subnet_objs(conn)
        for data in get_response_data(response):
            if str(data['name']).lower() == str(self.name).lower():
                print("Response To Look :-"+str(data))
                print("Could not able to delete subnet "+str(self.name))
                return "Error"                
            time.sleep(5)
        print("Subnet {} deleted sucessfully".format(self.name))
        return "OK"