Fix API to not use the deprecated CPHP Export() function

feature/node-rewrite
Sven Slootweg 12 years ago
parent 02f399a469
commit 392dd6fbe5

@ -59,22 +59,23 @@ def api_request(parameters, method="GET"):
querystring = urllib.urlencode(parameters)
req = urllib2.Request(endpoint + "?" + querystring)
response = urllib2.urlopen(req)
return json.loads(response.read())
result = response.read()
return json.loads(result)
def show_list():
print ""
for key, vps in vpsmap.items():
node = nodemap[vps['NodeId']]
print "%s. %s (%s [%s], %s)" % (key, vps['Hostname'], node['Name'], node['Hostname'], node['PhysicalLocation'])
node = nodemap[vps['node_id']]
print "%s. %s (%s [%s], %s)" % (key, vps['hostname'], node['name'], node['hostname'], node['physical_location'])
print ""
choice = raw_input("Make your choice: ")
try:
current_vps = vpsmap[int(choice)]
current_node = nodemap[current_vps['NodeId']]
current_node = nodemap[current_vps['node_id']]
open_shell(current_node['Hostname'], "vz", current_vps['InternalId'])
open_shell(current_node['hostname'], "vz", current_vps['internal_id'])
except KeyError, ValueError:
print "That was not a valid option. Try again. "
show_list()
@ -114,8 +115,8 @@ if auth_result['data']['correct'] == True:
for vps in vpslist["data"]:
vpsmap[i] = vps
if vps["NodeId"] not in nodelist:
nodelist.append(vps["NodeId"])
if vps["node_id"] not in nodelist:
nodelist.append(vps["node_id"])
i += 1

@ -66,13 +66,17 @@ if(isset($_GET['key']) && $_GET['key'] == $settings['local_api_key'])
if($result = mysql_query_cached($query))
{
// TODO: output results
$sContainers = array();
foreach($result->data as $row)
{
$sContainer = new Container($row);
$sContainers[] = $sContainer->Export();
$sContainers[] = array(
'hostname' => $sContainer->sHostname,
'internal_id' => $sContainer->sInternalId,
'node_id' => $sContainer->sNodeId,
'status' => $sContainer->sStatus
);
}
$return_object = $sContainers;
@ -88,7 +92,16 @@ if(isset($_GET['key']) && $_GET['key'] == $settings['local_api_key'])
try
{
$sNode = new Node($_GET['nodeid']);
$return_object = $sNode->Export();
$return_object = array(
'name' => $sNode->sName,
'hostname' => $sNode->sHostname,
'port' => $sNode->sPort,
'user' => $sNode->sUser,
'physical_location' => $sNode->sPhysicalLocation,
'private_key' => $sNode->sPrivateKey,
'public_key' => $sNode->sPublicKey,
'has_custom_key' => $sNode->sHasCustomKey
);
}
catch (NotFoundException $e)
{

@ -54,13 +54,6 @@ class Container extends CPHPDatabaseRecordClass
)
);
public $prototype_export = array(
'Hostname',
'InternalId',
'NodeId',
'Status'
);
public function __get($name)
{
switch($name)

@ -36,17 +36,6 @@ class Node extends CPHPDatabaseRecordClass
)
);
public $prototype_export = array(
'Name',
'Hostname',
'Port',
'User',
'PhysicalLocation',
'PrivateKey',
'PublicKey',
'HasCustomkey'
);
public $ssh = null;
protected function EventConstructed()

Loading…
Cancel
Save