Skip to content
This repository has been archived by the owner on Nov 27, 2023. It is now read-only.

CCIManager should be not referred now since SL-api has changed it to VSManager #168

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions jumpgate/common/hooks/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@


class APIHooks(object):
# singleton pattern: http://goo.gl/1MtF3B

class __APIHooks:

class __APIHooks(object):
# singleton pattern: http://goo.gl/1MtF3
def __init__(self):
self.reset()

Expand Down
2 changes: 1 addition & 1 deletion jumpgate/compute/drivers/sl/availability_zones.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
class AvailabilityZonesV2(object):
def on_get(self, req, resp, tenant_id):
client = req.env['sl_client']
cci = SoftLayer.CCIManager(client)
cci = SoftLayer.VSManager(client)

all_options = cci.get_create_options()

Expand Down
4 changes: 2 additions & 2 deletions jumpgate/compute/drivers/sl/server_ips.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
class ServerIpsV2(object):
def on_get(self, req, resp, tenant_id, server_id):
client = req.env['sl_client']
cci = SoftLayer.CCIManager(client)
cci = SoftLayer.VSManager(client)

instance = cci.get_instance(
server_id, mask='id, primaryIpAddress, primaryBackendIpAddress')
Expand Down Expand Up @@ -41,7 +41,7 @@ def on_get(self, req, resp, tenant_id, server_id, network_label):
message='Network does not exist')

client = req.env['sl_client']
cci = SoftLayer.CCIManager(client)
cci = SoftLayer.VSManager(client)
instance = cci.get_instance(server_id, mask='id, ' + network_mask)

resp.body = {
Expand Down
14 changes: 7 additions & 7 deletions jumpgate/compute/drivers/sl/servers.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def on_post(self, req, resp, tenant_id, instance_id):
message="Malformed request body")

vg_client = req.env['sl_client']['Virtual_Guest']
cci = SoftLayer.CCIManager(req.env['sl_client'])
cci = SoftLayer.VSManager(req.env['sl_client'])

try:
instance_id = int(instance_id)
Expand Down Expand Up @@ -151,7 +151,7 @@ def __init__(self, app, flavors):

def on_get(self, req, resp, tenant_id):
client = req.env['sl_client']
cci = SoftLayer.CCIManager(client)
cci = SoftLayer.VSManager(client)

params = get_list_params(req)

Expand Down Expand Up @@ -189,7 +189,7 @@ def on_post(self, req, resp, tenant_id):
payload['hourly'] = True

networks = utils.lookup(body, 'server', 'networks')
cci = SoftLayer.CCIManager(client)
cci = SoftLayer.VSManager(client)

try:
self._handle_flavor(payload, body)
Expand Down Expand Up @@ -405,7 +405,7 @@ def __init__(self, app):

def on_get(self, req, resp, tenant_id=None):
client = req.env['sl_client']
cci = SoftLayer.CCIManager(client)
cci = SoftLayer.VSManager(client)

params = get_list_params(req)

Expand All @@ -428,7 +428,7 @@ def __init__(self, app):

def on_get(self, req, resp, tenant_id, server_id):
client = req.env['sl_client']
cci = SoftLayer.CCIManager(client)
cci = SoftLayer.VSManager(client)

instance = cci.get_instance(server_id,
mask=get_virtual_guest_mask())
Expand All @@ -439,7 +439,7 @@ def on_get(self, req, resp, tenant_id, server_id):

def on_delete(self, req, resp, tenant_id, server_id):
client = req.env['sl_client']
cci = SoftLayer.CCIManager(client)
cci = SoftLayer.VSManager(client)

try:
cci.cancel_instance(server_id)
Expand All @@ -454,7 +454,7 @@ def on_delete(self, req, resp, tenant_id, server_id):

def on_put(self, req, resp, tenant_id, server_id):
client = req.env['sl_client']
cci = SoftLayer.CCIManager(client)
cci = SoftLayer.VSManager(client)
body = json.loads(req.stream.read().decode())

if 'name' in utils.lookup(body, 'server'):
Expand Down
2 changes: 1 addition & 1 deletion jumpgate/compute/drivers/sl/usage.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
class UsageV2(object):
def on_get(self, req, resp, tenant_id, target_id):
client = req.env['sl_client']
cci = SoftLayer.CCIManager(client)
cci = SoftLayer.VSManager(client)
start_time = datetime.datetime.now() + datetime.timedelta(hours=-1)
usage = {
'server_usages': [],
Expand Down
2 changes: 1 addition & 1 deletion tests/jumpgate-tests/compute/test_availability_zones.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def setUp(self):
self.tenant_id = '1234'
self.instance = AvailabilityZonesV2()

@patch('SoftLayer.CCIManager.get_create_options')
@patch('SoftLayer.VSManager.get_create_options')
def test_on_get(self, mockOptions):
mockOptions.return_value = {
'datacenters':
Expand Down
10 changes: 5 additions & 5 deletions tests/jumpgate-tests/compute/test_servers.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def perform_server_action(self, body_str, tenant_id,
flavors=flavors)
instance.on_post(self.req, self.resp, tenant_id, instance_id)

@mock.patch('jumpgate.compute.drivers.sl.servers.SoftLayer.CCIManager')
@mock.patch('jumpgate.compute.drivers.sl.servers.SoftLayer.VSManager')
def test_on_post_create(self, cciMock):
body_str = '{"createImage": {"name": "foobar"}}'
self.perform_server_action(body_str, TENANT_ID,
Expand All @@ -52,7 +52,7 @@ def test_on_post_create(self, cciMock):
filter=filterMock, limit=1)
self.assertEquals(self.resp.status, 202)

@mock.patch('jumpgate.compute.drivers.sl.servers.SoftLayer.CCIManager')
@mock.patch('jumpgate.compute.drivers.sl.servers.SoftLayer.VSManager')
def test_on_post_create_fail(self, cciMock):
client, env = get_client_env(body='{"createImage": \
{"name": "foobar"}}')
Expand Down Expand Up @@ -104,7 +104,7 @@ def test_on_post_reboot_default(self):
self.vg_clientMock.rebootDefault.assert_called_with(id=INSTANCE_ID)

@mock.patch('jumpgate.compute.drivers.sl.servers.SoftLayer'
'.CCIManager.upgrade')
'.VSManager.upgrade')
def test_on_post_resize(self, cciMock):
body_str = '{"resize": {"flavorRef": "2"}}'
self.perform_server_action(body_str, TENANT_ID, INSTANCE_ID,
Expand Down Expand Up @@ -155,7 +155,7 @@ def test_on_post_malformed_body(self):

class TestServersServersDetailV2(unittest.TestCase):

@mock.patch('SoftLayer.CCIManager.list_instances')
@mock.patch('SoftLayer.VSManager.list_instances')
def test_on_get(self, mockListInstance):
client, env = get_client_env()
href = u'http://localhost:5000/compute/v2/333582/servers/4846014'
Expand Down Expand Up @@ -251,7 +251,7 @@ class TestServerDetail(unittest.TestCase):
in the response, but are specified in the Openstack API reference.
Will add later when there is support.
'''
@mock.patch('jumpgate.compute.drivers.sl.servers.SoftLayer.CCIManager'
@mock.patch('jumpgate.compute.drivers.sl.servers.SoftLayer.VSManager'
'.get_instance')
def perform_server_detail(self, tenant_id, server_id, get_instance_mock):
self.client, self.env = get_client_env()
Expand Down