1# Copyright 2019 Rackspace, US Inc. 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); you may 4# not use this file except in compliance with the License. You may obtain 5# a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12# License for the specific language governing permissions and limitations 13# under the License. 14 15from openstack import resource 16 17 18class Amphora(resource.Resource): 19 resource_key = 'amphora' 20 resources_key = 'amphorae' 21 base_path = '/octavia/amphorae' 22 23 # capabilities 24 allow_create = False 25 allow_fetch = True 26 allow_commit = False 27 allow_delete = False 28 allow_list = True 29 30 _query_mapping = resource.QueryParameters( 31 'id', 'loadbalancer_id', 'compute_id', 'lb_network_ip', 'vrrp_ip', 32 'ha_ip', 'vrrp_port_id', 'ha_port_id', 'cert_expiration', 'cert_busy', 33 'role', 'status', 'vrrp_interface', 'vrrp_id', 'vrrp_priority', 34 'cached_zone', 'created_at', 'updated_at', 'image_id', 'image_id' 35 ) 36 37 # Properties 38 #: The ID of the amphora. 39 id = resource.Body('id') 40 #: The ID of the load balancer. 41 loadbalancer_id = resource.Body('loadbalancer_id') 42 #: The ID of the amphora resource in the compute system. 43 compute_id = resource.Body('compute_id') 44 #: The management IP of the amphora. 45 lb_network_ip = resource.Body('lb_network_ip') 46 #: The address of the vrrp port on the amphora. 47 vrrp_ip = resource.Body('vrrp_ip') 48 #: The IP address of the Virtual IP (VIP). 49 ha_ip = resource.Body('ha_ip') 50 #: The vrrp port's ID in the networking system. 51 vrrp_port_id = resource.Body('vrrp_port_id') 52 #: The ID of the Virtual IP (VIP) port. 53 ha_port_id = resource.Body('ha_port_id') 54 #: The date the certificate for the amphora expires. 55 cert_expiration = resource.Body('cert_expiration') 56 #: Whether the certificate is in the process of being replaced. 57 cert_busy = resource.Body('cert_busy') 58 #: The role configured for the amphora. One of STANDALONE, MASTER, BACKUP. 59 role = resource.Body('role') 60 #: The status of the amphora. One of: BOOTING, ALLOCATED, READY, 61 #: PENDING_CREATE, PENDING_DELETE, DELETED, ERROR. 62 status = resource.Body('status') 63 #: The bound interface name of the vrrp port on the amphora. 64 vrrp_interface = resource.Body('vrrp_interface') 65 #: The vrrp group's ID for the amphora. 66 vrrp_id = resource.Body('vrrp_id') 67 #: The priority of the amphora in the vrrp group. 68 vrrp_priority = resource.Body('vrrp_priority') 69 #: The availability zone of a compute instance, cached at create time. 70 cached_zone = resource.Body('cached_zone') 71 #: The UTC date and timestamp when the resource was created. 72 created_at = resource.Body('created_at') 73 #: The UTC date and timestamp when the resource was last updated. 74 updated_at = resource.Body('updated_at') 75 #: The ID of the glance image used for the amphora. 76 image_id = resource.Body('image_id') 77 #: The ID of the compute flavor used for the amphora. 78 compute_flavor = resource.Body('compute_flavor') 79 80 81class AmphoraConfig(resource.Resource): 82 base_path = '/octavia/amphorae/%(amphora_id)s/config' 83 84 # capabilities 85 allow_create = False 86 allow_fetch = False 87 allow_commit = True 88 allow_delete = False 89 allow_list = False 90 allow_empty_commit = True 91 92 requires_id = False 93 94 # Properties 95 #: The ID of the amphora. 96 amphora_id = resource.URI('amphora_id') 97 98 # The default _update code path also has no 99 # way to pass has_body into this function, so overriding the method here. 100 def commit(self, session, base_path=None): 101 return super(AmphoraConfig, self).commit( 102 session, base_path=base_path, has_body=False) 103 104 105class AmphoraFailover(resource.Resource): 106 base_path = '/octavia/amphorae/%(amphora_id)s/failover' 107 108 # capabilities 109 allow_create = False 110 allow_fetch = False 111 allow_commit = True 112 allow_delete = False 113 allow_list = False 114 allow_empty_commit = True 115 116 requires_id = False 117 118 # Properties 119 #: The ID of the amphora. 120 amphora_id = resource.URI('amphora_id') 121 122 # The default _update code path also has no 123 # way to pass has_body into this function, so overriding the method here. 124 def commit(self, session, base_path=None): 125 return super(AmphoraFailover, self).commit( 126 session, base_path=base_path, has_body=False) 127