Exemplo n.º 1
0
    def put(self):

        data = {
            'symbol': self.symbol,
            'exp_date': self.exp_date,
            'price': self.price
            }
        
        return rest.put(TABLE_NAME, data)
Exemplo n.º 2
0
    def put(self):

        data = {
            "symbol": self.symbol,
            "exp_date": self.exp_date,
            "strike": self.strike,
            "call_or_put": self.call_or_put,
            "price": self.price,
        }

        return rest.put(TABLE_NAME, data)
Exemplo n.º 3
0
def setup_vcenter_cloud_mgmt_network(cloud):
    states = [
        'VCENTER_DISCOVERY_COMPLETE_NO_MGMT_NW', 'VCENTER_DISCOVERY_COMPLETE',
        'VCENTER_DISCOVERY_WAITING_DC', 'VCENTER_DISCOVERY_ONGOING'
    ]
    wait_for_vcenter_state(cloud['name'], states)
    logger.debug('Configure cloud management network: %s' % cloud)
    mgmt_name = cloud['vcenter_configuration']['management_network']
    cloud['vcenter_configuration']['management_network'] = \
                        'vimgrruntime?name=%s' %mgmt_name
    status_code, data = put('cloud',
                            name=cloud['name'],
                            data=json.dumps(cloud))
Exemplo n.º 4
0
def test(url):
    print "registered campaigns"
    pp = pprint.PrettyPrinter(indent=4)
    pp.pprint(list(url))

    data = [{
        u'fields': {
            u'accepted_count': -1,
            u'addr_filter': None,
            u'concurrent_scanning': False,
            u'devclass_filter': None,
            u'dongle_name': u'Test Dongle',
            u'enabled': True,
            u'end': None,
            u'fixed_channel': None,
            u'name': u'Test Campaign',
            u'name_filter': u'Test Name',
            u'pin_code': u'test',
            u'rejected_count': 2,
            u'rejected_timeout': -1,
            u'rssi_max': None,
            u'rssi_min': None,
            u'service': 0,
            u'start': None,
            u'tries_count': -1,
            u'tries_timeout': 0,
            u'upload_on_discovered': False
        },
        u'model': u'openproximity.marketingcampaign',
        u'pk': 1
    }]

    print "creating campaign"
    data = json.dumps(data)
    data = json.loads(rest.post(url, klass, data))
    pp.pprint(data)
    print "created"

    print "editing campaign"
    data[0][u'fields'][u'name'] = u'Test 2'
    pk = data[0]['pk']
    data = json.dumps(data)
    data = rest.put(url, klass, pk, data)
    data = json.loads(data)
    pp.pprint(data)

    print "deleting campaign"
    pp.pprint(delete(url, pk))
Exemplo n.º 5
0
def test(url):
    print "registered campaigns"
    pp=pprint.PrettyPrinter(indent=4)
    pp.pprint(list(url))

    data = [{
	u'fields': {
	  u'accepted_count': -1,
	  u'addr_filter': None,
	  u'concurrent_scanning': False,
	  u'devclass_filter': None,
	  u'dongle_name': u'Test Dongle',
	  u'enabled': True,
	  u'end': None,
	  u'fixed_channel': None,
	  u'name': u'Test Campaign',
	  u'name_filter': u'Test Name',
	  u'pin_code': u'test',
	  u'rejected_count': 2,
	  u'rejected_timeout': -1,
	  u'rssi_max': None,
	  u'rssi_min': None,
	  u'service': 0,
	  u'start': None,
	  u'tries_count': -1,
	  u'tries_timeout': 0,
	  u'upload_on_discovered': False
	},
	u'model': u'openproximity.marketingcampaign',
	u'pk': 1
    }]
    
    print "creating campaign"
    data=json.dumps(data)
    data = json.loads(rest.post(url, klass, data))
    pp.pprint(data)
    print "created"
    
    print "editing campaign"
    data[0][u'fields'][u'name']=u'Test 2'
    pk=data[0]['pk']
    data=json.dumps(data)
    data = rest.put(url, klass, pk, data)
    data=json.loads(data)
    pp.pprint(data)

    print "deleting campaign"
    pp.pprint(delete(url, pk))
Exemplo n.º 6
0
def put(url, pk, campaign, chance, data, *args, **kwargs):
    b=( 
	('file', open(data, 'rb')),
	('campaign', campaign),
	('chance', chance),
    )

    datagen, headers = multipart_encode(b)

    return json.loads(
	rest.put(
	    url=url, 
	    klass=klass, 
	    pk=pk,
	    data=''.join(datagen),
	    headers=headers
	)
   )
Exemplo n.º 7
0
def setup_cloud(wait_for_cloud_ready=True, config_file=None):

    if suite_vars.skip_cloud_config:
        logger.info(
            "Skipping cloud config as skip_cloud_config is set to True")
        return
    setup_tb_configuration(pre=True)
    config = get_config()
    ctrl_clouds = config.testbed[config.site_name].cloud
    if config_file:
        config_clouds = get_parsed_json_cloud(config_file)
        if ctrl_clouds:
            ctrl_clouds.append(config_clouds)
        else:
            ctrl_clouds = config_clouds
    if ctrl_clouds:
        for cloud in ctrl_clouds:
            logger.debug('cloud data %s' % cloud)
            name = cloud['name']
            logger.info("Setting Cloud: %s" % name)
            logger.debug("Setting Cloud with %s" % cloud)
            vtype = cloud['vtype']
            if vtype == 'CLOUD_AWS':
                config = get_config()
                tb_name = config.testbed[config.get_mode(key='site_name')].name
                cloud['custom_tags'] = [{
                    'tag_key': 'avitest_tb_tag',
                    'tag_val': tb_name
                }]
            try:
                status_code, data = put('cloud',
                                        name=name,
                                        data=json.dumps(cloud),
                                        check_status_code=False)
            except:
                status_code, data = post('cloud', data=json.dumps(cloud))
            logger.debug("Received for cloud create: %s" % status_code)

            if cloud['vtype'] == "CLOUD_VCENTER":
                setup_vcenter_cloud_mgmt_network(cloud)

    if wait_for_cloud_ready and ctrl_clouds:
        check_cloud_state(clouds=ctrl_clouds)
    setup_tb_configuration()
Exemplo n.º 8
0
def configure_cluster(wait_time=600, **kwargs):
    ignore_follower_reset = kwargs.pop('ignore_follower_reset', False)
    logger.debug("::ignore_follower_reset:: %s" % ignore_follower_reset)
    nodes = []
    controllers = infra_utils.get_vm_of_type('controller')
    ip_list = [vm.ip for vm in controllers]
    leader_ip = ip_list[0]
    ctrl_vm = None
    for vm in controllers:
        if vm.ip == leader_ip:
            ctrl_vm = vm
    for vm in controllers:
        nodes.append({'ip': {'addr': vm.ip, 'type': 'V4'}, 'name': vm.ip})
        if vm.ip != ctrl_vm.ip and not ignore_follower_reset:
            make_follower_ready_for_cluster(vm, **kwargs)
    cluster_obj = {'name': DEFAULT_CLUSTER_NAME, 'nodes': nodes}
    logger.info("configure_cluster with nodes %s" % (nodes))
    st, rsp = put('cluster', data=json.dumps(cluster_obj))
    wait_until_n_cluster_nodes_ready(len(controllers),
                                     wait_time=wait_time,
                                     **kwargs)
Exemplo n.º 9
0
    def putResponse(self, reqURL, data):
        '''
        method calling REST PUT request

        :param reqURL: REST resource url
        :type reqURL: string
        :param data: data body for the request
        :type data: JSON format
        :return: dictionary containing returnCode and buffer
        :rtype: dictionary
        '''

        if self.verbose:
            print 'Req URL: ', reqURL
        res = rest.put(self.switch_ip, reqURL, data, self.verbose)
        if isinstance(res, urllib2.URLError):
            return (555, res.reason)
        else:
            try:
                return (res["response"].status, res["data"])
            except:
                return (res["response"].status, res["response"].reason)
Exemplo n.º 10
0
    def putResponse(self, reqURL, data):
        '''
        method calling REST PUT request

        :param reqURL: REST resource url
        :type reqURL: string
        :param data: data body for the request
        :type data: JSON format
        :return: dictionary containing returnCode and buffer
        :rtype: dictionary
        '''

        if self.verbose:
            print 'Req URL: ', reqURL
        res = rest.put(self.switch_ip, reqURL, data, self.verbose)
        if isinstance(res, urllib2.URLError):
            return (555, res.reason)
        else:
            try:
                return (res["response"].status, res["data"])
            except:
                return (res["response"].status, res["response"].reason)
Exemplo n.º 11
0
def configure_cluster_vip(ipaddr):
    st, rsp = get('cluster')
    virtual_ip = {"addr": ipaddr, "type": 1}
    rsp['virtual_ip'] = {"addr": ipaddr, "type": 1}
    st, rsp = put('cluster', data=json.dumps(rsp))
Exemplo n.º 12
0
def put(url, pk, data, *args, **kwargs):
    data = json.dumps(eval(file(data).read()))
    data, url = rest.put(url, klass, pk, data)
    return json.loads(data), url
Exemplo n.º 13
0
 def send(self, **data):
     put(self.url(), **data)
Exemplo n.º 14
0
def put(url, pk, data, *args, **kwargs):
    data=json.dumps(eval(file(data).read()))
    data, url = rest.put(url, klass, pk, data)
    return json.loads(data), url
Exemplo n.º 15
0
def remove_cluster_vip():
    st, rsp = get('cluster')
    rsp.pop('virtual_ip')
    st, rsp = put('cluster', data=json.dumps(rsp))
Exemplo n.º 16
0
 def send(self, subpath='', **kwargs):
     # ignore connection errors here? #TODO
     put(self.url() + subpath, **kwargs)
Exemplo n.º 17
0
import rest

## test creating and deleting a service
print rest.delete('localhost','/myservice', 8080)
print rest.get('localhost','/myservice', 8080)
print rest.put('localhost', '/myservice', 8080)
print rest.get('localhost','/myservice', 8080)
print rest.delete('localhost','/myservice', 8080)
Exemplo n.º 18
0
import rest

## test creating and deleting a service
print rest.delete('localhost', '/myservice', 8080)
print rest.get('localhost', '/myservice', 8080)
print rest.put('localhost', '/myservice', 8080)
print rest.get('localhost', '/myservice', 8080)
print rest.delete('localhost', '/myservice', 8080)