merged trunk
This commit is contained in:
@@ -518,7 +518,7 @@ class FixedIpCommands(object):
|
||||
instance = fixed_ip['instance']
|
||||
hostname = instance['hostname']
|
||||
host = instance['host']
|
||||
mac_address = fixed_ip['mac_address']['address']
|
||||
mac_address = fixed_ip['virtual_interface']['address']
|
||||
print "%-18s\t%-15s\t%-17s\t%-15s\t%s" % (
|
||||
fixed_ip['network']['cidr'],
|
||||
fixed_ip['address'],
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
import mox
|
||||
|
||||
from base64 import b64decode
|
||||
from M2Crypto import BIO
|
||||
@@ -29,6 +30,7 @@ from nova import db
|
||||
from nova import exception
|
||||
from nova import flags
|
||||
from nova import log as logging
|
||||
from nova import network
|
||||
from nova import rpc
|
||||
from nova import test
|
||||
from nova import utils
|
||||
@@ -132,6 +134,33 @@ class CloudTestCase(test.TestCase):
|
||||
allocate,
|
||||
self.context)
|
||||
|
||||
def test_release_address(self):
|
||||
address = "10.10.10.10"
|
||||
allocate = self.cloud.allocate_address
|
||||
db.floating_ip_create(self.context,
|
||||
{'address': address,
|
||||
'host': self.network.host})
|
||||
result = self.cloud.release_address(self.context, address)
|
||||
self.assertEqual(result['releaseResponse'], ['Address released.'])
|
||||
|
||||
def test_release_address_still_associated(self):
|
||||
address = "10.10.10.10"
|
||||
fixed_ip = {'instance': {'id': 1}}
|
||||
floating_ip = {'id': 0,
|
||||
'address': address,
|
||||
'fixed_ip_id': 0,
|
||||
'fixed_ip': fixed_ip,
|
||||
'project_id': None,
|
||||
'auto_assigned': False}
|
||||
network_api = network.api.API()
|
||||
self.mox.StubOutWithMock(network_api.db, 'floating_ip_get_by_address')
|
||||
network_api.db.floating_ip_get_by_address(mox.IgnoreArg(),
|
||||
mox.IgnoreArg()).AndReturn(floating_ip)
|
||||
self.mox.ReplayAll()
|
||||
release = self.cloud.release_address
|
||||
# ApiError: Floating ip is in use. Disassociate it before releasing.
|
||||
self.assertRaises(exception.ApiError, release, self.context, address)
|
||||
|
||||
@test.skip_test("Skipping this pending future merge")
|
||||
def test_associate_disassociate_address(self):
|
||||
"""Verifies associate runs cleanly without raising an exception"""
|
||||
|
||||
@@ -519,6 +519,57 @@ class ComputeTestCase(test.TestCase):
|
||||
|
||||
self.compute.terminate_instance(context, instance_id)
|
||||
|
||||
def test_finish_revert_resize(self):
|
||||
"""Ensure that the flavor is reverted to the original on revert"""
|
||||
context = self.context.elevated()
|
||||
instance_id = self._create_instance()
|
||||
|
||||
def fake(*args, **kwargs):
|
||||
pass
|
||||
|
||||
self.stubs.Set(self.compute.driver, 'finish_resize', fake)
|
||||
self.stubs.Set(self.compute.driver, 'revert_resize', fake)
|
||||
self.stubs.Set(self.compute.network_api, 'get_instance_nw_info', fake)
|
||||
|
||||
self.compute.run_instance(self.context, instance_id)
|
||||
|
||||
# Confirm the instance size before the resize starts
|
||||
inst_ref = db.instance_get(context, instance_id)
|
||||
instance_type_ref = db.instance_type_get_by_id(context,
|
||||
inst_ref['instance_type_id'])
|
||||
self.assertEqual(instance_type_ref['flavorid'], 1)
|
||||
|
||||
db.instance_update(self.context, instance_id, {'host': 'foo'})
|
||||
|
||||
self.compute.prep_resize(context, instance_id, 3)
|
||||
|
||||
migration_ref = db.migration_get_by_instance_and_status(context,
|
||||
instance_id, 'pre-migrating')
|
||||
|
||||
self.compute.resize_instance(context, instance_id,
|
||||
migration_ref['id'])
|
||||
self.compute.finish_resize(context, instance_id,
|
||||
int(migration_ref['id']), {})
|
||||
|
||||
# Prove that the instance size is now the new size
|
||||
inst_ref = db.instance_get(context, instance_id)
|
||||
instance_type_ref = db.instance_type_get_by_id(context,
|
||||
inst_ref['instance_type_id'])
|
||||
self.assertEqual(instance_type_ref['flavorid'], 3)
|
||||
|
||||
# Finally, revert and confirm the old flavor has been applied
|
||||
self.compute.revert_resize(context, instance_id,
|
||||
migration_ref['id'])
|
||||
self.compute.finish_revert_resize(context, instance_id,
|
||||
migration_ref['id'])
|
||||
|
||||
inst_ref = db.instance_get(context, instance_id)
|
||||
instance_type_ref = db.instance_type_get_by_id(context,
|
||||
inst_ref['instance_type_id'])
|
||||
self.assertEqual(instance_type_ref['flavorid'], 1)
|
||||
|
||||
self.compute.terminate_instance(context, instance_id)
|
||||
|
||||
def test_get_by_flavor_id(self):
|
||||
type = instance_types.get_instance_type_by_flavor_id(1)
|
||||
self.assertEqual(type['name'], 'm1.tiny')
|
||||
|
||||
Reference in New Issue
Block a user