Sapan Bhatia | cb35e7f | 2017-05-24 12:17:28 +0200 | [diff] [blame] | 1 | option app_label = "core"; |
Sapan Bhatia | d022aeb | 2017-06-07 15:49:55 +0200 | [diff] [blame] | 2 | |
Matteo Scandolo | 81c154d | 2017-11-22 14:55:09 -0800 | [diff] [blame] | 3 | // use thi policy to allow access to admins only |
| 4 | policy admin_policy < ctx.user.is_admin > |
| 5 | |
Sapan Bhatia | 170ae27 | 2017-05-30 19:01:09 +0200 | [diff] [blame] | 6 | message XOSBase { |
Sapan Bhatia | d022aeb | 2017-06-07 15:49:55 +0200 | [diff] [blame] | 7 | option skip_init = True; |
Sapan Bhatia | cb35e7f | 2017-05-24 12:17:28 +0200 | [diff] [blame] | 8 | |
Sapan Bhatia | 170ae27 | 2017-05-30 19:01:09 +0200 | [diff] [blame] | 9 | required string created = 1 [content_type = "date", auto_now_add = True]; |
| 10 | required string updated = 2 [default = "now()", content_type = "date"]; |
| 11 | optional string enacted = 3 [null = True, content_type = "date", blank = True, default = None]; |
| 12 | optional string policed = 4 [null = True, content_type = "date", blank = True, default = None]; |
Sapan Bhatia | cb35e7f | 2017-05-24 12:17:28 +0200 | [diff] [blame] | 13 | optional string backend_register = 5 [default = "{}", max_length = 1024]; |
Matteo Scandolo | 031028f | 2017-10-03 17:01:22 -0700 | [diff] [blame] | 14 | required bool backend_need_delete = 6 [default = False, blank = True]; |
| 15 | required bool backend_need_reap = 7 [default = False, blank = True]; |
Sapan Bhatia | da5e444 | 2017-08-27 09:51:13 -0400 | [diff] [blame] | 16 | required string backend_status = 8 [default = "Provisioning in progress", max_length = 1024, null = True]; |
| 17 | required int32 backend_code = 9 [default = 0]; |
Matteo Scandolo | 031028f | 2017-10-03 17:01:22 -0700 | [diff] [blame] | 18 | required bool deleted = 10 [default = False, blank = True]; |
| 19 | required bool write_protect = 12 [default = False, blank = True]; |
| 20 | required bool lazy_blocked = 13 [default = False, blank = True]; |
| 21 | required bool no_sync = 14 [default = False, blank = True]; |
| 22 | required bool no_policy = 15 [default = False, blank = True]; |
Sapan Bhatia | da5e444 | 2017-08-27 09:51:13 -0400 | [diff] [blame] | 23 | optional string policy_status = 16 [default = "Policy in process", max_length = 1024]; |
| 24 | optional int32 policy_code = 16 [default = 0]; |
| 25 | required string leaf_model_name = 17 [null = False, max_length = 1024, help_text = "The most specialized model in this chain of inheritance, often defined by a service developer"]; |
Matteo Scandolo | 031028f | 2017-10-03 17:01:22 -0700 | [diff] [blame] | 26 | required bool backend_need_delete_policy = 18 [default = False, help_text = "True if delete model_policy must be run before object can be reaped", blank = True]; |
Sapan Bhatia | 170ae27 | 2017-05-30 19:01:09 +0200 | [diff] [blame] | 27 | } |
| 28 | |
Sapan Bhatia | b5ce186 | 2017-07-31 15:48:19 -0400 | [diff] [blame] | 29 | // The calling user represents the user being accessed, or is a site admin. |
| 30 | policy user_policy < |
| 31 | ctx.user.is_admin |
| 32 | | ctx.user.id = obj.id |
| 33 | | (exists Privilege: |
| 34 | Privilege.accessor_id = ctx.user.id |
| 35 | & Privilege.accessor_type = "User" |
| 36 | & Privilege.permission = "role:admin" |
| 37 | & Privilege.object_type = "Site" |
| 38 | & Privilege.object_id = ctx.user.site.id) > |
| 39 | |
| 40 | message User::user_policy (AbstractBaseUser,PlModelMixIn) { |
Sapan Bhatia | d022aeb | 2017-06-07 15:49:55 +0200 | [diff] [blame] | 41 | option skip_django = True; |
Matteo Scandolo | e425f9d | 2017-08-15 15:56:19 -0700 | [diff] [blame] | 42 | option description = "An XOS User"; |
Sapan Bhatia | cb35e7f | 2017-05-24 12:17:28 +0200 | [diff] [blame] | 43 | |
Matteo Scandolo | fb37c8f | 2017-10-18 09:53:30 +0200 | [diff] [blame] | 44 | required string email = 1 [db_index = True, max_length = 255, null = False, blank = False, tosca_key=True]; |
Sapan Bhatia | d022aeb | 2017-06-07 15:49:55 +0200 | [diff] [blame] | 45 | required string username = 2 [default = "Something", max_length = 255, content_type = "stripped", blank = False, null = False, db_index = False]; |
Sapan Bhatia | cb35e7f | 2017-05-24 12:17:28 +0200 | [diff] [blame] | 46 | required string password = 3 [default = "Something", max_length = 255, blank = False, null = False, db_index = False]; |
Sapan Bhatia | afce8fd | 2017-06-28 23:24:53 -0700 | [diff] [blame] | 47 | optional string last_login = 4 [db_index = False, null = True, content_type = "date", blank = True]; |
| 48 | required string firstname = 5 [max_length = 200, content_type = "stripped", blank = False, help_text = "person's given name", null = False, db_index = False]; |
| 49 | required string lastname = 6 [max_length = 200, content_type = "stripped", blank = False, help_text = "person's surname", null = False, db_index = False]; |
| 50 | optional string phone = 7 [max_length = 100, content_type = "stripped", blank = True, help_text = "phone number contact", null = True, db_index = False]; |
| 51 | optional string user_url = 8 [db_index = False, max_length = 200, null = True, content_type = "url", blank = True]; |
| 52 | required manytoone site->Site:users = 9 [help_text = "Site this user will be homed too", null = False, db_index = True, blank = False]; |
| 53 | optional string public_key = 10 [help_text = "Public key string", max_length = 1024, null = True, db_index = False, blank = True, varchar = True]; |
| 54 | required bool is_active = 11 [default = True, null = False, db_index = False, blank = True]; |
| 55 | required bool is_admin = 12 [default = False, null = False, db_index = False, blank = True]; |
| 56 | required bool is_staff = 13 [default = True, null = False, db_index = False, blank = True]; |
| 57 | required bool is_readonly = 14 [default = False, null = False, db_index = False, blank = True]; |
| 58 | required bool is_registering = 15 [default = False, null = False, db_index = False, blank = True]; |
| 59 | required bool is_appuser = 16 [default = False, null = False, db_index = False, blank = True]; |
| 60 | optional string login_page = 17 [max_length = 200, content_type = "stripped", blank = True, help_text = "send this user to a specific page on login", null = True, db_index = False]; |
| 61 | required string created = 18 [db_index = False, null = False, content_type = "date", blank = True]; |
| 62 | required string updated = 19 [db_index = False, null = False, content_type = "date", blank = True]; |
| 63 | optional string enacted = 20 [db_index = False, null = True, content_type = "date", blank = False]; |
| 64 | optional string policed = 21 [db_index = False, null = True, content_type = "date", blank = False]; |
| 65 | required string backend_status = 22 [default = "Provisioning in progress", max_length = 1024, content_type = "stripped", blank = False, null = False, db_index = False]; |
Scott Baker | 708418b | 2017-12-01 15:23:35 -0800 | [diff] [blame] | 66 | required int32 backend_code = 34 [default = 0]; |
Sapan Bhatia | afce8fd | 2017-06-28 23:24:53 -0700 | [diff] [blame] | 67 | required bool backend_need_delete = 23 [default = False, null = False, db_index = False, blank = True]; |
| 68 | required bool backend_need_reap = 24 [default = False, null = False, db_index = False, blank = True]; |
| 69 | required bool deleted = 25 [default = False, null = False, db_index = False, blank = True]; |
| 70 | required bool write_protect = 26 [default = False, null = False, db_index = False, blank = True]; |
| 71 | required bool lazy_blocked = 27 [default = False, null = False, db_index = False, blank = True]; |
| 72 | required bool no_sync = 28 [default = False, null = False, db_index = False, blank = True]; |
| 73 | required bool no_policy = 29 [default = False, null = False, db_index = False, blank = True]; |
| 74 | required string timezone = 30 [default = "America/New_York", max_length = 100, blank = False, null = False, db_index = False]; |
Scott Baker | e08d006 | 2017-07-11 12:04:26 -0700 | [diff] [blame] | 75 | optional string policy_status = 32 [default = "0 - Policy in process", max_length = 1024]; |
Scott Baker | 708418b | 2017-12-01 15:23:35 -0800 | [diff] [blame] | 76 | optional int32 policy_code = 35 [default = 0]; |
Sapan Bhatia | 784a516 | 2017-09-03 21:02:32 -0400 | [diff] [blame] | 77 | required string leaf_model_name = 33 [null = False, max_length = 1024, help_text = "The most specialized model in this chain of inheritance, often defined by a service developer"]; |
Scott Baker | e08d006 | 2017-07-11 12:04:26 -0700 | [diff] [blame] | 78 | } |
Sapan Bhatia | d022aeb | 2017-06-07 15:49:55 +0200 | [diff] [blame] | 79 | |
Sapan Bhatia | b5ce186 | 2017-07-31 15:48:19 -0400 | [diff] [blame] | 80 | // A user may give a permission that he has to another user |
| 81 | policy grant_policy < ctx.user.is_admin |
| 82 | | exists Privilege:Privilege.object_type = obj.object_type |
| 83 | & Privilege.object_id = obj.object_id |
| 84 | & Privilege.accessor_type = "User" |
| 85 | & Privilege.accessor_id = ctx.user.id |
| 86 | & Privilege.permission = "role:admin" > |
| 87 | |
| 88 | message Privilege::grant_policy (XOSBase) { |
Sapan Bhatia | 8918ac3 | 2017-07-09 00:43:27 -0400 | [diff] [blame] | 89 | required int32 accessor_id = 1 [null = False]; |
| 90 | required string accessor_type = 2 [null = False, max_length=1024]; |
Sapan Bhatia | b5ce186 | 2017-07-31 15:48:19 -0400 | [diff] [blame] | 91 | required int32 controller_id = 3 [null = True]; |
| 92 | required int32 object_id = 4 [null = False]; |
| 93 | required string object_type = 5 [null = False, max_length=1024]; |
Matteo Scandolo | fb37c8f | 2017-10-18 09:53:30 +0200 | [diff] [blame] | 94 | required string permission = 6 [null = False, default = "all", max_length=1024, tosca_key=True]; |
Sapan Bhatia | b5ce186 | 2017-07-31 15:48:19 -0400 | [diff] [blame] | 95 | required string granted = 7 [content_type = "date", auto_now_add = True, max_length=1024]; |
| 96 | required string expires = 8 [content_type = "date", null = True, max_length=1024]; |
Sapan Bhatia | 8918ac3 | 2017-07-09 00:43:27 -0400 | [diff] [blame] | 97 | } |
| 98 | |
Sapan Bhatia | 170ae27 | 2017-05-30 19:01:09 +0200 | [diff] [blame] | 99 | message AddressPool (XOSBase) { |
| 100 | required string name = 1 [db_index = False, max_length = 32, null = False, blank = False]; |
Sapan Bhatia | d022aeb | 2017-06-07 15:49:55 +0200 | [diff] [blame] | 101 | optional string addresses = 2 [db_index = False, null = True, blank = True, varchar = True]; |
Sapan Bhatia | 170ae27 | 2017-05-30 19:01:09 +0200 | [diff] [blame] | 102 | optional string gateway_ip = 3 [db_index = False, max_length = 32, null = True, blank = False]; |
| 103 | optional string gateway_mac = 4 [db_index = False, max_length = 32, null = True, blank = False]; |
| 104 | optional string cidr = 5 [db_index = False, max_length = 32, null = True, blank = False]; |
Sapan Bhatia | d022aeb | 2017-06-07 15:49:55 +0200 | [diff] [blame] | 105 | optional string inuse = 6 [db_index = False, null = True, blank = True, varchar = True]; |
Sapan Bhatia | 170ae27 | 2017-05-30 19:01:09 +0200 | [diff] [blame] | 106 | optional manytoone service->Service:addresspools = 7 [db_index = True, null = True, blank = True]; |
| 107 | } |
| 108 | |
Sapan Bhatia | b5ce186 | 2017-07-31 15:48:19 -0400 | [diff] [blame] | 109 | // Admins at a deployment have access to controllers at those deployments |
| 110 | policy controller_policy |
| 111 | < ctx.user.is_admin |
| 112 | | exists Privilege: |
| 113 | Privilege.accessor_id = ctx.user.id |
| 114 | & Privilege.object_type = "Deployment" |
| 115 | & Privilege.permission = "role:admin" |
| 116 | & Privilege.object_id = obj.id > |
Sapan Bhatia | 170ae27 | 2017-05-30 19:01:09 +0200 | [diff] [blame] | 117 | |
Sapan Bhatia | b5ce186 | 2017-07-31 15:48:19 -0400 | [diff] [blame] | 118 | message Controller::controller_policy (XOSBase) { |
Sapan Bhatia | 170ae27 | 2017-05-30 19:01:09 +0200 | [diff] [blame] | 119 | required string name = 1 [max_length = 200, content_type = "stripped", blank = False, help_text = "Name of the Controller", null = False, db_index = False]; |
| 120 | required string backend_type = 2 [max_length = 200, content_type = "stripped", blank = False, help_text = "Type of compute controller, e.g. EC2, OpenStack, or OpenStack version", null = False, db_index = False]; |
| 121 | required string version = 3 [max_length = 200, content_type = "stripped", blank = False, help_text = "Controller version", null = False, db_index = False]; |
| 122 | optional string auth_url = 4 [max_length = 200, content_type = "stripped", blank = True, help_text = "Auth url for the compute controller", null = True, db_index = False]; |
| 123 | optional string admin_user = 5 [max_length = 200, content_type = "stripped", blank = True, help_text = "Username of an admin user at this controller", null = True, db_index = False]; |
| 124 | optional string admin_password = 6 [max_length = 200, content_type = "stripped", blank = True, help_text = "Password of theadmin user at this controller", null = True, db_index = False]; |
| 125 | optional string admin_tenant = 7 [max_length = 200, content_type = "stripped", blank = True, help_text = "Name of the tenant the admin user belongs to", null = True, db_index = False]; |
| 126 | optional string domain = 8 [max_length = 200, content_type = "stripped", blank = True, help_text = "Name of the domain this controller belongs to", null = True, db_index = False]; |
| 127 | optional string rabbit_host = 9 [max_length = 200, content_type = "stripped", blank = True, help_text = "IP address of rabbitmq server at this controller", null = True, db_index = False]; |
| 128 | optional string rabbit_user = 10 [max_length = 200, content_type = "stripped", blank = True, help_text = "Username of rabbitmq server at this controller", null = True, db_index = False]; |
| 129 | optional string rabbit_password = 11 [max_length = 200, content_type = "stripped", blank = True, help_text = "Password of rabbitmq server at this controller", null = True, db_index = False]; |
| 130 | required manytoone deployment->Deployment:controllerdeployments = 12 [db_index = True, null = False, blank = False]; |
| 131 | } |
| 132 | |
Sapan Bhatia | 170ae27 | 2017-05-30 19:01:09 +0200 | [diff] [blame] | 133 | message ControllerImages (XOSBase) { |
Sapan Bhatia | f7934b5 | 2017-06-12 05:04:23 -0700 | [diff] [blame] | 134 | required manytoone image->Image:controllerimages = 1 [db_index = True, null = False, blank = False, unique_with = "controller"]; |
Sapan Bhatia | 170ae27 | 2017-05-30 19:01:09 +0200 | [diff] [blame] | 135 | required manytoone controller->Controller:controllerimages = 2 [db_index = True, null = False, blank = False]; |
| 136 | optional string glance_image_id = 3 [max_length = 200, content_type = "stripped", blank = True, help_text = "Glance image id", null = True, db_index = False]; |
| 137 | } |
| 138 | |
Sapan Bhatia | b5ce186 | 2017-07-31 15:48:19 -0400 | [diff] [blame] | 139 | // Everyone has read access |
| 140 | // For write access, you have to be a site_admin |
Sapan Bhatia | 170ae27 | 2017-05-30 19:01:09 +0200 | [diff] [blame] | 141 | |
Sapan Bhatia | b5ce186 | 2017-07-31 15:48:19 -0400 | [diff] [blame] | 142 | policy site_policy < |
| 143 | ctx.user.is_admin |
| 144 | | (ctx.write_access -> exists Privilege: Privilege.object_type = "Site" & Privilege.object_id = obj.id & Privilege.accessor_id = ctx.user.id & Privilege.permission = "role:admin") > |
| 145 | |
| 146 | // If you can access (read or write) the site, you can also access its slices |
| 147 | // Otherwise, you need an explicit privilege on the Slice (admin for write access) |
| 148 | // or admin privilege on the associated site. |
| 149 | policy slice_policy < |
| 150 | ctx.user.is_admin |
| 151 | | (*site_policy(site) |
Sapan Bhatia | 0534b47 | 2017-09-01 23:10:16 -0400 | [diff] [blame] | 152 | & (ctx.user = obj.creator |
Sapan Bhatia | b5ce186 | 2017-07-31 15:48:19 -0400 | [diff] [blame] | 153 | | (exists Privilege: |
| 154 | Privilege.accessor_id = ctx.user.id |
| 155 | & Privilege.accessor_type = "User" |
| 156 | & Privilege.object_type = "Slice" |
| 157 | & Privilege.object_id = obj.id |
| 158 | & (ctx.write_access -> Privilege.permission = "role:admin")) |
| 159 | ) |
| 160 | | |
| 161 | (exists Privilege: |
| 162 | Privilege.accessor_id = ctx.user.id |
| 163 | & Privilege.accessor_type = "User" |
| 164 | & Privilege.object_type = "Slice" |
| 165 | & Privilege.object_id = obj.id) |
| 166 | | (exists Privilege: |
| 167 | Privilege.accessor_id = ctx.user.id |
| 168 | & Privilege.accessor_type = "User" |
| 169 | & Privilege.object_type = "Site" |
| 170 | & Privilege.object_id = obj.site.id |
| 171 | & Privilege.permission = "role:admin") |
| 172 | ) > |
| 173 | |
| 174 | policy controller_network_policy < |
| 175 | ctx.user.is_admin |
| 176 | | *slice_policy(network.owner) > |
| 177 | |
| 178 | |
| 179 | message ControllerNetwork::controller_network_policy (XOSBase) { |
Sapan Bhatia | f7934b5 | 2017-06-12 05:04:23 -0700 | [diff] [blame] | 180 | required manytoone network->Network:controllernetworks = 1 [db_index = True, null = False, blank = False, unique_with = "controller"]; |
Sapan Bhatia | 170ae27 | 2017-05-30 19:01:09 +0200 | [diff] [blame] | 181 | required manytoone controller->Controller:controllernetworks = 2 [db_index = True, null = False, blank = False]; |
| 182 | required string subnet = 3 [db_index = False, max_length = 32, null = False, blank = True]; |
| 183 | required string start_ip = 4 [db_index = False, max_length = 32, null = False, blank = True]; |
| 184 | required string stop_ip = 5 [db_index = False, max_length = 32, null = False, blank = True]; |
| 185 | optional string net_id = 6 [help_text = "Neutron network", max_length = 256, null = True, db_index = False, blank = True]; |
| 186 | optional string router_id = 7 [help_text = "Neutron router id", max_length = 256, null = True, db_index = False, blank = True]; |
| 187 | optional string subnet_id = 8 [help_text = "Neutron subnet id", max_length = 256, null = True, db_index = False, blank = True]; |
| 188 | optional string gateway = 9 [db_index = False, max_length = 32, null = True, blank = True]; |
| 189 | optional string segmentation_id = 10 [db_index = False, max_length = 32, null = True, blank = True]; |
| 190 | } |
| 191 | |
| 192 | |
| 193 | message ControllerRole (XOSBase) { |
| 194 | required string role = 1 [choices = "(('admin', 'Admin'),)", max_length = 30, content_type = "stripped", blank = False, null = False, db_index = False]; |
| 195 | } |
| 196 | |
| 197 | |
| 198 | message ControllerSite (XOSBase) { |
Matteo Scandolo | d0693cc | 2017-12-06 15:38:13 -0800 | [diff] [blame] | 199 | required manytoone site->Site:controllersite = 1 [db_index = True, null = False, blank = False, unique_with="controller", tosca_key = True]; |
| 200 | optional manytoone controller->Controller:controllersite = 2 [db_index = True, null = True, blank = True, tosca_key = True]; |
Sapan Bhatia | 170ae27 | 2017-05-30 19:01:09 +0200 | [diff] [blame] | 201 | optional string tenant_id = 3 [max_length = 200, content_type = "stripped", blank = True, help_text = "Keystone tenant id", null = True, db_index = True]; |
| 202 | } |
| 203 | |
Sapan Bhatia | 8918ac3 | 2017-07-09 00:43:27 -0400 | [diff] [blame] | 204 | message ControllerPrivilege (XOSBase) { |
| 205 | required manytoone controller->Controller:controllerprivileges = 1 [db_index = True, null = False, blank = False]; |
| 206 | required manytoone privilege->Privilege:controllerprivileges = 2 [db_index = True, null = False, blank = False]; |
| 207 | optional string role_id = 3 [max_length = 200, content_type = "stripped", blank = True, help_text = "Keystone id", null = True, db_index = True]; |
| 208 | } |
Sapan Bhatia | 170ae27 | 2017-05-30 19:01:09 +0200 | [diff] [blame] | 209 | |
| 210 | message ControllerSitePrivilege (XOSBase) { |
Sapan Bhatia | f7934b5 | 2017-06-12 05:04:23 -0700 | [diff] [blame] | 211 | required manytoone controller->Controller:controllersiteprivileges = 1 [db_index = True, null = False, blank = False, unique_with = "site_privilege"]; |
| 212 | required manytoone site_privilege->SitePrivilege:controllersiteprivileges = 2 [db_index = True, null = False, blank = False, unique_with = "role_id"]; |
Sapan Bhatia | 170ae27 | 2017-05-30 19:01:09 +0200 | [diff] [blame] | 213 | optional string role_id = 3 [max_length = 200, content_type = "stripped", blank = True, help_text = "Keystone id", null = True, db_index = True]; |
| 214 | } |
| 215 | |
Sapan Bhatia | b5ce186 | 2017-07-31 15:48:19 -0400 | [diff] [blame] | 216 | policy controller_slice_policy < |
| 217 | ctx.user.is_admin |
| 218 | | *slice_policy(slice) > |
Sapan Bhatia | 170ae27 | 2017-05-30 19:01:09 +0200 | [diff] [blame] | 219 | |
Sapan Bhatia | b5ce186 | 2017-07-31 15:48:19 -0400 | [diff] [blame] | 220 | message ControllerSlice::controller_slice_policy (XOSBase) { |
Sapan Bhatia | f7934b5 | 2017-06-12 05:04:23 -0700 | [diff] [blame] | 221 | required manytoone controller->Controller:controllerslices = 1 [db_index = True, null = False, blank = False, unique_with = "slice"]; |
Sapan Bhatia | 170ae27 | 2017-05-30 19:01:09 +0200 | [diff] [blame] | 222 | required manytoone slice->Slice:controllerslices = 2 [db_index = True, null = False, blank = False]; |
| 223 | optional string tenant_id = 3 [max_length = 200, content_type = "stripped", blank = True, help_text = "Keystone tenant id", null = True, db_index = False]; |
| 224 | } |
| 225 | |
| 226 | |
| 227 | message ControllerSlicePrivilege (XOSBase) { |
Sapan Bhatia | f7934b5 | 2017-06-12 05:04:23 -0700 | [diff] [blame] | 228 | required manytoone controller->Controller:controllersliceprivileges = 1 [db_index = True, null = False, blank = False, unique_with = "slice_privilege"]; |
Sapan Bhatia | 170ae27 | 2017-05-30 19:01:09 +0200 | [diff] [blame] | 229 | required manytoone slice_privilege->SlicePrivilege:controllersliceprivileges = 2 [db_index = True, null = False, blank = False]; |
| 230 | optional string role_id = 3 [max_length = 200, content_type = "stripped", blank = True, help_text = "Keystone id", null = True, db_index = True]; |
| 231 | } |
| 232 | |
Sapan Bhatia | b5ce186 | 2017-07-31 15:48:19 -0400 | [diff] [blame] | 233 | policy controller_user_policy < |
| 234 | ctx.user.is_admin |
| 235 | | (ctx.read_access & *user_policy(user)) > |
Sapan Bhatia | 170ae27 | 2017-05-30 19:01:09 +0200 | [diff] [blame] | 236 | |
Sapan Bhatia | b5ce186 | 2017-07-31 15:48:19 -0400 | [diff] [blame] | 237 | message ControllerUser::controller_user_policy (XOSBase) { |
Sapan Bhatia | 170ae27 | 2017-05-30 19:01:09 +0200 | [diff] [blame] | 238 | required manytoone user->User:controllerusers = 1 [db_index = True, null = False, blank = False]; |
Sapan Bhatia | f7934b5 | 2017-06-12 05:04:23 -0700 | [diff] [blame] | 239 | required manytoone controller->Controller:controllersusers = 2 [db_index = True, null = False, blank = False, unique_with = "user"]; |
Sapan Bhatia | 170ae27 | 2017-05-30 19:01:09 +0200 | [diff] [blame] | 240 | optional string kuser_id = 3 [max_length = 200, content_type = "stripped", blank = True, help_text = "Keystone user id", null = True, db_index = False]; |
| 241 | } |
| 242 | |
Sapan Bhatia | b5ce186 | 2017-07-31 15:48:19 -0400 | [diff] [blame] | 243 | // Everyone has read access |
| 244 | // For write access you need admin privileges at that deployment |
| 245 | policy deployment_policy < |
| 246 | ctx.user.is_admin |
| 247 | | (ctx.write_access -> exists Privilege: Privilege.object_type = "Deployment" & Privilege.object_id = obj.id & Privilege.accessor_id = ctx.user.id & Privilege.permission = "role:admin") > |
Sapan Bhatia | 170ae27 | 2017-05-30 19:01:09 +0200 | [diff] [blame] | 248 | |
Sapan Bhatia | b5ce186 | 2017-07-31 15:48:19 -0400 | [diff] [blame] | 249 | message Deployment::deployment_policy (XOSBase) { |
Sapan Bhatia | 170ae27 | 2017-05-30 19:01:09 +0200 | [diff] [blame] | 250 | required string name = 1 [max_length = 200, content_type = "stripped", blank = False, help_text = "Name of the Deployment", null = False, db_index = False]; |
Sapan Bhatia | d022aeb | 2017-06-07 15:49:55 +0200 | [diff] [blame] | 251 | required string accessControl = 2 [default = "allow all", max_length = 200, blank = False, help_text = "Access control list that specifies which sites/users may use nodes in this deployment", null = False, db_index = False, varchar = True]; |
Sapan Bhatia | 170ae27 | 2017-05-30 19:01:09 +0200 | [diff] [blame] | 252 | } |
| 253 | |
| 254 | |
| 255 | message DeploymentPrivilege (XOSBase) { |
Sapan Bhatia | f7934b5 | 2017-06-12 05:04:23 -0700 | [diff] [blame] | 256 | required manytoone user->User:deploymentprivileges = 1 [db_index = True, null = False, blank = False, unique_with="deployment"]; |
| 257 | required manytoone deployment->Deployment:deploymentprivileges = 2 [db_index = True, null = False, blank = False, unique_with="role"]; |
Sapan Bhatia | 170ae27 | 2017-05-30 19:01:09 +0200 | [diff] [blame] | 258 | required manytoone role->DeploymentRole:deploymentprivileges = 3 [db_index = True, null = False, blank = False]; |
| 259 | } |
| 260 | |
| 261 | |
| 262 | message DeploymentRole (XOSBase) { |
Matteo Scandolo | d0693cc | 2017-12-06 15:38:13 -0800 | [diff] [blame] | 263 | required string role = 1 [choices = "(('admin', 'Admin'),)", max_length = 30, content_type = "stripped", blank = False, null = False, db_index = False, tosca_key=True]; |
Sapan Bhatia | 170ae27 | 2017-05-30 19:01:09 +0200 | [diff] [blame] | 264 | } |
| 265 | |
| 266 | |
| 267 | message Diag (XOSBase) { |
Matteo Scandolo | 2521a4d | 2017-11-20 15:53:17 -0800 | [diff] [blame] | 268 | option gui_hidden = True; |
| 269 | required string name = 1 [max_length = 200, content_type = "stripped", blank = False, help_text = "Name of the synchronizer", null = False, db_index = False]; |
Sapan Bhatia | 170ae27 | 2017-05-30 19:01:09 +0200 | [diff] [blame] | 270 | } |
| 271 | |
| 272 | |
| 273 | message Flavor (XOSBase) { |
| 274 | required string name = 1 [max_length = 32, content_type = "stripped", blank = False, help_text = "name of this flavor, as displayed to users", null = False, db_index = False]; |
| 275 | optional string description = 2 [db_index = False, max_length = 1024, null = True, content_type = "stripped", blank = True]; |
| 276 | required string flavor = 3 [max_length = 32, content_type = "stripped", blank = False, help_text = "flavor string used to configure deployments", null = False, db_index = False]; |
Sapan Bhatia | 170ae27 | 2017-05-30 19:01:09 +0200 | [diff] [blame] | 277 | } |
| 278 | |
| 279 | |
| 280 | message Image (XOSBase) { |
| 281 | required string name = 1 [db_index = False, max_length = 256, null = False, content_type = "stripped", blank = False]; |
| 282 | required string kind = 2 [default = "vm", choices = "(('vm', 'Virtual Machine'), ('container', 'Container'))", max_length = 30, blank = False, null = False, db_index = False]; |
| 283 | required string disk_format = 3 [db_index = False, max_length = 256, null = False, content_type = "stripped", blank = False]; |
| 284 | required string container_format = 4 [db_index = False, max_length = 256, null = False, content_type = "stripped", blank = False]; |
| 285 | optional string path = 5 [max_length = 256, content_type = "stripped", blank = True, help_text = "Path to image on local disk", null = True, db_index = False]; |
| 286 | optional string tag = 6 [max_length = 256, content_type = "stripped", blank = True, help_text = "For Docker Images, tag of image", null = True, db_index = False]; |
Sapan Bhatia | 170ae27 | 2017-05-30 19:01:09 +0200 | [diff] [blame] | 287 | } |
| 288 | |
Sapan Bhatia | b5ce186 | 2017-07-31 15:48:19 -0400 | [diff] [blame] | 289 | policy image_deployment_policy < |
| 290 | *deployment_policy(deployment) |
| 291 | > |
Sapan Bhatia | 170ae27 | 2017-05-30 19:01:09 +0200 | [diff] [blame] | 292 | |
| 293 | message ImageDeployments (XOSBase) { |
Sapan Bhatia | f7934b5 | 2017-06-12 05:04:23 -0700 | [diff] [blame] | 294 | required manytoone image->Image:imagedeployments = 1 [db_index = True, null = False, blank = False, unique_with = "deployment"]; |
Sapan Bhatia | 170ae27 | 2017-05-30 19:01:09 +0200 | [diff] [blame] | 295 | required manytoone deployment->Deployment:imagedeployments = 2 [db_index = True, null = False, blank = False]; |
| 296 | } |
| 297 | |
Sapan Bhatia | 5ea307d | 2017-07-19 00:13:21 -0400 | [diff] [blame] | 298 | policy instance_creator < obj.creator > |
Sapan Bhatia | 9227b4d | 2017-07-25 23:14:48 -0400 | [diff] [blame] | 299 | policy instance_isolation < (obj.isolation = "container" | obj.isolation = "container_vm" ) -> (obj.image.kind = "container") > |
| 300 | policy instance_isolation_container_vm_parent < (obj.isolation = "container_vm") -> obj.parent > |
| 301 | policy instance_parent_isolation_container_vm < obj.parent -> ( obj.isolation = "container_vm" ) > |
Sapan Bhatia | 5ea307d | 2017-07-19 00:13:21 -0400 | [diff] [blame] | 302 | policy instance_isolation_vm < (obj.isolation = "vm") -> (obj.image.kind = "vm") > |
Sapan Bhatia | 5ea307d | 2017-07-19 00:13:21 -0400 | [diff] [blame] | 303 | policy instance_creator_privilege < not (obj.slice.creator = obj.creator) -> exists Privilege:Privilege.object_id = obj.slice.id & Privilege.accessor_id = obj.creator.id & Privilege.object_type = "Slice" > |
Sapan Bhatia | 170ae27 | 2017-05-30 19:01:09 +0200 | [diff] [blame] | 304 | |
Sapan Bhatia | b5ce186 | 2017-07-31 15:48:19 -0400 | [diff] [blame] | 305 | policy instance_policy < *slice_policy(slice) > |
| 306 | |
| 307 | message Instance::instance_policy (XOSBase) { |
| 308 | option validators = "instance_creator:Instance has no creator, instance_isolation: Container instance {obj.name} must use container image, instance_isolation_container_vm_parent:Container-vm instance {obj.name} must have a parent, instance_parent_isolation_container_vm:Parent field can only be set on Container-vm instances ({obj.name}), instance_isolation_vm: VM Instance {obj.name} must use VM image, instance_creator_privilege: instance creator has no privileges on slice"; |
Sapan Bhatia | 170ae27 | 2017-05-30 19:01:09 +0200 | [diff] [blame] | 309 | optional string instance_id = 1 [max_length = 200, content_type = "stripped", blank = True, help_text = "Nova instance id", null = True, db_index = False]; |
| 310 | optional string instance_uuid = 2 [max_length = 200, content_type = "stripped", blank = True, help_text = "Nova instance uuid", null = True, db_index = False]; |
| 311 | required string name = 3 [max_length = 200, content_type = "stripped", blank = False, help_text = "Instance name", null = False, db_index = False]; |
| 312 | optional string instance_name = 4 [max_length = 200, content_type = "stripped", blank = True, help_text = "OpenStack generated name", null = True, db_index = False]; |
Matteo Scandolo | bd8caca | 2017-08-17 15:36:10 -0700 | [diff] [blame] | 313 | optional string ip = 5 [max_length = 39, content_type = "ip", blank = True, help_text = "Instance ip address", null = True, db_index = False, gui_hidden = True]; |
Sapan Bhatia | 170ae27 | 2017-05-30 19:01:09 +0200 | [diff] [blame] | 314 | required manytoone image->Image:instances = 6 [db_index = True, null = False, blank = False]; |
| 315 | optional manytoone creator->User:instances = 7 [db_index = True, null = True, blank = True]; |
| 316 | required manytoone slice->Slice:instances = 8 [db_index = True, null = False, blank = False]; |
| 317 | required manytoone deployment->Deployment:instance_deployment = 9 [db_index = True, null = False, blank = False]; |
| 318 | required manytoone node->Node:instances = 10 [db_index = True, null = False, blank = False]; |
| 319 | required int32 numberCores = 11 [help_text = "Number of cores for instance", default = 0, null = False, db_index = False, blank = False]; |
| 320 | required manytoone flavor->Flavor:instance = 12 [help_text = "Flavor of this instance", null = False, db_index = True, blank = False]; |
Sapan Bhatia | d022aeb | 2017-06-07 15:49:55 +0200 | [diff] [blame] | 321 | optional string userData = 13 [help_text = "user_data passed to instance during creation", null = True, db_index = False, blank = True, varchar = True]; |
Sapan Bhatia | 170ae27 | 2017-05-30 19:01:09 +0200 | [diff] [blame] | 322 | required string isolation = 14 [default = "vm", choices = "(('vm', 'Virtual Machine'), ('container', 'Container'), ('container_vm', 'Container In VM'))", max_length = 30, blank = False, null = False, db_index = False]; |
| 323 | optional string volumes = 15 [help_text = "Comma-separated list of directories to expose to parent context", null = True, db_index = False, blank = True]; |
| 324 | optional manytoone parent->Instance:instance = 16 [help_text = "Parent Instance for containers nested inside of VMs", null = True, db_index = True, blank = True]; |
| 325 | } |
Sapan Bhatia | b5ce186 | 2017-07-31 15:48:19 -0400 | [diff] [blame] | 326 | |
| 327 | |
| 328 | policy network_policy < *slice_policy(owner) > |
| 329 | |
| 330 | message Network::network_policy (XOSBase) { |
Sapan Bhatia | 170ae27 | 2017-05-30 19:01:09 +0200 | [diff] [blame] | 331 | required string name = 1 [db_index = False, max_length = 32, null = False, blank = False]; |
| 332 | required manytoone template->NetworkTemplate:network = 2 [db_index = True, null = False, blank = False]; |
| 333 | required string subnet = 3 [db_index = False, max_length = 32, null = False, blank = True]; |
| 334 | required string start_ip = 4 [db_index = False, max_length = 32, null = False, blank = True]; |
| 335 | required string end_ip = 5 [db_index = False, max_length = 32, null = False, blank = True]; |
| 336 | optional string ports = 6 [db_index = False, max_length = 1024, null = True, blank = True]; |
| 337 | optional string labels = 7 [db_index = False, max_length = 1024, null = True, blank = True]; |
| 338 | required manytoone owner->Slice:ownedNetworks = 8 [help_text = "Slice that owns control of this Network", null = False, db_index = True, blank = False]; |
| 339 | required bool permit_all_slices = 10 [default = False, null = False, db_index = False, blank = True]; |
| 340 | required bool autoconnect = 17 [help_text = "This network can be autoconnected to the slice that owns it", default = True, null = False, db_index = False, blank = True]; |
| 341 | required manytomany permitted_slices->Slice/Network_permitted_slices:availableNetworks = 18 [db_index = False, null = False, blank = True]; |
| 342 | required manytomany slices->Slice/NetworkSlice:networks = 19 [db_index = False, null = False, blank = True]; |
| 343 | required manytomany instances->Instance/Port:networks = 20 [db_index = False, null = False, blank = True]; |
| 344 | } |
| 345 | |
| 346 | |
| 347 | message NetworkParameter (XOSBase) { |
| 348 | required manytoone parameter->NetworkParameterType:networkparameters = 1 [help_text = "The type of the parameter", null = False, db_index = True, blank = False]; |
| 349 | required string value = 2 [help_text = "The value of this parameter", max_length = 1024, null = False, db_index = False, blank = False]; |
| 350 | required string content_type = 4 [max_length = 1024, content_type = "stripped", blank = False, help_text = "Content type id linked to this network parameter", null = False, db_index = False]; |
| 351 | required uint32 object_id = 4 [db_index = False, null = False, blank = False, help_text = "Object linked to this NetworkParameter"]; |
| 352 | } |
| 353 | |
| 354 | |
| 355 | message NetworkParameterType (XOSBase) { |
| 356 | required string name = 1 [help_text = "The name of this parameter", max_length = 128, null = False, db_index = True, blank = False]; |
| 357 | required string description = 2 [db_index = False, max_length = 1024, null = False, blank = False]; |
| 358 | } |
| 359 | |
Sapan Bhatia | 9227b4d | 2017-07-25 23:14:48 -0400 | [diff] [blame] | 360 | policy network_slice_validator < (obj.slice in obj.network.permitted_slices.all()) | (obj.slice = obj.network.owner) | obj.network.permit_all_slices > |
Sapan Bhatia | b5ce186 | 2017-07-31 15:48:19 -0400 | [diff] [blame] | 361 | policy network_slice_policy < *slice_policy(slice) & *network_policy(network) > |
Sapan Bhatia | 170ae27 | 2017-05-30 19:01:09 +0200 | [diff] [blame] | 362 | |
Sapan Bhatia | b5ce186 | 2017-07-31 15:48:19 -0400 | [diff] [blame] | 363 | message NetworkSlice::network_slice_policy (XOSBase) { |
Sapan Bhatia | 3941959 | 2017-10-19 13:02:22 -0400 | [diff] [blame] | 364 | option validators = "network_slice_validator:Slice {obj.slice.name} is not allowed to connect to networks {obj.network}"; |
Matteo Scandolo | fb37c8f | 2017-10-18 09:53:30 +0200 | [diff] [blame] | 365 | required manytoone network->Network:networkslices = 1 [db_index = True, null = False, blank = False, unique_with = "slice", tosca_key=True]; |
| 366 | required manytoone slice->Slice:networkslices = 2 [db_index = True, null = False, blank = False, tosca_key=True]; |
Sapan Bhatia | 170ae27 | 2017-05-30 19:01:09 +0200 | [diff] [blame] | 367 | } |
Sapan Bhatia | 5ea307d | 2017-07-19 00:13:21 -0400 | [diff] [blame] | 368 | |
Sapan Bhatia | 170ae27 | 2017-05-30 19:01:09 +0200 | [diff] [blame] | 369 | message NetworkTemplate (XOSBase) { |
| 370 | required string name = 1 [db_index = False, max_length = 32, null = False, blank = False]; |
| 371 | optional string description = 2 [db_index = False, max_length = 1024, null = True, blank = True]; |
| 372 | required string visibility = 4 [default = "private", choices = "(('public', 'public'), ('private', 'private'))", max_length = 30, blank = False, null = False, db_index = False]; |
| 373 | required string translation = 5 [default = "none", choices = "(('none', 'none'), ('NAT', 'NAT'))", max_length = 30, blank = False, null = False, db_index = False]; |
| 374 | optional string access = 6 [choices = "((None, 'None'), ('indirect', 'Indirect'), ('direct', 'Direct'))", max_length = 30, blank = True, help_text = "Advertise this network as a means for other slices to contact this slice", null = True, db_index = False]; |
| 375 | optional string shared_network_name = 7 [db_index = False, max_length = 30, null = True, blank = True]; |
| 376 | optional string shared_network_id = 8 [help_text = "Quantum network", max_length = 256, null = True, db_index = False, blank = True]; |
| 377 | required string topology_kind = 9 [default = "bigswitch", choices = "(('bigswitch', 'BigSwitch'), ('physical', 'Physical'), ('custom', 'Custom'))", max_length = 30, blank = False, null = False, db_index = False]; |
| 378 | optional string controller_kind = 10 [blank = True, max_length = 30, null = True, db_index = False, choices = "((None, 'None'), ('onos', 'ONOS'), ('custom', 'Custom'))"]; |
| 379 | optional string vtn_kind = 11 [default = "PRIVATE", choices = "(('PRIVATE', 'Private'), ('PUBLIC', 'Public'), ('MANAGEMENT_LOCAL', 'Management Local'), ('MANAGEMENT_HOST', 'Management Host'), ('VSG', 'VSG'), ('ACCESS_AGENT', 'Access Agent'))", max_length = 30, blank = True, null = True, db_index = False]; |
| 380 | } |
Sapan Bhatia | b5ce186 | 2017-07-31 15:48:19 -0400 | [diff] [blame] | 381 | |
| 382 | policy node_policy < *site_policy(site_deployment.site) > |
| 383 | |
| 384 | message Node::node_policy (XOSBase) { |
Sapan Bhatia | 170ae27 | 2017-05-30 19:01:09 +0200 | [diff] [blame] | 385 | required string name = 1 [max_length = 200, content_type = "stripped", blank = False, help_text = "Name of the Node", null = False, db_index = False]; |
| 386 | required manytoone site_deployment->SiteDeployment:nodes = 2 [db_index = True, null = False, blank = False]; |
| 387 | } |
| 388 | message NodeLabel (XOSBase) { |
| 389 | required string name = 1 [max_length = 200, content_type = "stripped", blank = False, help_text = "label name", null = False, db_index = False]; |
| 390 | required manytomany node->Node/NodeLabel_node:nodelabels = 2 [db_index = False, null = False, blank = True]; |
| 391 | } |
Sapan Bhatia | 5ea307d | 2017-07-19 00:13:21 -0400 | [diff] [blame] | 392 | |
Sapan Bhatia | 9227b4d | 2017-07-25 23:14:48 -0400 | [diff] [blame] | 393 | policy port_validator < (obj.instance.slice in obj.network.permitted_slices.all()) | (obj.instance.slice = obj.network.owner) | obj.network.permit_all_slices > |
Sapan Bhatia | b5ce186 | 2017-07-31 15:48:19 -0400 | [diff] [blame] | 394 | policy port_policy < *instance_policy(instance) & *network_policy(network) > |
Sapan Bhatia | 5ea307d | 2017-07-19 00:13:21 -0400 | [diff] [blame] | 395 | |
Sapan Bhatia | b5ce186 | 2017-07-31 15:48:19 -0400 | [diff] [blame] | 396 | message Port::port_policy (XOSBase) { |
Sapan Bhatia | 9227b4d | 2017-07-25 23:14:48 -0400 | [diff] [blame] | 397 | option validators = "port_validator:Slice is not allowed to connect to network"; |
Sapan Bhatia | f7934b5 | 2017-06-12 05:04:23 -0700 | [diff] [blame] | 398 | required manytoone network->Network:links = 1 [db_index = True, null = False, blank = False, unique_with = "instance"]; |
Sapan Bhatia | 170ae27 | 2017-05-30 19:01:09 +0200 | [diff] [blame] | 399 | optional manytoone instance->Instance:ports = 2 [db_index = True, null = True, blank = True]; |
| 400 | optional string ip = 3 [max_length = 39, content_type = "ip", blank = True, help_text = "Instance ip address", null = True, db_index = False]; |
| 401 | optional string port_id = 4 [help_text = "Neutron port id", max_length = 256, null = True, db_index = False, blank = True]; |
| 402 | optional string mac = 5 [help_text = "MAC address associated with this port", max_length = 256, null = True, db_index = False, blank = True]; |
| 403 | required bool xos_created = 6 [default = False, null = False, db_index = False, blank = True]; |
| 404 | } |
| 405 | |
| 406 | |
| 407 | message Role (XOSBase) { |
| 408 | required string role_type = 1 [db_index = False, max_length = 80, null = False, content_type = "stripped", blank = False]; |
| 409 | optional string role = 2 [db_index = False, max_length = 80, null = True, content_type = "stripped", blank = True]; |
| 410 | required string description = 3 [db_index = False, max_length = 120, null = False, content_type = "stripped", blank = False]; |
| 411 | } |
| 412 | |
Sapan Bhatia | b5ce186 | 2017-07-31 15:48:19 -0400 | [diff] [blame] | 413 | policy service_policy <ctx.user.is_admin | exists Privilege: Privilege.accessor_id = ctx.user.id & Privilege.accessor_type = "User" & Privilege.object_type = "Service" & Privilege.object_id = obj.id > |
Sapan Bhatia | 170ae27 | 2017-05-30 19:01:09 +0200 | [diff] [blame] | 414 | |
| 415 | message Service (XOSBase,AttributeMixin) { |
Sapan Bhatia | d022aeb | 2017-06-07 15:49:55 +0200 | [diff] [blame] | 416 | optional string description = 1 [help_text = "Description of Service", max_length = 254, null = True, db_index = False, blank = True, varchar = True]; |
Sapan Bhatia | 170ae27 | 2017-05-30 19:01:09 +0200 | [diff] [blame] | 417 | required bool enabled = 2 [default = True, null = False, db_index = False, blank = True]; |
Scott Baker | d6e533f | 2017-07-17 13:37:29 -0700 | [diff] [blame] | 418 | required string kind = 3 [default = "generic", max_length = 30, content_type = "stripped", blank = False, help_text = "Kind of service", null = False, db_index = False, choices="(('generic', 'Generic'), ('data', 'Data Plane'), ('control', 'Control Plane'))"]; |
Sapan Bhatia | 170ae27 | 2017-05-30 19:01:09 +0200 | [diff] [blame] | 419 | required string name = 4 [max_length = 30, content_type = "stripped", blank = False, help_text = "Service Name", null = False, db_index = False]; |
| 420 | optional string versionNumber = 5 [max_length = 30, content_type = "stripped", blank = True, help_text = "Version of Service Definition", null = True, db_index = False]; |
| 421 | required bool published = 6 [default = True, null = False, db_index = False, blank = True]; |
| 422 | optional string view_url = 7 [db_index = False, max_length = 1024, null = True, content_type = "stripped", blank = True]; |
| 423 | optional string icon_url = 8 [db_index = False, max_length = 1024, null = True, content_type = "stripped", blank = True]; |
Sapan Bhatia | d022aeb | 2017-06-07 15:49:55 +0200 | [diff] [blame] | 424 | optional string public_key = 9 [help_text = "Public key string", max_length = 4096, null = True, db_index = False, blank = True, varchar = True]; |
Zack Williams | f517e40 | 2017-05-20 13:37:43 -0700 | [diff] [blame] | 425 | optional string private_key_fn = 10 [db_index = False, max_length = 4096, null = True, content_type = "stripped", blank = True]; |
Sapan Bhatia | 170ae27 | 2017-05-30 19:01:09 +0200 | [diff] [blame] | 426 | optional string service_specific_id = 11 [db_index = False, max_length = 30, null = True, content_type = "stripped", blank = True]; |
Sapan Bhatia | d022aeb | 2017-06-07 15:49:55 +0200 | [diff] [blame] | 427 | optional string service_specific_attribute = 12 [db_index = False, null = True, blank = True, varchar = True]; |
Sapan Bhatia | 170ae27 | 2017-05-30 19:01:09 +0200 | [diff] [blame] | 428 | } |
| 429 | |
| 430 | |
| 431 | message ServiceAttribute (XOSBase) { |
| 432 | required string name = 1 [help_text = "Attribute Name", max_length = 128, null = False, db_index = False, blank = False]; |
Sapan Bhatia | d022aeb | 2017-06-07 15:49:55 +0200 | [diff] [blame] | 433 | required string value = 2 [help_text = "Attribute Value", null = False, db_index = False, blank = False, varchar = True]; |
Sapan Bhatia | 170ae27 | 2017-05-30 19:01:09 +0200 | [diff] [blame] | 434 | required manytoone service->Service:serviceattributes = 3 [help_text = "The Service this attribute is associated with", null = False, db_index = True, blank = False]; |
| 435 | } |
| 436 | |
| 437 | |
Scott Baker | 071da96 | 2017-07-13 10:43:41 -0700 | [diff] [blame] | 438 | message ServiceDependency (XOSBase) { |
Matteo Scandolo | fb37c8f | 2017-10-18 09:53:30 +0200 | [diff] [blame] | 439 | required manytoone provider_service->Service:provided_dependencies = 1 [help_text = "The service that provides this dependency", null=False, db_index = True, blank=False, tosca_key=True]; |
Wei-Yu Chen | 99a618d | 2018-03-14 13:42:12 +0800 | [diff] [blame] | 440 | required manytoone subscriber_service->Service:subscribed_dependencies = 2 [help_text = "The services that subscribes to this dependency", null=False, db_index=True, blank=False, tosca_key=True]; |
Scott Baker | 071da96 | 2017-07-13 10:43:41 -0700 | [diff] [blame] | 441 | required string connect_method = 3 [max_length = 30, help_text = "method to connect the two services", null=False, blank=False, default="none", choices = "(('none', 'None'), ('private', 'Private'), ('public', 'Public'))"]; |
Sapan Bhatia | 170ae27 | 2017-05-30 19:01:09 +0200 | [diff] [blame] | 442 | } |
| 443 | |
| 444 | |
| 445 | message ServiceMonitoringAgentInfo (XOSBase) { |
| 446 | required string name = 1 [help_text = "Monitoring Agent Name", max_length = 128, null = False, db_index = False, blank = False]; |
| 447 | optional manytoone service->Service:servicemonitoringagents = 2 [help_text = "The Service this attribute is associated with", null = True, db_index = True, blank = True]; |
Sapan Bhatia | d022aeb | 2017-06-07 15:49:55 +0200 | [diff] [blame] | 448 | required string target_uri = 3 [help_text = "Monitoring collector URI to be used by agents to publish the data", null = False, db_index = False, blank = False, varchar = True]; |
Sapan Bhatia | 170ae27 | 2017-05-30 19:01:09 +0200 | [diff] [blame] | 449 | } |
| 450 | |
| 451 | |
| 452 | message ServicePrivilege (XOSBase) { |
Sapan Bhatia | f7934b5 | 2017-06-12 05:04:23 -0700 | [diff] [blame] | 453 | required manytoone user->User:serviceprivileges = 1 [db_index = True, null = False, blank = False, unique_with = "service"]; |
| 454 | required manytoone service->Service:serviceprivileges = 2 [db_index = True, null = False, blank = False, unique_with = "role"]; |
Sapan Bhatia | 170ae27 | 2017-05-30 19:01:09 +0200 | [diff] [blame] | 455 | required manytoone role->ServiceRole:serviceprivileges = 3 [db_index = True, null = False, blank = False]; |
| 456 | } |
| 457 | |
| 458 | |
| 459 | message ServiceRole (XOSBase) { |
| 460 | required string role = 1 [choices = "(('admin', 'Admin'),)", max_length = 30, content_type = "stripped", blank = False, null = False, db_index = False]; |
| 461 | } |
| 462 | |
| 463 | |
Sapan Bhatia | b5ce186 | 2017-07-31 15:48:19 -0400 | [diff] [blame] | 464 | |
| 465 | message Site::site_policy (XOSBase) { |
Sapan Bhatia | 170ae27 | 2017-05-30 19:01:09 +0200 | [diff] [blame] | 466 | required string name = 1 [max_length = 200, content_type = "stripped", blank = False, help_text = "Name for this Site", null = False, db_index = False]; |
| 467 | optional string site_url = 2 [max_length = 512, content_type = "url", blank = True, help_text = "Site's Home URL Page", null = True, db_index = False]; |
| 468 | required bool enabled = 3 [help_text = "Status for this Site", default = True, null = False, db_index = False, blank = True]; |
| 469 | required bool hosts_nodes = 4 [help_text = "Indicates whether or not the site host nodes", default = True, null = False, db_index = False, blank = True]; |
| 470 | required bool hosts_users = 5 [help_text = "Indicates whether or not the site manages user accounts", default = True, null = False, db_index = False, blank = True]; |
| 471 | optional float longitude = 6 [db_index = False, null = True, blank = True]; |
| 472 | optional float latitude = 7 [db_index = False, null = True, blank = True]; |
| 473 | required string login_base = 8 [max_length = 50, content_type = "stripped", blank = False, help_text = "Prefix for Slices associated with this Site", null = False, db_index = False]; |
| 474 | required bool is_public = 9 [help_text = "Indicates the visibility of this site to other members", default = True, null = False, db_index = False, blank = True]; |
| 475 | required string abbreviated_name = 10 [db_index = False, max_length = 80, null = False, content_type = "stripped", blank = False]; |
| 476 | required manytomany deployments->Deployment/SiteDeployment:sites = 11 [help_text = "Select which sites are allowed to host nodes in this deployment", null = False, db_index = False, blank = True]; |
| 477 | } |
| 478 | |
| 479 | |
| 480 | message SiteDeployment (XOSBase) { |
Matteo Scandolo | fb37c8f | 2017-10-18 09:53:30 +0200 | [diff] [blame] | 481 | required manytoone site->Site:sitedeployments = 1 [db_index = True, null = False, blank = False, unique_with = "deployment", tosca_key=True]; |
| 482 | required manytoone deployment->Deployment:sitedeployments = 2 [db_index = True, null = False, blank = False, unique_with = "controller", tosca_key=True]; |
Sapan Bhatia | 170ae27 | 2017-05-30 19:01:09 +0200 | [diff] [blame] | 483 | optional manytoone controller->Controller:sitedeployments = 3 [db_index = True, null = True, blank = True]; |
| 484 | optional string availability_zone = 4 [max_length = 200, content_type = "stripped", blank = True, help_text = "OpenStack availability zone", null = True, db_index = False]; |
| 485 | } |
| 486 | |
| 487 | |
| 488 | message SitePrivilege (XOSBase) { |
| 489 | required manytoone user->User:siteprivileges = 1 [db_index = True, null = False, blank = False]; |
Matteo Scandolo | fb37c8f | 2017-10-18 09:53:30 +0200 | [diff] [blame] | 490 | required manytoone site->Site:siteprivileges = 2 [db_index = True, null = False, blank = False, tosca_key=True]; |
| 491 | required manytoone role->SiteRole:siteprivileges = 3 [db_index = True, null = False, blank = False, tosca_key=True]; |
Sapan Bhatia | 170ae27 | 2017-05-30 19:01:09 +0200 | [diff] [blame] | 492 | } |
| 493 | |
| 494 | |
| 495 | message SiteRole (XOSBase) { |
Matteo Scandolo | d0693cc | 2017-12-06 15:38:13 -0800 | [diff] [blame] | 496 | required string role = 1 [choices = "(('admin', 'Admin'), ('pi', 'PI'), ('tech', 'Tech'), ('billing', 'Billing'))", max_length = 30, content_type = "stripped", blank = False, null = False, db_index = False, tosca_key=True]; |
Sapan Bhatia | 170ae27 | 2017-05-30 19:01:09 +0200 | [diff] [blame] | 497 | } |
Sapan Bhatia | cb35e7f | 2017-05-24 12:17:28 +0200 | [diff] [blame] | 498 | |
Sapan Bhatia | 9227b4d | 2017-07-25 23:14:48 -0400 | [diff] [blame] | 499 | policy slice_name < obj.id | {{ obj.name.startswith(obj.site.login_base) }} > |
Sapan Bhatia | 5ea307d | 2017-07-19 00:13:21 -0400 | [diff] [blame] | 500 | policy slice_name_length_and_no_spaces < {{ len(obj.site.login_base) + 1 < len(obj.name) and ' ' not in obj.name }} > |
| 501 | policy slice_has_creator < obj.creator > |
| 502 | |
Sapan Bhatia | b5ce186 | 2017-07-31 15:48:19 -0400 | [diff] [blame] | 503 | |
| 504 | |
| 505 | message Slice::slice_policy (XOSBase) { |
Sapan Bhatia | 3941959 | 2017-10-19 13:02:22 -0400 | [diff] [blame] | 506 | option validators = "slice_name:Slice name ({obj.name}) must begin with site login_base ({obj.site.login_base}), slice_name_length_and_no_spaces:Slice name too short or contains spaces, slice_has_creator:Slice has no creator"; |
Sapan Bhatia | cb35e7f | 2017-05-24 12:17:28 +0200 | [diff] [blame] | 507 | option plural = "Slices"; |
Sapan Bhatia | 5ea307d | 2017-07-19 00:13:21 -0400 | [diff] [blame] | 508 | |
Sapan Bhatia | 170ae27 | 2017-05-30 19:01:09 +0200 | [diff] [blame] | 509 | required string name = 1 [max_length = 80, content_type = "stripped", blank = False, help_text = "The Name of the Slice", null = False, db_index = False]; |
| 510 | required bool enabled = 2 [help_text = "Status for this Slice", default = True, null = False, db_index = False, blank = True]; |
Sapan Bhatia | d022aeb | 2017-06-07 15:49:55 +0200 | [diff] [blame] | 511 | required string description = 4 [help_text = "High level description of the slice and expected activities", max_length = 1024, null = False, db_index = False, blank = True, varchar = True]; |
Sapan Bhatia | 170ae27 | 2017-05-30 19:01:09 +0200 | [diff] [blame] | 512 | required string slice_url = 5 [db_index = False, max_length = 512, null = False, content_type = "url", blank = True]; |
| 513 | required manytoone site->Site:slices = 6 [help_text = "The Site this Slice belongs to", null = False, db_index = True, blank = False]; |
| 514 | required int32 max_instances = 7 [default = 10, null = False, db_index = False, blank = False]; |
| 515 | optional manytoone service->Service:slices = 8 [db_index = True, null = True, blank = True]; |
| 516 | optional string network = 9 [blank = True, max_length = 256, null = True, db_index = False, choices = "((None, 'Default'), ('host', 'Host'), ('bridged', 'Bridged'), ('noauto', 'No Automatic Networks'))"]; |
| 517 | optional string exposed_ports = 10 [db_index = False, max_length = 256, null = True, blank = True]; |
Sapan Bhatia | fd37ac5 | 2017-09-01 23:21:46 -0400 | [diff] [blame] | 518 | optional manytoone creator->User:slices = 12 [db_index = True, null = False, blank = False]; |
Sapan Bhatia | 170ae27 | 2017-05-30 19:01:09 +0200 | [diff] [blame] | 519 | optional manytoone default_flavor->Flavor:slices = 13 [db_index = True, null = True, blank = True]; |
| 520 | optional manytoone default_image->Image:slices = 14 [db_index = True, null = True, blank = True]; |
| 521 | optional manytoone default_node->Node:slices = 15 [db_index = True, null = True, blank = True]; |
| 522 | optional string mount_data_sets = 16 [default = "GenBank", max_length = 256, content_type = "stripped", blank = True, null = True, db_index = False]; |
| 523 | required string default_isolation = 17 [default = "vm", choices = "(('vm', 'Virtual Machine'), ('container', 'Container'), ('container_vm', 'Container In VM'))", max_length = 30, blank = False, null = False, db_index = False]; |
| 524 | } |
| 525 | |
| 526 | |
| 527 | message SlicePrivilege (XOSBase) { |
Sapan Bhatia | f7934b5 | 2017-06-12 05:04:23 -0700 | [diff] [blame] | 528 | required manytoone user->User:sliceprivileges = 1 [db_index = True, null = False, blank = False, unique_with = "slice"]; |
| 529 | required manytoone slice->Slice:sliceprivileges = 2 [db_index = True, null = False, blank = False, unique_with = "role"]; |
Sapan Bhatia | 170ae27 | 2017-05-30 19:01:09 +0200 | [diff] [blame] | 530 | required manytoone role->SliceRole:sliceprivileges = 3 [db_index = True, null = False, blank = False]; |
| 531 | } |
| 532 | |
| 533 | |
| 534 | message SliceRole (XOSBase) { |
Matteo Scandolo | d0693cc | 2017-12-06 15:38:13 -0800 | [diff] [blame] | 535 | required string role = 1 [choices = "(('admin', 'Admin'), ('default', 'Default'))", max_length = 30, content_type = "stripped", blank = False, null = False, db_index = False, tosca_key=True]; |
Sapan Bhatia | 170ae27 | 2017-05-30 19:01:09 +0200 | [diff] [blame] | 536 | } |
| 537 | |
Sapan Bhatia | b5ce186 | 2017-07-31 15:48:19 -0400 | [diff] [blame] | 538 | policy tag_policy < ctx.user.is_admin > |
Sapan Bhatia | 170ae27 | 2017-05-30 19:01:09 +0200 | [diff] [blame] | 539 | |
Sapan Bhatia | b5ce186 | 2017-07-31 15:48:19 -0400 | [diff] [blame] | 540 | message Tag::tag_policy (XOSBase) { |
Sapan Bhatia | 170ae27 | 2017-05-30 19:01:09 +0200 | [diff] [blame] | 541 | required manytoone service->Service:tags = 1 [help_text = "The Service this Tag is associated with", null = False, db_index = True, blank = False]; |
| 542 | required string name = 2 [help_text = "The name of this tag", max_length = 128, null = False, db_index = True, blank = False]; |
| 543 | required string value = 3 [max_length = 1024, content_type = "stripped", blank = False, help_text = "The value of this tag", null = False, db_index = False]; |
| 544 | required string content_type = 4 [max_length = 1024, content_type = "stripped", blank = False, help_text = "Content type id linked to this tag", null = False, db_index = False]; |
| 545 | required uint32 object_id = 5 [db_index = False, null = False, blank = False, help_text = "Object linked to this tag"]; |
| 546 | } |
| 547 | |
Scott Baker | d6e533f | 2017-07-17 13:37:29 -0700 | [diff] [blame] | 548 | message InterfaceType (XOSBase) { |
| 549 | required string name = 1 [db_index = False, max_length = 200, null = False, content_type = "stripped", blank = False]; |
| 550 | required string direction = 2 [db_index = False, max_length = 30, null = False, content_type = "stripped", blank = False, choices = "(('in', 'In'), ('out', 'Out'))"]; |
Sapan Bhatia | 170ae27 | 2017-05-30 19:01:09 +0200 | [diff] [blame] | 551 | } |
| 552 | |
Scott Baker | d6e533f | 2017-07-17 13:37:29 -0700 | [diff] [blame] | 553 | message ServiceInterface (XOSBase) { |
Matteo Scandolo | fb37c8f | 2017-10-18 09:53:30 +0200 | [diff] [blame] | 554 | required manytoone service->Service:service_interfaces = 1 [db_index = True, null = False, blank = False, tosca_key=True]; |
| 555 | required manytoone interface_type->InterfaceType:service_interfaces = 2 [db_index = True, null = False, blank = False, tosca_key=True]; |
Scott Baker | d6e533f | 2017-07-17 13:37:29 -0700 | [diff] [blame] | 556 | } |
| 557 | |
| 558 | message ServiceInstance (XOSBase, AttributeMixin) { |
| 559 | optional string name = 1 [db_index = False, max_length = 200, null = True, content_type = "stripped", blank = True]; |
| 560 | required manytoone owner->Service:service_instances = 2 [db_index = True, null = False, blank = False]; |
| 561 | optional string service_specific_id = 3 [db_index = False, max_length = 30, null = True, content_type = "stripped", blank = True]; |
| 562 | optional string service_specific_attribute = 10 [db_index = False, null = True, blank = True, varchar = True]; |
Scott Baker | dbb3627 | 2017-09-05 17:12:33 -0700 | [diff] [blame] | 563 | optional uint32 link_deleted_count = 11 [default = 0, help_text = "Incremented each time a provided_link is deleted from this ServiceInstance"]; |
Sapan Bhatia | 2189011 | 2017-10-31 00:25:47 -0400 | [diff] [blame] | 564 | optional manytoone master_serviceinstance->ServiceInstance:child_serviceinstances = 12 [help_text = "The master service instance that set this service instance up"]; |
Scott Baker | d6e533f | 2017-07-17 13:37:29 -0700 | [diff] [blame] | 565 | } |
| 566 | |
| 567 | message ServiceInstanceLink (XOSBase) { |
Matteo Scandolo | fb37c8f | 2017-10-18 09:53:30 +0200 | [diff] [blame] | 568 | required manytoone provider_service_instance->ServiceInstance:provided_links = 1 [db_index = True, null = False, blank = False, tosca_key=True]; |
Scott Baker | d6e533f | 2017-07-17 13:37:29 -0700 | [diff] [blame] | 569 | optional manytoone provider_service_interface->ServiceInterface:provided_links = 2 [db_index = True, null = True, blank = True]; |
| 570 | optional manytoone subscriber_service_instance->ServiceInstance:subscribed_links = 3 [db_index = True, null = True, blank = True]; |
Matteo Scandolo | d0693cc | 2017-12-06 15:38:13 -0800 | [diff] [blame] | 571 | optional manytoone subscriber_service->Service:subscribed_links = 4 [db_index = True, null = True, blank = True, tosca_key_one_of=subscriber_service_instance]; |
| 572 | optional manytoone subscriber_network->Network:subscribed_links = 5 [db_index = True, null = True, blank = True, tosca_key_one_of=subscriber_service_instance]; |
Scott Baker | d6e533f | 2017-07-17 13:37:29 -0700 | [diff] [blame] | 573 | } |
| 574 | |
| 575 | message ServiceInstanceAttribute (XOSBase) { |
Sapan Bhatia | 170ae27 | 2017-05-30 19:01:09 +0200 | [diff] [blame] | 576 | required string name = 1 [help_text = "Attribute Name", max_length = 128, null = False, db_index = False, blank = False]; |
| 577 | required string value = 2 [help_text = "Attribute Value", null = False, db_index = False, blank = False]; |
Scott Baker | d6e533f | 2017-07-17 13:37:29 -0700 | [diff] [blame] | 578 | required manytoone service_instance->ServiceInstance:service_instance_attributes = 3 [help_text = "The Tenant this attribute is associated with", null = False, db_index = True, blank = False]; |
Sapan Bhatia | 170ae27 | 2017-05-30 19:01:09 +0200 | [diff] [blame] | 579 | } |
| 580 | |
Scott Baker | d6e533f | 2017-07-17 13:37:29 -0700 | [diff] [blame] | 581 | message TenantWithContainer (ServiceInstance) { |
Sapan Bhatia | 170ae27 | 2017-05-30 19:01:09 +0200 | [diff] [blame] | 582 | optional manytoone instance->Instance:+ = 1 [help_text = "Instance used by this Tenant", null = True, db_index = True, blank = True]; |
| 583 | optional manytoone creator->User:+ = 2 [help_text = "Creator of this Tenant", null = True, db_index = True, blank = True]; |
| 584 | optional string external_hostname = 3 [max_length = 30, content_type = "stripped", blank = True, help_text = "External host name", null = True, db_index = False]; |
| 585 | optional string external_container = 4 [max_length = 30, content_type = "stripped", blank = True, help_text = "External host name", null = True, db_index = False]; |
| 586 | } |
| 587 | |
Sapan Bhatia | 170ae27 | 2017-05-30 19:01:09 +0200 | [diff] [blame] | 588 | message XOS (XOSBase) { |
Sapan Bhatia | cb35e7f | 2017-05-24 12:17:28 +0200 | [diff] [blame] | 589 | option singular="XOS"; |
| 590 | option plural="XOSes"; |
Sapan Bhatia | 170ae27 | 2017-05-30 19:01:09 +0200 | [diff] [blame] | 591 | required string name = 1 [default = "XOS", max_length = 200, content_type = "stripped", blank = False, help_text = "Name of XOS", null = False, db_index = False]; |
| 592 | } |
| 593 | |
Matteo Scandolo | 81c154d | 2017-11-22 14:55:09 -0800 | [diff] [blame] | 594 | message XOSGuiExtension::admin_policy (XOSBase) { |
Matteo Scandolo | e425f9d | 2017-08-15 15:56:19 -0700 | [diff] [blame] | 595 | option verbose_name="XOS GUI Extension"; |
| 596 | option description="This model holds the instruction to load an extension in the GUI"; |
Matteo Scandolo | cf39779 | 2017-12-01 11:49:45 -0800 | [diff] [blame] | 597 | // option no_sync = True; |
| 598 | // option no_policy = True; |
Matteo Scandolo | 31363ca | 2017-11-17 11:09:21 -0800 | [diff] [blame] | 599 | |
Sapan Bhatia | 170ae27 | 2017-05-30 19:01:09 +0200 | [diff] [blame] | 600 | required string name = 1 [max_length = 200, content_type = "stripped", blank = False, help_text = "Name of the GUI Extensions", null = False, db_index = False]; |
| 601 | required string files = 2 [max_length = 1024, content_type = "stripped", blank = False, help_text = "List of comma separated file composing the view", null = False, db_index = False]; |
| 602 | } |
Sapan Bhatia | 5ea307d | 2017-07-19 00:13:21 -0400 | [diff] [blame] | 603 | |
Matteo Scandolo | 7e3414c | 2017-11-15 08:10:55 -0800 | [diff] [blame] | 604 | message ServiceGraphConstraint (XOSBase) { |
| 605 | option verbose_name="Graph Constraint"; |
| 606 | option description="Define the position of the nodes in the service graph"; |
| 607 | required string constraints = 1 [max_length = 1024, content_type = "stripped", blank = True, help_text = "A composite array defining positions, eg [volt, vsg, [address_manager, vrouter]]", null = False, tosca_key=True]; |
| 608 | } |
| 609 | |