1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816
|
# Copyright 2013 Nebula Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# 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 random
import re
from unittest import mock
import uuid
from keystoneauth1 import discover
from openstack.compute.v2 import _proxy
from openstack.compute.v2 import availability_zone as _availability_zone
from openstack.compute.v2 import extension as _extension
from openstack.compute.v2 import flavor as _flavor
from openstack.compute.v2 import limits as _limits
from openstack.compute.v2 import migration as _migration
from openstack.compute.v2 import server as _server
from openstack.compute.v2 import server_action as _server_action
from openstack.compute.v2 import server_interface as _server_interface
from openstack.compute.v2 import server_migration as _server_migration
from openstack.compute.v2 import volume_attachment as _volume_attachment
from openstackclient.tests.unit.identity.v3 import fakes as identity_fakes
from openstackclient.tests.unit.image.v2 import fakes as image_fakes
from openstackclient.tests.unit.network.v2 import fakes as network_fakes
from openstackclient.tests.unit import utils
from openstackclient.tests.unit.volume.v3 import fakes as volume_fakes
class FakeClientMixin:
def setUp(self):
super().setUp()
self.app.client_manager.compute = mock.Mock(_proxy.Proxy)
self.compute_client = self.app.client_manager.compute
self.set_compute_api_version() # default to the lowest
def set_compute_api_version(self, version: str = '2.1'):
"""Set a fake server version.
:param version: The fake microversion to "support". This should be a
string of format '2.xx'.
:returns: None
"""
assert re.match(r'2.\d+', version)
self.compute_client.default_microversion = version
self.compute_client.get_endpoint_data.return_value = (
discover.EndpointData(
min_microversion='2.1', # nova has not bumped this yet
max_microversion=version,
)
)
class TestComputev2(
identity_fakes.FakeClientMixin,
network_fakes.FakeClientMixin,
image_fakes.FakeClientMixin,
volume_fakes.FakeClientMixin,
FakeClientMixin,
utils.TestCommand,
): ...
def create_one_agent(attrs=None):
"""Create a fake agent.
:param dict attrs: A dictionary with all attributes
:return: A dicionarty faking the agent
"""
attrs = attrs or {}
# set default attributes.
agent_attrs = {
'agent_id': 'agent-id-' + uuid.uuid4().hex,
'os': 'agent-os-' + uuid.uuid4().hex,
'architecture': 'agent-architecture',
'version': '8.0',
'url': 'http://127.0.0.1',
'md5hash': 'agent-md5hash',
'hypervisor': 'hypervisor',
}
assert not set(attrs) - set(agent_attrs), 'unknown keys'
# Overwrite default attributes.
agent_attrs.update(attrs)
return agent_attrs
def create_agents(attrs=None, count=2):
"""Create multiple fake agents.
:param dict attrs: A dictionary with all attributes
:param int count: The number of agents to fake
:return: A list of dictionaries faking the agents
"""
agents = []
for i in range(0, count):
agents.append(create_one_agent(attrs))
return agents
def create_one_extension(attrs=None):
"""Create a fake extension.
:param dict attrs: A dictionary with all attributes
:return: A fake :class:`~openstack.compute.v2.extension.Extension` object
"""
attrs = attrs or {}
# Set default attributes.
extension_info = {
'alias': 'NMN',
'description': 'description-' + uuid.uuid4().hex,
'links': [
{
"href": "https://github.com/openstack/compute-api",
"type": "text/html",
"rel": "describedby",
}
],
'name': 'name-' + uuid.uuid4().hex,
'namespace': (
'http://docs.openstack.org/compute/ext/multinic/api/v1.1'
),
'updated_at': '2014-01-07T12:00:0-00:00',
}
# Overwrite default attributes.
extension_info.update(attrs)
extension = _extension.Extension(**extension_info)
return extension
def create_one_security_group(attrs=None):
"""Create a fake security group.
:param dict attrs: A dictionary with all attributes
:return: A dictionary faking the security group
"""
attrs = attrs or {}
# Set default attributes.
security_group_attrs = {
'id': 'security-group-id-' + uuid.uuid4().hex,
'name': 'security-group-name-' + uuid.uuid4().hex,
'description': 'security-group-description-' + uuid.uuid4().hex,
'tenant_id': 'project-id-' + uuid.uuid4().hex,
'rules': [],
}
assert not set(attrs) - set(security_group_attrs), 'unknown keys'
# Overwrite default attributes.
security_group_attrs.update(attrs)
return security_group_attrs
def create_security_groups(attrs=None, count=2):
"""Create multiple fake security groups.
:param dict attrs: A dictionary with all attributes
:param int count: The number of security groups to fake
:return: A list of dictionaries faking the security groups
"""
security_groups = []
for i in range(0, count):
security_groups.append(create_one_security_group(attrs))
return security_groups
def create_one_security_group_rule(attrs=None):
"""Create a fake security group rule.
:param dict attrs: A dictionary with all attributes
:return: A dictionary faking the security group rule
"""
attrs = attrs or {}
# Set default attributes.
security_group_rule_attrs = {
'from_port': 0,
'group': {},
'id': 'security-group-rule-id-' + uuid.uuid4().hex,
'ip_protocol': 'tcp',
'ip_range': {'cidr': '0.0.0.0/0'},
'parent_group_id': 'security-group-id-' + uuid.uuid4().hex,
'to_port': 0,
}
assert not set(attrs) - set(security_group_rule_attrs), 'unknown keys'
# Overwrite default attributes.
security_group_rule_attrs.update(attrs)
return security_group_rule_attrs
def create_security_group_rules(attrs=None, count=2):
"""Create multiple fake security group rules.
:param dict attrs: A dictionary with all attributes
:param int count: The number of security group rules to fake
:return: A list of dictionaries faking the security group rules
"""
security_group_rules = []
for i in range(0, count):
security_group_rules.append(create_one_security_group_rule(attrs))
return security_group_rules
def create_one_server(attrs=None):
"""Create a fake server
:param dict attrs: A dictionary with all attributes
:return: A fake :class:`~openstack.compute.v2.server.Server` object,
"""
attrs = attrs 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)
server = _server.Server(**server_info)
# Override methods
server.trigger_crash_dump = mock.MagicMock()
return server
def create_servers(attrs=None, count=2):
"""Create multiple fake servers
:param dict attrs: A dictionary with all attributes
:param int count: The number of servers to fake
:return: A list of fake :class:`openstack.compute.v2.server.Server` objects
"""
servers = []
for i in range(0, count):
servers.append(create_one_server(attrs))
return servers
def create_one_server_action(attrs=None):
"""Create a fake server action.
:param attrs: A dictionary with all attributes
:return: A fake :class:`~openstack.compute.v2.server_action.ServerAction`
object
"""
attrs = attrs or {}
# Set default attributes
server_action_info = {
"server_id": "server-event-" + uuid.uuid4().hex,
"user_id": "user-id-" + uuid.uuid4().hex,
"start_time": "2017-02-27T07:47:13.000000",
"request_id": "req-" + uuid.uuid4().hex,
"action": "create",
"message": None,
"project_id": "project-id-" + uuid.uuid4().hex,
"events": [
{
"finish_time": "2017-02-27T07:47:25.000000",
"start_time": "2017-02-27T07:47:15.000000",
"traceback": None,
"event": "compute__do_build_and_run_instance",
"result": "Success",
}
],
}
# Overwrite default attributes
server_action_info.update(attrs)
# We handle events separately since they're nested resources
events = [
_server_action.ServerActionEvent(**event)
for event in server_action_info.pop('events')
]
server_action = _server_action.ServerAction(
**server_action_info,
events=events,
)
return server_action
def create_one_flavor(attrs=None):
"""Create a fake flavor.
:param dict attrs: A dictionary with all attributes
:return: A fake :class:`~openstack.compute.v2.flavor.Flavor` object
"""
attrs = attrs or {}
# Set default attributes.
flavor_info = {
'id': 'flavor-id-' + uuid.uuid4().hex,
'name': 'flavor-name-' + uuid.uuid4().hex,
'ram': 8192,
'vcpus': 4,
'disk': 128,
'swap': 0,
'rxtx_factor': 1.0,
'OS-FLV-DISABLED:disabled': False,
'os-flavor-access:is_public': True,
'description': 'description',
'OS-FLV-EXT-DATA:ephemeral': 0,
'extra_specs': {'property': 'value'},
}
# Overwrite default attributes.
flavor_info.update(attrs)
flavor = _flavor.Flavor(**flavor_info)
return flavor
def create_flavors(attrs=None, count=2):
"""Create multiple fake flavors.
:param dict attrs: A dictionary with all attributes
:param int count: The number of flavors to fake
:return: A list of fake :class:`openstack.compute.v2.flavor.Flavor` objects
"""
flavors = []
for i in range(0, count):
flavors.append(create_one_flavor(attrs))
return flavors
def create_one_flavor_access(attrs=None):
"""Create a fake flavor access.
:param dict attrs: A dictionary with all attributes
:return: A dictionary faking the flavor access
"""
attrs = attrs or {}
# Set default attributes.
flavor_access_info = {
'flavor_id': 'flavor-id-' + uuid.uuid4().hex,
'tenant_id': 'tenant-id-' + uuid.uuid4().hex,
}
assert not set(attrs) - set(flavor_access_info), 'unknown keys'
# Overwrite default attributes.
flavor_access_info.update(attrs)
return flavor_access_info
def create_one_availability_zone(attrs=None):
"""Create a fake AZ.
:param dict attrs: A dictionary with all attributes
:return: A fake
:class:`~openstack.compute.v2.availability_zone.AvailabilityZone` object
"""
attrs = attrs or {}
# Set default attributes.
host_name = uuid.uuid4().hex
service_name = uuid.uuid4().hex
availability_zone_info = {
'name': uuid.uuid4().hex,
'state': {'available': True},
'hosts': {
host_name: {
service_name: {
'available': True,
'active': True,
'updated_at': '2023-01-01T00:00:00.000000',
}
}
},
}
# Overwrite default attributes.
availability_zone_info.update(attrs)
availability_zone = _availability_zone.AvailabilityZone(
**availability_zone_info
)
return availability_zone
def create_availability_zones(attrs=None, count=2):
"""Create multiple fake AZs.
:param dict attrs: A dictionary with all attributes
:param int count: The number of availability zones to fake
:return: A list of fake
openstack.compute.v2.availability_zone.AvailabilityZone objects
"""
availability_zones = []
for i in range(0, count):
availability_zone = create_one_availability_zone(attrs)
availability_zones.append(availability_zone)
return availability_zones
def create_one_floating_ip(attrs=None):
"""Create a fake floating IP.
:param dict attrs: A dictionary with all attributes
:return: A dictionary faking the floating IP
"""
attrs = attrs or {}
# Set default attributes.
floating_ip_attrs = {
'id': 'floating-ip-id-' + uuid.uuid4().hex,
'ip': '1.0.9.0',
'fixed_ip': '2.0.9.0',
'instance_id': 'server-id-' + uuid.uuid4().hex,
'pool': 'public',
}
assert not set(attrs) - set(floating_ip_attrs), 'unknown keys'
# Overwrite default attributes.
floating_ip_attrs.update(attrs)
return floating_ip_attrs
def create_floating_ips(attrs=None, count=2):
"""Create multiple fake floating IPs.
:param dict attrs: A dictionary with all attributes
:param int count: The number of floating IPs to fake
:return: A list of dictionaries faking the floating IPs
"""
floating_ips = []
for i in range(0, count):
floating_ips.append(create_one_floating_ip(attrs))
return floating_ips
def create_one_floating_ip_pool(attrs=None):
"""Create a fake floating IP pool.
:param dict attrs: A dictionary with all attributes
:return: A dictionary faking the floating IP pool
"""
if attrs is None:
attrs = {}
# Set default attributes.
floating_ip_pool_attrs = {
'name': 'floating-ip-pool-name-' + uuid.uuid4().hex,
}
assert not set(attrs) - set(floating_ip_pool_attrs), 'unknown keys'
# Overwrite default attributes.
floating_ip_pool_attrs.update(attrs)
return floating_ip_pool_attrs
def create_floating_ip_pools(attrs=None, count=2):
"""Create multiple fake floating IP pools.
:param dict attrs: A dictionary with all attributes
:param int count: The number of floating IP pools to fake
:return: A list of dictionaries faking the floating IP pools
"""
floating_ip_pools = []
for i in range(0, count):
floating_ip_pools.append(create_one_floating_ip_pool(attrs))
return floating_ip_pools
def create_one_network(attrs=None):
"""Create a fake network.
:param dict attrs: A dictionary with all attributes
:return: A dictionary faking the network
"""
attrs = attrs or {}
# Set default attributes.
network_attrs = {
'bridge': 'br100',
'bridge_interface': None,
'broadcast': '10.0.0.255',
'cidr': '10.0.0.0/24',
'cidr_v6': None,
'created_at': '2016-02-11T11:17:37.000000',
'deleted': False,
'deleted_at': None,
'dhcp_server': '10.0.0.1',
'dhcp_start': '10.0.0.2',
'dns1': '8.8.4.4',
'dns2': None,
'enable_dhcp': True,
'gateway': '10.0.0.1',
'gateway_v6': None,
'host': None,
'id': 'network-id-' + uuid.uuid4().hex,
'injected': False,
'label': 'network-label-' + uuid.uuid4().hex,
'mtu': None,
'multi_host': False,
'netmask': '255.255.255.0',
'netmask_v6': None,
'priority': None,
'project_id': 'project-id-' + uuid.uuid4().hex,
'rxtx_base': None,
'share_address': False,
'updated_at': None,
'vlan': None,
'vpn_private_address': None,
'vpn_public_address': None,
'vpn_public_port': None,
}
assert not set(attrs) - set(network_attrs), 'unknown keys'
# Overwrite default attributes.
network_attrs.update(attrs)
return network_attrs
def create_networks(attrs=None, count=2):
"""Create multiple fake networks.
:param dict attrs: A dictionary with all attributes
:param int count: The number of networks to fake
:return: A list of dictionaries faking the networks
"""
networks = []
for i in range(0, count):
networks.append(create_one_network(attrs))
return networks
def create_limits(attrs=None):
"""Create a fake limits object."""
attrs = attrs or {}
limits_attrs = {
'absolute': {
'maxServerMeta': 128,
'maxTotalInstances': 10,
'maxPersonality': 5,
'totalServerGroupsUsed': 0,
'maxImageMeta': 128,
'maxPersonalitySize': 10240,
'maxTotalRAMSize': 51200,
'maxServerGroups': 10,
'maxSecurityGroupRules': 20,
'maxTotalKeypairs': 100,
'totalCoresUsed': 0,
'totalRAMUsed': 0,
'maxSecurityGroups': 10,
'totalFloatingIpsUsed': 0,
'totalInstancesUsed': 0,
'maxServerGroupMembers': 10,
'maxTotalFloatingIps': 10,
'totalSecurityGroupsUsed': 0,
'maxTotalCores': 20,
},
'rate': [
{
"uri": "*",
"limit": [
{
"value": 10,
"verb": "POST",
"remaining": 2,
"unit": "MINUTE",
"next-available": "2011-12-15T22:42:45Z",
},
{
"value": 10,
"verb": "PUT",
"remaining": 2,
"unit": "MINUTE",
"next-available": "2011-12-15T22:42:45Z",
},
{
"value": 100,
"verb": "DELETE",
"remaining": 100,
"unit": "MINUTE",
"next-available": "2011-12-15T22:42:45Z",
},
],
}
],
}
limits_attrs.update(attrs)
limits = _limits.Limits(**limits_attrs)
return limits
def create_one_migration(attrs=None):
"""Create a fake migration.
:param dict attrs: A dictionary with all attributes
:return: A fake :class:`~openstack.compute.v2.migration.Migration` object
"""
attrs = attrs or {}
# Set default attributes.
migration_info = {
"created_at": "2017-01-31T08:03:21.000000",
"dest_compute": "compute-" + uuid.uuid4().hex,
"dest_host": "10.0.2.15",
"dest_node": "node-" + uuid.uuid4().hex,
"id": random.randint(1, 999),
"migration_type": "migration",
"new_flavor_id": uuid.uuid4().hex,
"old_flavor_id": uuid.uuid4().hex,
"project_id": uuid.uuid4().hex,
"server_id": uuid.uuid4().hex,
"source_compute": "compute-" + uuid.uuid4().hex,
"source_node": "node-" + uuid.uuid4().hex,
"status": "migrating",
"updated_at": "2017-01-31T08:03:25.000000",
"user_id": uuid.uuid4().hex,
"uuid": uuid.uuid4().hex,
}
# Overwrite default attributes.
migration_info.update(attrs)
migration = _migration.Migration(**migration_info)
return migration
def create_migrations(attrs=None, count=2):
"""Create multiple fake migrations.
:param dict attrs: A dictionary with all attributes
:param int count: The number of migrations to fake
:return: A list of fake :class:`openstack.compute.v2.migration.Migration` objects
"""
migrations = []
for i in range(0, count):
migrations.append(create_one_migration(attrs))
return migrations
def create_one_server_migration(attrs=None):
"""Create a fake server migration.
:param dict attrs: A dictionary with all attributes
:return: A fake
:class:`~openstack.compute.v2.server_migration.ServerMigration` object
"""
attrs = attrs or {}
# Set default attributes.
migration_info = {
"created_at": "2016-01-29T13:42:02.000000",
"dest_compute": "compute2",
"dest_host": "1.2.3.4",
"dest_node": "node2",
"id": random.randint(1, 999),
"server_uuid": uuid.uuid4().hex,
"source_compute": "compute1",
"source_node": "node1",
"status": "running",
"memory_total_bytes": random.randint(1, 99999),
"memory_processed_bytes": random.randint(1, 99999),
"memory_remaining_bytes": random.randint(1, 99999),
"disk_total_bytes": random.randint(1, 99999),
"disk_processed_bytes": random.randint(1, 99999),
"disk_remaining_bytes": random.randint(1, 99999),
"updated_at": "2016-01-29T13:42:02.000000",
# added in 2.59
"uuid": uuid.uuid4().hex,
# added in 2.80
"user_id": uuid.uuid4().hex,
"project_id": uuid.uuid4().hex,
}
# Overwrite default attributes.
migration_info.update(attrs)
migration = _server_migration.ServerMigration(**migration_info)
return migration
def create_server_migrations(attrs=None, methods=None, count=2):
"""Create multiple server migrations.
:param dict attrs: A dictionary with all attributes
:param int count: The number of server migrations to fake
:return A list of fake
openstack.compute.v2.server_migration.ServerMigration objects
"""
migrations = []
for i in range(0, count):
migrations.append(create_one_server_migration(attrs, methods))
return migrations
def create_one_volume_attachment(attrs=None):
"""Create a fake volume attachment.
:param dict attrs: A dictionary with all attributes
:return: A fake
:class:`~openstack.compute.v2.volume_attachment.VolumeAttachment` object
"""
attrs = attrs or {}
# Set default attributes.
volume_attachment_info = {
"id": uuid.uuid4().hex,
"device": "/dev/sdb",
"server_id": uuid.uuid4().hex,
"volume_id": uuid.uuid4().hex,
# introduced in API microversion 2.70
"tag": "foo",
# introduced in API microversion 2.79
"delete_on_termination": True,
# introduced in API microversion 2.89
"attachment_id": uuid.uuid4().hex,
"bdm_id": uuid.uuid4().hex,
}
# Overwrite default attributes.
volume_attachment_info.update(attrs)
return _volume_attachment.VolumeAttachment(**volume_attachment_info)
def create_volume_attachments(attrs=None, count=2):
"""Create multiple fake volume attachments.
:param dict attrs: A dictionary with all attributes
:param int count: The number of volume attachments to fake
:return: A list of fake
openstack.compute.v2.volume_attachment.VolumeAttachment objects
"""
volume_attachments = []
for i in range(0, count):
volume_attachments.append(create_one_volume_attachment(attrs))
return volume_attachments
def create_one_server_interface(attrs=None):
"""Create a fake ServerInterface.
:param dict attrs: A dictionary with all attributes
:param dict methods: A dictionary with all methods
:return: A fake
:class:`~openstack.compute.v2.server_interface.ServerInterface` object
"""
attrs = attrs or {}
# Set default attributes.
server_interface_info = {
"fixed_ips": uuid.uuid4().hex,
"mac_addr": "aa:aa:aa:aa:aa:aa",
"net_id": uuid.uuid4().hex,
"port_id": uuid.uuid4().hex,
"port_state": "ACTIVE",
"server_id": uuid.uuid4().hex,
# introduced in API microversion 2.70
"tag": "foo",
}
# Overwrite default attributes.
server_interface_info.update(attrs)
return _server_interface.ServerInterface(**server_interface_info)
|