Switch server backup to sdk.
Switch this command from novaclient to SDK. As this is the first command related to server that we are migrating, we need to extend our test fakes to support fake Server resources. The extended fakes will replace the old ones once all commands related to server are switched. Change-Id: If476fb1614a64320ed071bbda35e941bf3290a2e
This commit is contained in:
parent
53debe7fe1
commit
57aad01886
@ -72,12 +72,9 @@ class CreateServerBackup(command.ShowOne):
|
|||||||
self.app.stderr.write('\rProgress: %s' % progress)
|
self.app.stderr.write('\rProgress: %s' % progress)
|
||||||
self.app.stderr.flush()
|
self.app.stderr.flush()
|
||||||
|
|
||||||
compute_client = self.app.client_manager.compute
|
compute_client = self.app.client_manager.sdk_connection.compute
|
||||||
|
|
||||||
server = utils.find_resource(
|
server = compute_client.find_server(parsed_args.server)
|
||||||
compute_client.servers,
|
|
||||||
parsed_args.server,
|
|
||||||
)
|
|
||||||
|
|
||||||
# Set sane defaults as this API wants all mouths to be fed
|
# Set sane defaults as this API wants all mouths to be fed
|
||||||
if parsed_args.name is None:
|
if parsed_args.name is None:
|
||||||
@ -93,7 +90,7 @@ class CreateServerBackup(command.ShowOne):
|
|||||||
else:
|
else:
|
||||||
backup_rotation = parsed_args.rotate
|
backup_rotation = parsed_args.rotate
|
||||||
|
|
||||||
compute_client.servers.backup(
|
compute_client.backup_server(
|
||||||
server.id,
|
server.id,
|
||||||
backup_name,
|
backup_name,
|
||||||
backup_type,
|
backup_type,
|
||||||
|
@ -20,6 +20,7 @@ import uuid
|
|||||||
|
|
||||||
from novaclient import api_versions
|
from novaclient import api_versions
|
||||||
from openstack.compute.v2 import flavor as _flavor
|
from openstack.compute.v2 import flavor as _flavor
|
||||||
|
from openstack.compute.v2 import server
|
||||||
|
|
||||||
from openstackclient.api import compute_v2
|
from openstackclient.api import compute_v2
|
||||||
from openstackclient.tests.unit import fakes
|
from openstackclient.tests.unit import fakes
|
||||||
@ -73,7 +74,7 @@ class FakeAggregate(object):
|
|||||||
def create_one_aggregate(attrs=None):
|
def create_one_aggregate(attrs=None):
|
||||||
"""Create a fake aggregate.
|
"""Create a fake aggregate.
|
||||||
|
|
||||||
:param Dictionary attrs:
|
:param dict attrs:
|
||||||
A dictionary with all attributes
|
A dictionary with all attributes
|
||||||
:return:
|
:return:
|
||||||
A FakeResource object, with id and other attributes
|
A FakeResource object, with id and other attributes
|
||||||
@ -104,7 +105,7 @@ class FakeAggregate(object):
|
|||||||
def create_aggregates(attrs=None, count=2):
|
def create_aggregates(attrs=None, count=2):
|
||||||
"""Create multiple fake aggregates.
|
"""Create multiple fake aggregates.
|
||||||
|
|
||||||
:param Dictionary attrs:
|
:param dict attrs:
|
||||||
A dictionary with all attributes
|
A dictionary with all attributes
|
||||||
:param int count:
|
:param int count:
|
||||||
The number of aggregates to fake
|
The number of aggregates to fake
|
||||||
@ -255,7 +256,7 @@ class FakeAgent(object):
|
|||||||
def create_one_agent(attrs=None):
|
def create_one_agent(attrs=None):
|
||||||
"""Create a fake agent.
|
"""Create a fake agent.
|
||||||
|
|
||||||
:param Dictionary attrs:
|
:param dict attrs:
|
||||||
A dictionary with all attributes
|
A dictionary with all attributes
|
||||||
:return:
|
:return:
|
||||||
A FakeResource object, with agent_id, os, and so on
|
A FakeResource object, with agent_id, os, and so on
|
||||||
@ -285,7 +286,7 @@ class FakeAgent(object):
|
|||||||
def create_agents(attrs=None, count=2):
|
def create_agents(attrs=None, count=2):
|
||||||
"""Create multiple fake agents.
|
"""Create multiple fake agents.
|
||||||
|
|
||||||
:param Dictionary attrs:
|
:param dict attrs:
|
||||||
A dictionary with all attributes
|
A dictionary with all attributes
|
||||||
:param int count:
|
:param int count:
|
||||||
The number of agents to fake
|
The number of agents to fake
|
||||||
@ -306,7 +307,7 @@ class FakeExtension(object):
|
|||||||
def create_one_extension(attrs=None):
|
def create_one_extension(attrs=None):
|
||||||
"""Create a fake extension.
|
"""Create a fake extension.
|
||||||
|
|
||||||
:param Dictionary attrs:
|
:param dict attrs:
|
||||||
A dictionary with all attributes
|
A dictionary with all attributes
|
||||||
:return:
|
:return:
|
||||||
A FakeResource object with name, namespace, etc.
|
A FakeResource object with name, namespace, etc.
|
||||||
@ -342,7 +343,7 @@ class FakeHypervisor(object):
|
|||||||
def create_one_hypervisor(attrs=None):
|
def create_one_hypervisor(attrs=None):
|
||||||
"""Create a fake hypervisor.
|
"""Create a fake hypervisor.
|
||||||
|
|
||||||
:param Dictionary attrs:
|
:param dict attrs:
|
||||||
A dictionary with all attributes
|
A dictionary with all attributes
|
||||||
:return:
|
:return:
|
||||||
A FakeResource object, with id, hypervisor_hostname, and so on
|
A FakeResource object, with id, hypervisor_hostname, and so on
|
||||||
@ -390,7 +391,7 @@ class FakeHypervisor(object):
|
|||||||
def create_hypervisors(attrs=None, count=2):
|
def create_hypervisors(attrs=None, count=2):
|
||||||
"""Create multiple fake hypervisors.
|
"""Create multiple fake hypervisors.
|
||||||
|
|
||||||
:param Dictionary attrs:
|
:param dict attrs:
|
||||||
A dictionary with all attributes
|
A dictionary with all attributes
|
||||||
:param int count:
|
:param int count:
|
||||||
The number of hypervisors to fake
|
The number of hypervisors to fake
|
||||||
@ -411,7 +412,7 @@ class FakeHypervisorStats(object):
|
|||||||
def create_one_hypervisor_stats(attrs=None):
|
def create_one_hypervisor_stats(attrs=None):
|
||||||
"""Create a fake hypervisor stats.
|
"""Create a fake hypervisor stats.
|
||||||
|
|
||||||
:param Dictionary attrs:
|
:param dict attrs:
|
||||||
A dictionary with all attributes
|
A dictionary with all attributes
|
||||||
:return:
|
:return:
|
||||||
A FakeResource object, with count, current_workload, and so on
|
A FakeResource object, with count, current_workload, and so on
|
||||||
@ -450,7 +451,7 @@ class FakeHypervisorStats(object):
|
|||||||
def create_hypervisors_stats(attrs=None, count=2):
|
def create_hypervisors_stats(attrs=None, count=2):
|
||||||
"""Create multiple fake hypervisors stats.
|
"""Create multiple fake hypervisors stats.
|
||||||
|
|
||||||
:param Dictionary attrs:
|
:param dict attrs:
|
||||||
A dictionary with all attributes
|
A dictionary with all attributes
|
||||||
:param int count:
|
:param int count:
|
||||||
The number of hypervisors to fake
|
The number of hypervisors to fake
|
||||||
@ -472,7 +473,7 @@ class FakeSecurityGroup(object):
|
|||||||
def create_one_security_group(attrs=None):
|
def create_one_security_group(attrs=None):
|
||||||
"""Create a fake security group.
|
"""Create a fake security group.
|
||||||
|
|
||||||
:param Dictionary attrs:
|
:param dict attrs:
|
||||||
A dictionary with all attributes
|
A dictionary with all attributes
|
||||||
:return:
|
:return:
|
||||||
A FakeResource object, with id, name, etc.
|
A FakeResource object, with id, name, etc.
|
||||||
@ -496,7 +497,7 @@ class FakeSecurityGroup(object):
|
|||||||
def create_security_groups(attrs=None, count=2):
|
def create_security_groups(attrs=None, count=2):
|
||||||
"""Create multiple fake security groups.
|
"""Create multiple fake security groups.
|
||||||
|
|
||||||
:param Dictionary attrs:
|
:param dict attrs:
|
||||||
A dictionary with all attributes
|
A dictionary with all attributes
|
||||||
:param int count:
|
:param int count:
|
||||||
The number of security groups to fake
|
The number of security groups to fake
|
||||||
@ -537,7 +538,7 @@ class FakeSecurityGroupRule(object):
|
|||||||
def create_one_security_group_rule(attrs=None):
|
def create_one_security_group_rule(attrs=None):
|
||||||
"""Create a fake security group rule.
|
"""Create a fake security group rule.
|
||||||
|
|
||||||
:param Dictionary attrs:
|
:param dict attrs:
|
||||||
A dictionary with all attributes
|
A dictionary with all attributes
|
||||||
:return:
|
:return:
|
||||||
A FakeResource object, with id, etc.
|
A FakeResource object, with id, etc.
|
||||||
@ -564,7 +565,7 @@ class FakeSecurityGroupRule(object):
|
|||||||
def create_security_group_rules(attrs=None, count=2):
|
def create_security_group_rules(attrs=None, count=2):
|
||||||
"""Create multiple fake security group rules.
|
"""Create multiple fake security group rules.
|
||||||
|
|
||||||
:param Dictionary attrs:
|
:param dict attrs:
|
||||||
A dictionary with all attributes
|
A dictionary with all attributes
|
||||||
:param int count:
|
:param int count:
|
||||||
The number of security group rules to fake
|
The number of security group rules to fake
|
||||||
@ -586,9 +587,9 @@ class FakeServer(object):
|
|||||||
def create_one_server(attrs=None, methods=None):
|
def create_one_server(attrs=None, methods=None):
|
||||||
"""Create a fake server.
|
"""Create a fake server.
|
||||||
|
|
||||||
:param Dictionary attrs:
|
:param dict attrs:
|
||||||
A dictionary with all attributes
|
A dictionary with all attributes
|
||||||
:param Dictionary methods:
|
:param dict methods:
|
||||||
A dictionary with all methods
|
A dictionary with all methods
|
||||||
:return:
|
:return:
|
||||||
A FakeResource object, with id, name, metadata, and so on
|
A FakeResource object, with id, name, metadata, and so on
|
||||||
@ -622,9 +623,9 @@ class FakeServer(object):
|
|||||||
def create_servers(attrs=None, methods=None, count=2):
|
def create_servers(attrs=None, methods=None, count=2):
|
||||||
"""Create multiple fake servers.
|
"""Create multiple fake servers.
|
||||||
|
|
||||||
:param Dictionary attrs:
|
:param dict attrs:
|
||||||
A dictionary with all attributes
|
A dictionary with all attributes
|
||||||
:param Dictionary methods:
|
:param dict methods:
|
||||||
A dictionary with all methods
|
A dictionary with all methods
|
||||||
:param int count:
|
:param int count:
|
||||||
The number of servers to fake
|
The number of servers to fake
|
||||||
@ -637,6 +638,59 @@ class FakeServer(object):
|
|||||||
|
|
||||||
return servers
|
return servers
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def create_one_sdk_server(attrs=None, methods=None):
|
||||||
|
"""Create a fake server for testing migration to sdk
|
||||||
|
|
||||||
|
:param dict attrs:
|
||||||
|
A dictionary with all attributes
|
||||||
|
:param dict methods:
|
||||||
|
A dictionary with all methods
|
||||||
|
:return:
|
||||||
|
A openstack.compute.v2.server.Server object,
|
||||||
|
with id, name, metadata, and so on
|
||||||
|
"""
|
||||||
|
attrs = attrs or {}
|
||||||
|
methods = methods or {}
|
||||||
|
|
||||||
|
# Set default attributes.
|
||||||
|
server_info = {
|
||||||
|
'id': 'server-id-' + uuid.uuid4().hex,
|
||||||
|
'name': 'server-name-' + uuid.uuid4().hex,
|
||||||
|
'metadata': {},
|
||||||
|
'image': {
|
||||||
|
'id': 'image-id-' + uuid.uuid4().hex,
|
||||||
|
},
|
||||||
|
'flavor': {
|
||||||
|
'id': 'flavor-id-' + uuid.uuid4().hex,
|
||||||
|
},
|
||||||
|
'OS-EXT-STS:power_state': 1,
|
||||||
|
}
|
||||||
|
|
||||||
|
# Overwrite default attributes.
|
||||||
|
server_info.update(attrs)
|
||||||
|
return server.Server(**server_info)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def create_sdk_servers(attrs=None, methods=None, count=2):
|
||||||
|
"""Create multiple fake servers for testing migration to sdk
|
||||||
|
|
||||||
|
:param dict attrs:
|
||||||
|
A dictionary with all attributes
|
||||||
|
:param dict methods:
|
||||||
|
A dictionary with all methods
|
||||||
|
:param int count:
|
||||||
|
The number of servers to fake
|
||||||
|
:return:
|
||||||
|
A list of openstack.compute.v2.server.Server objects
|
||||||
|
faking the servers
|
||||||
|
"""
|
||||||
|
servers = []
|
||||||
|
for i in range(0, count):
|
||||||
|
servers.append(FakeServer.create_one_sdk_server(attrs, methods))
|
||||||
|
|
||||||
|
return servers
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_servers(servers=None, count=2):
|
def get_servers(servers=None, count=2):
|
||||||
"""Get an iterable MagicMock object with a list of faked servers.
|
"""Get an iterable MagicMock object with a list of faked servers.
|
||||||
@ -705,7 +759,7 @@ class FakeService(object):
|
|||||||
def create_one_service(attrs=None):
|
def create_one_service(attrs=None):
|
||||||
"""Create a fake service.
|
"""Create a fake service.
|
||||||
|
|
||||||
:param Dictionary attrs:
|
:param dict attrs:
|
||||||
A dictionary with all attributes
|
A dictionary with all attributes
|
||||||
:return:
|
:return:
|
||||||
A FakeResource object, with id, host, binary, and so on
|
A FakeResource object, with id, host, binary, and so on
|
||||||
@ -738,7 +792,7 @@ class FakeService(object):
|
|||||||
def create_services(attrs=None, count=2):
|
def create_services(attrs=None, count=2):
|
||||||
"""Create multiple fake services.
|
"""Create multiple fake services.
|
||||||
|
|
||||||
:param Dictionary attrs:
|
:param dict attrs:
|
||||||
A dictionary with all attributes
|
A dictionary with all attributes
|
||||||
:param int count:
|
:param int count:
|
||||||
The number of services to fake
|
The number of services to fake
|
||||||
@ -759,7 +813,7 @@ class FakeFlavor(object):
|
|||||||
def create_one_flavor(attrs=None):
|
def create_one_flavor(attrs=None):
|
||||||
"""Create a fake flavor.
|
"""Create a fake flavor.
|
||||||
|
|
||||||
:param Dictionary attrs:
|
:param dict attrs:
|
||||||
A dictionary with all attributes
|
A dictionary with all attributes
|
||||||
:return:
|
:return:
|
||||||
A FakeResource object, with id, name, ram, vcpus, and so on
|
A FakeResource object, with id, name, ram, vcpus, and so on
|
||||||
@ -793,7 +847,7 @@ class FakeFlavor(object):
|
|||||||
def create_flavors(attrs=None, count=2):
|
def create_flavors(attrs=None, count=2):
|
||||||
"""Create multiple fake flavors.
|
"""Create multiple fake flavors.
|
||||||
|
|
||||||
:param Dictionary attrs:
|
:param dict attrs:
|
||||||
A dictionary with all attributes
|
A dictionary with all attributes
|
||||||
:param int count:
|
:param int count:
|
||||||
The number of flavors to fake
|
The number of flavors to fake
|
||||||
@ -833,7 +887,7 @@ class FakeFlavorAccess(object):
|
|||||||
def create_one_flavor_access(attrs=None):
|
def create_one_flavor_access(attrs=None):
|
||||||
"""Create a fake flavor access.
|
"""Create a fake flavor access.
|
||||||
|
|
||||||
:param Dictionary attrs:
|
:param dict attrs:
|
||||||
A dictionary with all attributes
|
A dictionary with all attributes
|
||||||
:return:
|
:return:
|
||||||
A FakeResource object, with flavor_id, tenat_id
|
A FakeResource object, with flavor_id, tenat_id
|
||||||
@ -862,7 +916,7 @@ class FakeKeypair(object):
|
|||||||
def create_one_keypair(attrs=None, no_pri=False):
|
def create_one_keypair(attrs=None, no_pri=False):
|
||||||
"""Create a fake keypair
|
"""Create a fake keypair
|
||||||
|
|
||||||
:param Dictionary attrs:
|
:param dict attrs:
|
||||||
A dictionary with all attributes
|
A dictionary with all attributes
|
||||||
:return:
|
:return:
|
||||||
A FakeResource object, name, fingerprint, and so on
|
A FakeResource object, name, fingerprint, and so on
|
||||||
@ -892,7 +946,7 @@ class FakeKeypair(object):
|
|||||||
def create_keypairs(attrs=None, count=2):
|
def create_keypairs(attrs=None, count=2):
|
||||||
"""Create multiple fake keypairs.
|
"""Create multiple fake keypairs.
|
||||||
|
|
||||||
:param Dictionary attrs:
|
:param dict attrs:
|
||||||
A dictionary with all attributes
|
A dictionary with all attributes
|
||||||
:param int count:
|
:param int count:
|
||||||
The number of keypairs to fake
|
The number of keypairs to fake
|
||||||
@ -933,7 +987,7 @@ class FakeAvailabilityZone(object):
|
|||||||
def create_one_availability_zone(attrs=None):
|
def create_one_availability_zone(attrs=None):
|
||||||
"""Create a fake AZ.
|
"""Create a fake AZ.
|
||||||
|
|
||||||
:param Dictionary attrs:
|
:param dict attrs:
|
||||||
A dictionary with all attributes
|
A dictionary with all attributes
|
||||||
:return:
|
:return:
|
||||||
A FakeResource object with zoneName, zoneState, etc.
|
A FakeResource object with zoneName, zoneState, etc.
|
||||||
@ -966,7 +1020,7 @@ class FakeAvailabilityZone(object):
|
|||||||
def create_availability_zones(attrs=None, count=2):
|
def create_availability_zones(attrs=None, count=2):
|
||||||
"""Create multiple fake AZs.
|
"""Create multiple fake AZs.
|
||||||
|
|
||||||
:param Dictionary attrs:
|
:param dict attrs:
|
||||||
A dictionary with all attributes
|
A dictionary with all attributes
|
||||||
:param int count:
|
:param int count:
|
||||||
The number of AZs to fake
|
The number of AZs to fake
|
||||||
@ -989,7 +1043,7 @@ class FakeFloatingIP(object):
|
|||||||
def create_one_floating_ip(attrs=None):
|
def create_one_floating_ip(attrs=None):
|
||||||
"""Create a fake floating ip.
|
"""Create a fake floating ip.
|
||||||
|
|
||||||
:param Dictionary attrs:
|
:param dict attrs:
|
||||||
A dictionary with all attributes
|
A dictionary with all attributes
|
||||||
:return:
|
:return:
|
||||||
A FakeResource object, with id, ip, and so on
|
A FakeResource object, with id, ip, and so on
|
||||||
@ -1014,7 +1068,7 @@ class FakeFloatingIP(object):
|
|||||||
def create_floating_ips(attrs=None, count=2):
|
def create_floating_ips(attrs=None, count=2):
|
||||||
"""Create multiple fake floating ips.
|
"""Create multiple fake floating ips.
|
||||||
|
|
||||||
:param Dictionary attrs:
|
:param dict attrs:
|
||||||
A dictionary with all attributes
|
A dictionary with all attributes
|
||||||
:param int count:
|
:param int count:
|
||||||
The number of floating ips to fake
|
The number of floating ips to fake
|
||||||
@ -1053,7 +1107,7 @@ class FakeFloatingIPPool(object):
|
|||||||
def create_one_floating_ip_pool(attrs=None):
|
def create_one_floating_ip_pool(attrs=None):
|
||||||
"""Create a fake floating ip pool.
|
"""Create a fake floating ip pool.
|
||||||
|
|
||||||
:param Dictionary attrs:
|
:param dict attrs:
|
||||||
A dictionary with all attributes
|
A dictionary with all attributes
|
||||||
:return:
|
:return:
|
||||||
A FakeResource object, with name, etc
|
A FakeResource object, with name, etc
|
||||||
@ -1075,7 +1129,7 @@ class FakeFloatingIPPool(object):
|
|||||||
def create_floating_ip_pools(attrs=None, count=2):
|
def create_floating_ip_pools(attrs=None, count=2):
|
||||||
"""Create multiple fake floating ip pools.
|
"""Create multiple fake floating ip pools.
|
||||||
|
|
||||||
:param Dictionary attrs:
|
:param dict attrs:
|
||||||
A dictionary with all attributes
|
A dictionary with all attributes
|
||||||
:param int count:
|
:param int count:
|
||||||
The number of floating ip pools to fake
|
The number of floating ip pools to fake
|
||||||
@ -1097,7 +1151,7 @@ class FakeNetwork(object):
|
|||||||
def create_one_network(attrs=None):
|
def create_one_network(attrs=None):
|
||||||
"""Create a fake network.
|
"""Create a fake network.
|
||||||
|
|
||||||
:param Dictionary attrs:
|
:param dict attrs:
|
||||||
A dictionary with all attributes
|
A dictionary with all attributes
|
||||||
:return:
|
:return:
|
||||||
A FakeResource object, with id, label, cidr and so on
|
A FakeResource object, with id, label, cidr and so on
|
||||||
@ -1149,7 +1203,7 @@ class FakeNetwork(object):
|
|||||||
def create_networks(attrs=None, count=2):
|
def create_networks(attrs=None, count=2):
|
||||||
"""Create multiple fake networks.
|
"""Create multiple fake networks.
|
||||||
|
|
||||||
:param Dictionary attrs:
|
:param dict attrs:
|
||||||
A dictionary with all attributes
|
A dictionary with all attributes
|
||||||
:param int count:
|
:param int count:
|
||||||
The number of networks to fake
|
The number of networks to fake
|
||||||
@ -1189,7 +1243,7 @@ class FakeHost(object):
|
|||||||
def create_one_host(attrs=None):
|
def create_one_host(attrs=None):
|
||||||
"""Create a fake host.
|
"""Create a fake host.
|
||||||
|
|
||||||
:param Dictionary attrs:
|
:param dict attrs:
|
||||||
A dictionary with all attributes
|
A dictionary with all attributes
|
||||||
:return:
|
:return:
|
||||||
A FakeResource object, with uuid and other attributes
|
A FakeResource object, with uuid and other attributes
|
||||||
@ -1243,7 +1297,7 @@ class FakeServerGroup(object):
|
|||||||
def _create_one_server_group(attrs=None):
|
def _create_one_server_group(attrs=None):
|
||||||
"""Create a fake server group
|
"""Create a fake server group
|
||||||
|
|
||||||
:param Dictionary attrs:
|
:param dict attrs:
|
||||||
A dictionary with all attributes
|
A dictionary with all attributes
|
||||||
:return:
|
:return:
|
||||||
A FakeResource object, with id and other attributes
|
A FakeResource object, with id and other attributes
|
||||||
@ -1273,7 +1327,7 @@ class FakeServerGroup(object):
|
|||||||
def create_one_server_group(attrs=None):
|
def create_one_server_group(attrs=None):
|
||||||
"""Create a fake server group
|
"""Create a fake server group
|
||||||
|
|
||||||
:param Dictionary attrs:
|
:param dict attrs:
|
||||||
A dictionary with all attributes
|
A dictionary with all attributes
|
||||||
:return:
|
:return:
|
||||||
A FakeResource object, with id and other attributes
|
A FakeResource object, with id and other attributes
|
||||||
@ -1291,7 +1345,7 @@ class FakeServerGroupV264(object):
|
|||||||
def create_one_server_group(attrs=None):
|
def create_one_server_group(attrs=None):
|
||||||
"""Create a fake server group
|
"""Create a fake server group
|
||||||
|
|
||||||
:param Dictionary attrs:
|
:param dict attrs:
|
||||||
A dictionary with all attributes
|
A dictionary with all attributes
|
||||||
:return:
|
:return:
|
||||||
A FakeResource object, with id and other attributes
|
A FakeResource object, with id and other attributes
|
||||||
@ -1309,7 +1363,7 @@ class FakeUsage(object):
|
|||||||
def create_one_usage(attrs=None):
|
def create_one_usage(attrs=None):
|
||||||
"""Create a fake usage.
|
"""Create a fake usage.
|
||||||
|
|
||||||
:param Dictionary attrs:
|
:param dict attrs:
|
||||||
A dictionary with all attributes
|
A dictionary with all attributes
|
||||||
:return:
|
:return:
|
||||||
A FakeResource object, with tenant_id and other attributes
|
A FakeResource object, with tenant_id and other attributes
|
||||||
@ -1351,7 +1405,7 @@ class FakeUsage(object):
|
|||||||
def create_usages(attrs=None, count=2):
|
def create_usages(attrs=None, count=2):
|
||||||
"""Create multiple fake services.
|
"""Create multiple fake services.
|
||||||
|
|
||||||
:param Dictionary attrs:
|
:param dict attrs:
|
||||||
A dictionary with all attributes
|
A dictionary with all attributes
|
||||||
:param int count:
|
:param int count:
|
||||||
The number of services to fake
|
The number of services to fake
|
||||||
@ -1575,9 +1629,9 @@ class FakeMigration(object):
|
|||||||
def create_one_migration(attrs=None, methods=None):
|
def create_one_migration(attrs=None, methods=None):
|
||||||
"""Create a fake migration.
|
"""Create a fake migration.
|
||||||
|
|
||||||
:param Dictionary attrs:
|
:param dict attrs:
|
||||||
A dictionary with all attributes
|
A dictionary with all attributes
|
||||||
:param Dictionary methods:
|
:param dict methods:
|
||||||
A dictionary with all methods
|
A dictionary with all methods
|
||||||
:return:
|
:return:
|
||||||
A FakeResource object, with id, type, and so on
|
A FakeResource object, with id, type, and so on
|
||||||
@ -1617,9 +1671,9 @@ class FakeMigration(object):
|
|||||||
def create_migrations(attrs=None, methods=None, count=2):
|
def create_migrations(attrs=None, methods=None, count=2):
|
||||||
"""Create multiple fake migrations.
|
"""Create multiple fake migrations.
|
||||||
|
|
||||||
:param Dictionary attrs:
|
:param dict attrs:
|
||||||
A dictionary with all attributes
|
A dictionary with all attributes
|
||||||
:param Dictionary methods:
|
:param dict methods:
|
||||||
A dictionary with all methods
|
A dictionary with all methods
|
||||||
:param int count:
|
:param int count:
|
||||||
The number of migrations to fake
|
The number of migrations to fake
|
||||||
@ -1642,9 +1696,9 @@ class FakeServerMigration(object):
|
|||||||
def create_one_server_migration(attrs=None, methods=None):
|
def create_one_server_migration(attrs=None, methods=None):
|
||||||
"""Create a fake server migration.
|
"""Create a fake server migration.
|
||||||
|
|
||||||
:param Dictionary attrs:
|
:param dict attrs:
|
||||||
A dictionary with all attributes
|
A dictionary with all attributes
|
||||||
:param Dictionary methods:
|
:param dict methods:
|
||||||
A dictionary with all methods
|
A dictionary with all methods
|
||||||
:return:
|
:return:
|
||||||
A FakeResource object, with id, type, and so on
|
A FakeResource object, with id, type, and so on
|
||||||
@ -1695,9 +1749,9 @@ class FakeVolumeAttachment(object):
|
|||||||
def create_one_volume_attachment(attrs=None, methods=None):
|
def create_one_volume_attachment(attrs=None, methods=None):
|
||||||
"""Create a fake volume attachment.
|
"""Create a fake volume attachment.
|
||||||
|
|
||||||
:param Dictionary attrs:
|
:param dict attrs:
|
||||||
A dictionary with all attributes
|
A dictionary with all attributes
|
||||||
:param Dictionary methods:
|
:param dict methods:
|
||||||
A dictionary with all methods
|
A dictionary with all methods
|
||||||
:return:
|
:return:
|
||||||
A FakeResource object, with id, device, and so on
|
A FakeResource object, with id, device, and so on
|
||||||
@ -1733,9 +1787,9 @@ class FakeVolumeAttachment(object):
|
|||||||
def create_volume_attachments(attrs=None, methods=None, count=2):
|
def create_volume_attachments(attrs=None, methods=None, count=2):
|
||||||
"""Create multiple fake volume attachments (BDMs).
|
"""Create multiple fake volume attachments (BDMs).
|
||||||
|
|
||||||
:param Dictionary attrs:
|
:param dict attrs:
|
||||||
A dictionary with all attributes
|
A dictionary with all attributes
|
||||||
:param Dictionary methods:
|
:param dict methods:
|
||||||
A dictionary with all methods
|
A dictionary with all methods
|
||||||
:param int count:
|
:param int count:
|
||||||
The number of volume attachments to fake
|
The number of volume attachments to fake
|
||||||
|
@ -28,8 +28,9 @@ class TestServerBackup(compute_fakes.TestComputev2):
|
|||||||
super(TestServerBackup, self).setUp()
|
super(TestServerBackup, self).setUp()
|
||||||
|
|
||||||
# Get a shortcut to the compute client ServerManager Mock
|
# Get a shortcut to the compute client ServerManager Mock
|
||||||
self.servers_mock = self.app.client_manager.compute.servers
|
self.app.client_manager.sdk_connection = mock.Mock()
|
||||||
self.servers_mock.reset_mock()
|
self.app.client_manager.sdk_connection.compute = mock.Mock()
|
||||||
|
self.sdk_client = self.app.client_manager.sdk_connection.compute
|
||||||
|
|
||||||
# Get a shortcut to the image client ImageManager Mock
|
# Get a shortcut to the image client ImageManager Mock
|
||||||
self.images_mock = self.app.client_manager.image
|
self.images_mock = self.app.client_manager.image
|
||||||
@ -42,14 +43,14 @@ class TestServerBackup(compute_fakes.TestComputev2):
|
|||||||
self.methods = {}
|
self.methods = {}
|
||||||
|
|
||||||
def setup_servers_mock(self, count):
|
def setup_servers_mock(self, count):
|
||||||
servers = compute_fakes.FakeServer.create_servers(
|
servers = compute_fakes.FakeServer.create_sdk_servers(
|
||||||
attrs=self.attrs,
|
attrs=self.attrs,
|
||||||
methods=self.methods,
|
methods=self.methods,
|
||||||
count=count,
|
count=count,
|
||||||
)
|
)
|
||||||
|
|
||||||
# This is the return value for utils.find_resource()
|
# This is the return value for compute_client.find_server()
|
||||||
self.servers_mock.get = compute_fakes.FakeServer.get_servers(
|
self.sdk_client.find_server = compute_fakes.FakeServer.get_servers(
|
||||||
servers,
|
servers,
|
||||||
0,
|
0,
|
||||||
)
|
)
|
||||||
@ -130,8 +131,7 @@ class TestServerBackupCreate(TestServerBackup):
|
|||||||
# data to be shown.
|
# data to be shown.
|
||||||
columns, data = self.cmd.take_action(parsed_args)
|
columns, data = self.cmd.take_action(parsed_args)
|
||||||
|
|
||||||
# ServerManager.backup(server, backup_name, backup_type, rotation)
|
self.sdk_client.backup_server.assert_called_with(
|
||||||
self.servers_mock.backup.assert_called_with(
|
|
||||||
servers[0].id,
|
servers[0].id,
|
||||||
servers[0].name,
|
servers[0].name,
|
||||||
'',
|
'',
|
||||||
@ -164,8 +164,7 @@ class TestServerBackupCreate(TestServerBackup):
|
|||||||
# data to be shown.
|
# data to be shown.
|
||||||
columns, data = self.cmd.take_action(parsed_args)
|
columns, data = self.cmd.take_action(parsed_args)
|
||||||
|
|
||||||
# ServerManager.backup(server, backup_name, backup_type, rotation)
|
self.sdk_client.backup_server.assert_called_with(
|
||||||
self.servers_mock.backup.assert_called_with(
|
|
||||||
servers[0].id,
|
servers[0].id,
|
||||||
'image',
|
'image',
|
||||||
'daily',
|
'daily',
|
||||||
@ -212,8 +211,7 @@ class TestServerBackupCreate(TestServerBackup):
|
|||||||
parsed_args,
|
parsed_args,
|
||||||
)
|
)
|
||||||
|
|
||||||
# ServerManager.backup(server, backup_name, backup_type, rotation)
|
self.sdk_client.backup_server.assert_called_with(
|
||||||
self.servers_mock.backup.assert_called_with(
|
|
||||||
servers[0].id,
|
servers[0].id,
|
||||||
'image',
|
'image',
|
||||||
'daily',
|
'daily',
|
||||||
@ -254,8 +252,7 @@ class TestServerBackupCreate(TestServerBackup):
|
|||||||
# data to be shown.
|
# data to be shown.
|
||||||
columns, data = self.cmd.take_action(parsed_args)
|
columns, data = self.cmd.take_action(parsed_args)
|
||||||
|
|
||||||
# ServerManager.backup(server, backup_name, backup_type, rotation)
|
self.sdk_client.backup_server.assert_called_with(
|
||||||
self.servers_mock.backup.assert_called_with(
|
|
||||||
servers[0].id,
|
servers[0].id,
|
||||||
'image',
|
'image',
|
||||||
'daily',
|
'daily',
|
||||||
|
@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
features:
|
||||||
|
- |
|
||||||
|
Migrate openstack server backup from novaclient to sdk.
|
Loading…
x
Reference in New Issue
Block a user