def removeOrder(self, n):

        oldstyle = self.formLayout3.itemAt(n - 1).widget().styleSheet()
        self.formLayout3.itemAt(n - 1).widget().setStyleSheet(styles.buttonY)
        data.orderResolution[0], data.orderResolution[
            1] = self.width / 2.5, self.height / 1.3
        Dialog = QtWidgets.QDialog()
        ui = confirmwin.Ui_DialogCONFIRM()
        ui.setupUi(Dialog)
        Dialog.exec_()
        try:
            if data.toDelete:
                client.delete(data.username, data.system_ord[n - 1][-1])
                for i in reversed(range(self.formLayout3.count())):
                    self.formLayout3.itemAt(i).widget().deleteLater()
                del data.system_ord[n - 1]
                self.reloadSystemOrders("")
                bal = client.get_balance(data.username)
                data.balance = (bal, "$")
                func.putPersonalData()
                bar.setText(func.barInfo())
            else:
                self.formLayout3.itemAt(n - 1).widget().setStyleSheet(oldstyle)
            data.toDelete = False
        except:
            print("Error in remove order")
Beispiel #2
0
def delete_logical_switches():
    api_endpoint = SWITCHES_ENDPOINT
    print 'Starting deletion of Logical Switches!'
    logical_switches_resp = client.get(api_endpoint)
    for instance in logical_switches_resp.json()['results']:
        instance_api_endpoint = '%s/%s?force=true' % (api_endpoint,
                                                      instance['id'])
        client.delete(instance_api_endpoint)
    print ' Deleted Logical Switches!'
Beispiel #3
0
def delete_router_ports():
    api_endpoint = ROUTER_PORTS_ENDPOINT
    print 'Starting deletion of Router Ports!'
    router_ports_resp = client.get(api_endpoint)
    for instance in router_ports_resp.json()['results']:
        instance_api_endpoint = '%s/%s?force=true' % (api_endpoint,
                                                      instance['id'])
        client.delete(instance_api_endpoint)
    print ' Deleted Router Ports!'
Beispiel #4
0
def delete_logical_switches(context, type = 'logical_switches'):

    lswitches = context[type]
    map_logical_switches_id(lswitches)
    
    for lswitch in lswitches:
        
        if  lswitch.get('id') is None:
            continue

        retry = 0
        while (retry < 3):
            
            delete_response = client.delete(NSX_URLS['lswitch']['all'] + '/' +
                     lswitch['id'], False)
            data = delete_response.text

            if DEBUG:
                print('NSX Logical Switch {} Deletion response:{}\n'.format(lswitch['name'], data))

            if delete_response.status_code < 400: 
                print('Deleted NSX Logical Switch:{}\n'.format(lswitch['name']))
                break

            print('Deletion of NSX Logical Switch {} failed, details: {}\n'.format(lswitch['name'], data))
            if 'resource is still in use' in str(data):
                retry += 1
                print('Going to retry deletion again... for Logical Switch:{}\n'.format(lswitch['name']))
            else:
                print('Cannot retry deletion..., skipping delete for Logical Switch:{}\n'.format(lswitch['name']))
                break
Beispiel #5
0
def delete_nsx_dlr_gateways(context):

    nsx_dlrs = context.get('nsx_dlrs')
    if not nsx_dlrs:
        nsx_dlrs = []
        edge_service_gateways = context['edge_service_gateways']
        for edge in  edge_service_gateways:
            nsx_dlrs.append( { 'name': edge['name'] + '-dlr' })

    map_nsx_esg_id(nsx_dlrs)
    
    for nsx_dlr in nsx_dlrs:

        if  nsx_dlr.get('id') is None:
            continue

        delete_response = client.delete(NSX_URLS['esg']['all'] + '/' +
                nsx_dlr['id'])
        data = delete_response.text

        if DEBUG:
            print('NSX DLR Deletion response:{}\n'.format(data))

        if delete_response.status_code < 400: 
            print('Deleted NSX DLR : {}\n'.format(nsx_dlr['name']))
        else:
            print('Deletion of NSX DLR failed, details:{}\n'.format(data +'\n'))    
Beispiel #6
0
def delete_edge_clusters():
    api_endpoint = EDGE_CLUSTERS_ENDPOINT
    print 'Starting deletion of Edge Clusters!'
    edge_clusters_resp = client.get(api_endpoint)
    for instance in edge_clusters_resp.json()['results']:
        instance_api_endpoint = '%s/%s' % (api_endpoint, instance['id'])
        resp = client.delete(instance_api_endpoint)
    print ' Deleted Edge Clusters!'
Beispiel #7
0
def delete_node_from_transport_and_fabric(type_of_entity, entity_map):
    transport_nodes_api_endpoint = TRANSPORT_NODES_ENDPOINT
    fabric_nodes_api_endpoint = FABRIC_NODES_ENDPOINT

    for entity_id in entity_map.keys():
        print 'Deleting {} from Transport and Fabric nodes: {}'.format(
            type_of_entity, entity_map[entity_id])
        transport_node_delete_url = '%s/%s' % (transport_nodes_api_endpoint,
                                               entity_id)
        transport_nodes_resp = client.delete(transport_node_delete_url)
        #print '  Delete response from Transport nodes: {}'.format(transport_nodes_resp)

        fabric_node_delete_url = '%s/%s' % (fabric_nodes_api_endpoint,
                                            entity_id)
        fabric_node_delete_resp = client.delete(fabric_node_delete_url)
        #print '  Delete response from Fabric nodes: {}'.format(fabric_node_delete_resp)
    print ''
Beispiel #8
0
def delete_transport_zone(context):

    # if no transport zone, nothing to delete
    if not check_transport_zone(context):
        return

    transport_zone_id = context['nsxmanager']['transport_zone_id']
    delete_response = client.delete(NSX_URLS['scope']['all'] + '/' +
             transport_zone_id, False)
    data = delete_response.text
Beispiel #9
0
def reset_t0_route_nat_rules():
  for key in global_id_map:
    if key.startswith('ROUTER:TIER0:'):
      t0_router_id = global_id_map[key]
      api_endpoint = '%s/%s/%s' % (ROUTERS_ENDPOINT, t0_router_id, 'nat/rules')
      resp = client.get(api_endpoint).json()
      nat_rules = resp['results']
      for nat_rule in nat_rules:
        delete_api_endpint = '%s%s%s' % (api_endpoint, '/', nat_rule['id'])
        resp = client.delete(delete_api_endpint )
Beispiel #10
0
 def POST(self, topic_id, comment_id):
     if not is_admin():
         return web.notfound()
     r, j = client.delete('/topics/%i/comments/%i/' % (int(topic_id), int(comment_id)))
     if ok(r):
         flash(_.comment.delete.ok)
         raise web.redirect('/topics/%i/' % int(topic_id))
     else:
         flash(_.comment.delete.fail)
         raise web.redirect('/topics/%i/' % int(topic_id))
Beispiel #11
0
 def POST(self, id):
     if not user():
         return web.notfound()
     render = web.template.render('asset', base='after.common', globals=globals())
     r, j = client.delete('/users/%i/friends/%i/' % (int(user().user_id),int(id)))
     if ok(r):
         flash(_.user.unfollow.ok)
         raise web.redirect('/users/%i/' % int(id))
     else:
         flash(_.user.unfollow.fail)
         raise web.redirect('/users/%i/' % int(id))
Beispiel #12
0
 def POST(self, group_id):
     if not user():
         return web.notfound()
     i = {'user_id':session.user.user_id}
     r, j = client.delete('/groups/%i/' % int(group_id), data=i)
     if ok(r):
         flash(_.group.quit.ok)
         return web.redirect('/groups/')
     else:
         flash(_.group.quit.fail)
         return web.redirect('/groups/%i/' % int(group_id))
     return web.notfound()
Beispiel #13
0
 def POST(self, id):
     if not user():
         return web.notfound()
     print 'hi'
     render = web.template.render('asset', base='after.common', globals=globals())
     r, j = client.delete('/topics/%i/' % int(id))
     if ok(r):
         flash(_.topic.delete.ok)
         raise web.redirect('/topics/');
     else:
         flash(_.topic.delete.fail)
         raise web.redirect('/topics/%i/' % int(id));
Beispiel #14
0
def disable_auto_install_for_compute_fabric():
    compute_fabric_collection_api_endpoint = COMPUTE_COLLECTION_FABRIC_TEMPLATES_ENDPOINT
    transport_node_collection_api_endpoint = COMPUTE_COLLECTION_TRANSPORT_NODES_ENDPOINT

    outer_resp = client.get(compute_fabric_collection_api_endpoint)
    #print 'Got Compute collection respo: {}'.format(outer_resp)
    compute_fabric_templates = outer_resp.json()['results']
    for compute_fabric in compute_fabric_templates:
        #print 'Iterating over Compute fabric respo: {}'.format(compute_fabric)
        compute_fabric['auto_install_nsx'] = False
        compute_fabric_id = compute_fabric['id']

        compute_collection_id = compute_fabric['compute_collection_id']

        # First remove the related transport node template from the compute collection relationship
        transport_node_association_from_compute_fabric_api_endpoint = '%s?compute_collection_id=%s' % (
            transport_node_collection_api_endpoint, compute_collection_id)

        get_resp = client.get(
            transport_node_association_from_compute_fabric_api_endpoint,
            check=False)
        if get_resp.status_code == 200:
            try:
                for transport_node in get_resp.json()['results']:
                    transport_node_id = transport_node['id']
                    transport_node_removal_api_endpoint = '%s/%s' % (
                        transport_node_collection_api_endpoint,
                        transport_node_id)
                    delete_resp = client.delete(
                        transport_node_removal_api_endpoint, check=False)
                    print 'Removed auto-linking of Host as Transport Node in Fabric for Compute Manager: {}'.format(
                        compute_fabric['compute_collection_id'])
            except Exception as e:
                print 'No transport nodes associated'
                #ignore
        # Now change the compute fabric template
        compute_fabric_update_api_endpoint = '%s/%s' % (
            compute_fabric_collection_api_endpoint, compute_fabric_id)
        resp = client.put(compute_fabric_update_api_endpoint,
                          compute_fabric,
                          check=False)

        if resp.status_code < 400:
            print 'Disabled auto install of NSX in Compute Fabric: {}'.format(
                compute_fabric['compute_collection_id'])
            print ''
        else:
            print 'Problem in disabling auto install in Compute Fabric: {}'.format(
                compute_fabric['compute_collection_id'])
            print 'Associated Error: {}'.format(resp.json())
            exit(1)
Beispiel #15
0
 def POST(self, group_id, user_id, is_approved):
     if not user():
         return web.notfound()
     i = {'user_id':session.user.user_id}
     if int(is_approved) == 1:
         r, j = client.post('/groups/%i/requests/%i/' % (int(group_id),int(user_id)), data=i)
         if ok(r):
             flash(_.group.admin.ok)
             return web.redirect('/groups/requests/')
         else:
             flash(_.group.admin.fail)
             return web.redirect('/groups/requests/')
     elif int(is_approved) == 0:
         r, j = client.delete('/groups/%i/requests/%i/' % (int(group_id),int(user_id)), data=i)
         if ok(r):
             flash(_.group.admin.ok)
             return web.redirect('/groups/requests/')
         else:
             flash(_.group.admin.fail)
             return web.redirect('/groups/requests/')
     return web.notfound()
Beispiel #16
0
def delete_nsx_edge_gateways(context):

    edge_service_gateways = context['edge_service_gateways']
    map_nsx_esg_id(edge_service_gateways)
    
    for nsx_esg in edge_service_gateways:

        if  nsx_esg.get('id') is None:
            continue

        delete_response = client.delete(NSX_URLS['esg']['all'] + '/' +
                nsx_esg['id'])
        data = delete_response.text

        if DEBUG:
            print('NSX ESG Deletion response:{}\n'.format(data))

        if delete_response.status_code < 400: 
            print('Deleted NSX ESG : {}\n'.format(nsx_esg['name']))
        else:
            print('Deletion of NSX ESG failed, details:{}\n'.format(data +'\n'))    
Beispiel #17
0
def delete_lbrs():
    api_endpoint = LBR_SERVICES_ENDPOINT
    print 'Starting deletion of Loadbalancers!'
    lbrs_resp = client.get(api_endpoint)
    for instance in lbrs_resp.json()['results']:
        instance_api_endpoint = '%s/%s' % (api_endpoint, instance['id'])
        client.delete(instance_api_endpoint)
    print ' Deleted Loadbalancers!'

    api_endpoint = LBR_VIRTUAL_SERVER_ENDPOINT
    print 'Starting deletion of Virtual Servers!'
    virtual_servers_resp = client.get(api_endpoint)
    for instance in virtual_servers_resp.json()['results']:
        instance_api_endpoint = '%s/%s' % (api_endpoint, instance['id'])
        client.delete(instance_api_endpoint)
    print ' Deleted Virtual Servers!'

    api_endpoint = LBR_POOLS_ENDPOINT
    print 'Starting deletion of Server Pools!'
    pool_servers_resp = client.get(api_endpoint)
    for instance in pool_servers_resp.json()['results']:
        instance_api_endpoint = '%s/%s' % (api_endpoint, instance['id'])
        client.delete(instance_api_endpoint)
    print ' Deleted Server Pools!'
Beispiel #18
0
 def delete(self,options={}) :
     return riq.delete(self.endpoint() + '/' + self.id(),options)
Beispiel #19
0
 def delete(self, options={}):
     return riq.delete(self.endpoint() + "/" + self.id(), options)