| Jeremy Mordkoff | 6f07e6f | 2016-09-07 18:56:51 -0400 | [diff] [blame] | 1 | |
| 2 | /* |
| 3 | * |
| 4 | * Copyright 2016 RIFT.IO Inc |
| 5 | * |
| 6 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | * you may not use this file except in compliance with the License. |
| 8 | * You may obtain a copy of the License at |
| 9 | * |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
| 12 | * Unless required by applicable law or agreed to in writing, software |
| 13 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | * See the License for the specific language governing permissions and |
| 16 | * limitations under the License. |
| 17 | * |
| 18 | */ |
| 19 | |
| 20 | |
| 21 | /** |
| 22 | * @file rwvx.h |
| 23 | * @author Justin Bronder (justin.bronder@riftio.com) |
| 24 | * @date 09/29/2014 |
| 25 | * @brief Top level API include for rwcal submodule |
| 26 | */ |
| 27 | |
| 28 | #ifndef __RWCAL_API_H__ |
| 29 | #define __RWCAL_API_H__ |
| 30 | |
| 31 | #include <stdbool.h> |
| 32 | |
| 33 | #include <libpeas/peas.h> |
| 34 | |
| 35 | #include <rwcal.h> |
| 36 | #include <rwlib.h> |
| 37 | #include <rw-manifest.pb-c.h> |
| 38 | #include <rw_vx_plugin.h> |
| 39 | |
| 40 | #include "rwlog.h" |
| 41 | |
| 42 | __BEGIN_DECLS |
| 43 | |
| 44 | struct rwcal_module_s { |
| 45 | rw_vx_framework_t * framework; |
| 46 | rw_vx_modinst_common_t *mip; |
| 47 | |
| 48 | PeasExtension * cloud; |
| 49 | RwCalCloud * cloud_cls; |
| 50 | RwCalCloudIface * cloud_iface; |
| 51 | |
| 52 | rwlog_ctx_t *rwlog_instance; |
| 53 | }; |
| 54 | typedef struct rwcal_module_s * rwcal_module_ptr_t; |
| 55 | |
| 56 | // Redefine yang autonames |
| 57 | typedef RWPB_E(RwManifest_RwcalCloudType) rwcal_cloud_type; |
| 58 | |
| 59 | /* |
| 60 | * Allocate a rwcal module. Once allocated, the clients within |
| 61 | * the module still need to be initialized. For rwzk, see |
| 62 | * rwcal_rwzk_{kazoo,zake}_init(). For rwcloud, see |
| 63 | * rwcal_cloud_init(). It is a fatal error to attempt to use any |
| 64 | * client before it has been initialized. However, it is |
| 65 | * perfectly fine to not initialize a client that will remain |
| 66 | * unused. Note that every function contains the client that it |
| 67 | * will use as part of the name, just after the rwcal_ prefix. |
| 68 | * |
| 69 | * @return - rwcal module handle or NULL on failure. |
| 70 | */ |
| 71 | rwcal_module_ptr_t rwcal_module_alloc(); |
| 72 | |
| 73 | /* |
| 74 | * Deallocate a rwcal module. |
| 75 | * |
| 76 | * @param - pointer to the rwcal module to be deallocated. |
| 77 | */ |
| 78 | void rwcal_module_free(rwcal_module_ptr_t * rwcal); |
| 79 | |
| 80 | |
| 81 | /* |
| 82 | * Initialize the rwcal cloud controller. |
| 83 | * |
| 84 | * key/secret for various cloud types: |
| 85 | * EC2: ACCESS_ID/SECRET_KEY |
| 86 | * |
| 87 | * @param rwcal - module handle. |
| 88 | * @return - RW_STATUS_SUCCESS, |
| 89 | * RW_STATUS_NOTFOUND if the type is unknown, |
| 90 | * RW_STATUS_FAILURE otherwise. |
| 91 | */ |
| 92 | rw_status_t rwcal_cloud_init(rwcal_module_ptr_t rwcal); |
| 93 | |
| 94 | /* |
| 95 | * Get a list of the names of the available images that can be |
| 96 | * used to start a new VM. |
| 97 | * |
| 98 | * @param rwcal - module handle. |
| 99 | * @param account - cloud account information. |
| 100 | * @param image_names - on success, contains a NULL-terminated |
| 101 | * list of image names. |
| 102 | * @return - rw_status_t |
| 103 | */ |
| 104 | rw_status_t rwcal_get_image_list( |
| 105 | rwcal_module_ptr_t rwcal, |
| 106 | rwpb_gi_Rwcal_CloudAccount *account, |
| 107 | rwpb_gi_Rwcal_VimResources **images); |
| 108 | |
| 109 | /* |
| 110 | * Delete Image. |
| 111 | * |
| 112 | * @param rwcal - module handle. |
| 113 | * @param account - cloud account information. |
| 114 | * @param image_id - id of image to be deleted |
| 115 | * @return - rw_status_t |
| 116 | */ |
| 117 | rw_status_t rwcal_delete_image( |
| 118 | rwcal_module_ptr_t rwcal, |
| 119 | rwpb_gi_Rwcal_CloudAccount *account, |
| 120 | const char * image_id); |
| 121 | |
| 122 | /* |
| 123 | * Create a flavor. |
| 124 | * |
| 125 | * @param rwcal - module handle. |
| 126 | * @param account - cloud account information. |
| 127 | * @param flavor - rwpb_gi_Rwcal_FlavorInfoItem object describing the |
| 128 | * flavor to be created |
| 129 | * @param flavor_id - on success, contains a NULL-terminated string containing the new flavor_id |
| 130 | * @return - rw_status_t |
| 131 | */ |
| 132 | rw_status_t rwcal_create_flavor( |
| 133 | rwcal_module_ptr_t rwcal, |
| 134 | rwpb_gi_Rwcal_CloudAccount *account, |
| 135 | rwpb_gi_Rwcal_FlavorInfoItem *flavor, |
| 136 | char *flavor_id); |
| 137 | |
| 138 | |
| 139 | /* |
| 140 | * Delete flavor. |
| 141 | * |
| 142 | * @param rwcal - module handle. |
| 143 | * @param account - cloud account information. |
| 144 | * @param flavor_id - id of flavor to be deleted |
| 145 | * @return - rw_status_t |
| 146 | */ |
| 147 | rw_status_t rwcal_delete_flavor( |
| 148 | rwcal_module_ptr_t rwcal, |
| 149 | rwpb_gi_Rwcal_CloudAccount *account, |
| 150 | const char * flavor_id); |
| 151 | |
| 152 | /* |
| 153 | * Get a specific flavor |
| 154 | * |
| 155 | * @param rwcal - module handle. |
| 156 | * @param account - cloud account information. |
| 157 | * @param flavor_id - id of the flavor to return |
| 158 | * @param flavir - rwpb_gi_Rwcal_FlavorInfoItem object containing the |
| 159 | * details of the requested flavor |
| 160 | * |
| 161 | * @return - rw_status_t |
| 162 | */ |
| 163 | rw_status_t rwcal_get_flavor( |
| 164 | rwcal_module_ptr_t rwcal, |
| 165 | rwpb_gi_Rwcal_CloudAccount *account, |
| 166 | const char * flavor_id, |
| 167 | rwpb_gi_Rwcal_FlavorInfoItem **flavor); |
| 168 | |
| 169 | /* |
| 170 | * Get a list of the details for all flavors |
| 171 | * |
| 172 | * @param rwcal - module handle. |
| 173 | * @param account - cloud account information. |
| 174 | * @param flavors - on success, contains a list of flavor info objects |
| 175 | * |
| 176 | * @return - rw_status_t |
| 177 | */ |
| 178 | rw_status_t rwcal_get_flavor_list( |
| 179 | rwcal_module_ptr_t rwcal, |
| 180 | rwpb_gi_Rwcal_CloudAccount *account, |
| 181 | rwpb_gi_Rwcal_VimResources **flavors); |
| 182 | |
| 183 | /* |
| 184 | * Create a virtual machine. |
| 185 | * |
| 186 | * @param rwcal - module handle. |
| 187 | * @param account - cloud account information. |
| 188 | * @param vm - the information that defines what kind of VM will be |
| 189 | * created |
| 190 | * @param vm_id - on success, contains a NULL-terminated string |
| 191 | * containing the new vm id |
| 192 | * |
| 193 | * @return - rw_status_t |
| 194 | */ |
| 195 | rw_status_t rwcal_create_vm( |
| 196 | rwcal_module_ptr_t rwcal, |
| 197 | rwpb_gi_Rwcal_CloudAccount *account, |
| 198 | rwpb_gi_Rwcal_VMInfoItem *vm, |
| 199 | char **vm_id); |
| 200 | |
| 201 | /* |
| 202 | * Delete VM. |
| 203 | * |
| 204 | * @param rwcal - module handle. |
| 205 | * @param account - cloud account information. |
| 206 | * @param vm_id - id of vm to be deleted |
| 207 | * @return - rw_status_t |
| 208 | */ |
| 209 | rw_status_t rwcal_delete_vm( |
| 210 | rwcal_module_ptr_t rwcal, |
| 211 | rwpb_gi_Rwcal_CloudAccount *account, |
| 212 | const char * vm_id); |
| 213 | |
| 214 | /* |
| 215 | * Reboot VM. |
| 216 | * |
| 217 | * @param rwcal - module handle. |
| 218 | * @param account - cloud account information. |
| 219 | * @param vm_id - id of vm to be deleted |
| 220 | * @return - rw_status_t |
| 221 | */ |
| 222 | rw_status_t rwcal_reboot_vm( |
| 223 | rwcal_module_ptr_t rwcal, |
| 224 | rwpb_gi_Rwcal_CloudAccount *account, |
| 225 | const char * vm_id); |
| 226 | |
| 227 | /* |
| 228 | * Start VM. |
| 229 | * |
| 230 | * @param rwcal - module handle. |
| 231 | * @param account - cloud account information. |
| 232 | * @param vm_id - id of a vm to start |
| 233 | * @return - rw_status_t |
| 234 | */ |
| 235 | rw_status_t rwcal_start_vm( |
| 236 | rwcal_module_ptr_t rwcal, |
| 237 | rwpb_gi_Rwcal_CloudAccount *account, |
| 238 | const char * vm_id); |
| 239 | |
| 240 | /* |
| 241 | * Stop VM. |
| 242 | * |
| 243 | * @param rwcal - module handle. |
| 244 | * @param account - cloud account information. |
| 245 | * @param vm_id - id of a vm to stop |
| 246 | * @return - rw_status_t |
| 247 | */ |
| 248 | rw_status_t rwcal_stop_vm( |
| 249 | rwcal_module_ptr_t rwcal, |
| 250 | rwpb_gi_Rwcal_CloudAccount *account, |
| 251 | const char * vm_id); |
| 252 | |
| 253 | /* |
| 254 | * Get a list of the names of the available vms |
| 255 | * |
| 256 | * @param rwcal - module handle. |
| 257 | * @param account - cloud account information. |
| 258 | * @param vms - on success, contains a NULL-terminated |
| 259 | * list of vms. |
| 260 | * @return - rw_status_t |
| 261 | */ |
| 262 | rw_status_t rwcal_get_vm_list( |
| 263 | rwcal_module_ptr_t rwcal, |
| 264 | rwpb_gi_Rwcal_CloudAccount *account, |
| 265 | rwpb_gi_Rwcal_VimResources** vms); |
| 266 | |
| 267 | /* |
| 268 | * Create a tenant. |
| 269 | * |
| 270 | * @param rwcal - module handle. |
| 271 | * @param account - cloud account information. |
| 272 | * @param tenant_name - name to assign to the tenant. |
| 273 | * @param tenant_info - on success, contains a NULL-terminated list of tenant_info |
| 274 | * @return - rw_status_t |
| 275 | */ |
| 276 | rw_status_t rwcal_create_tenant( |
| 277 | rwcal_module_ptr_t rwcal, |
| 278 | rwpb_gi_Rwcal_CloudAccount *account, |
| 279 | const char * tenant_name, |
| 280 | char *** tenant_info); |
| 281 | |
| 282 | /* |
| 283 | * Delete tenant. |
| 284 | * |
| 285 | * @param rwcal - module handle. |
| 286 | * @param account - cloud account information. |
| 287 | * @param tenant_id - id of tenant to be deleted |
| 288 | * @return - rw_status_t |
| 289 | */ |
| 290 | rw_status_t rwcal_delete_tenant( |
| 291 | rwcal_module_ptr_t rwcal, |
| 292 | rwpb_gi_Rwcal_CloudAccount *account, |
| 293 | const char * tenant_id); |
| 294 | |
| 295 | /* |
| 296 | * Get a list of the available tenants |
| 297 | * |
| 298 | * @param rwcal - module handle. |
| 299 | * @param account - cloud account information. |
| 300 | * @param tenants - on success, contains a NULL-terminated |
| 301 | * list of tenants. |
| 302 | * @return - rw_status_t |
| 303 | */ |
| 304 | rw_status_t rwcal_get_tenant_list( |
| 305 | rwcal_module_ptr_t rwcal, |
| 306 | rwpb_gi_Rwcal_CloudAccount *account, |
| 307 | rwpb_gi_Rwcal_VimResources **tenants); |
| 308 | |
| 309 | /* |
| 310 | * Create a role. |
| 311 | * |
| 312 | * @param rwcal - module handle. |
| 313 | * @param account - cloud account information. |
| 314 | * @param role_name - name to assign to the role. |
| 315 | * @param role_info - on success, contains a NULL-terminated list of role_info |
| 316 | * @return - rw_status_t |
| 317 | */ |
| 318 | rw_status_t rwcal_create_role( |
| 319 | rwcal_module_ptr_t rwcal, |
| 320 | rwpb_gi_Rwcal_CloudAccount *account, |
| 321 | const char * role_name, |
| 322 | char *** role_info); |
| 323 | |
| 324 | /* |
| 325 | * Delete role. |
| 326 | * |
| 327 | * @param rwcal - module handle. |
| 328 | * @param account - cloud account information. |
| 329 | * @param role_id - id of role to be deleted |
| 330 | * @return - rw_status_t |
| 331 | */ |
| 332 | rw_status_t rwcal_delete_role( |
| 333 | rwcal_module_ptr_t rwcal, |
| 334 | rwpb_gi_Rwcal_CloudAccount *account, |
| 335 | const char * role_id); |
| 336 | |
| 337 | /* |
| 338 | * Get a list of the available roles |
| 339 | * |
| 340 | * @param rwcal - module handle. |
| 341 | * @param account - cloud account information. |
| 342 | * @param roles - on success, contains a NULL-terminated |
| 343 | * list of roles. |
| 344 | * @return - rw_status_t |
| 345 | */ |
| 346 | rw_status_t rwcal_get_role_list( |
| 347 | rwcal_module_ptr_t rwcal, |
| 348 | rwpb_gi_Rwcal_CloudAccount *account, |
| 349 | rwpb_gi_Rwcal_VimResources **roles); |
| 350 | |
| 351 | /* |
| 352 | * Add a new host |
| 353 | * |
| 354 | * @param rwcal - module handle. |
| 355 | * @param account - cloud account information. |
| 356 | * @param host - host info |
| 357 | * @param host_id - on success, contains a NULL-terminated string |
| 358 | * containing the new host_id |
| 359 | * |
| 360 | * @return - rw_status_t |
| 361 | */ |
| 362 | rw_status_t rwcal_add_host( |
| 363 | rwcal_module_ptr_t rwcal, |
| 364 | rwpb_gi_Rwcal_CloudAccount *account, |
| 365 | rwpb_gi_Rwcal_HostInfoItem *host, |
| 366 | char **host_id); |
| 367 | |
| 368 | /* |
| 369 | * Remove a new host |
| 370 | * |
| 371 | * @param rwcal - module handle. |
| 372 | * @param account - cloud account information. |
| 373 | * @param host_id - the id of the host to remove |
| 374 | * |
| 375 | * @return - rw_status_t |
| 376 | */ |
| 377 | rw_status_t rwcal_remove_host( |
| 378 | rwcal_module_ptr_t rwcal, |
| 379 | rwpb_gi_Rwcal_CloudAccount *account, |
| 380 | const char *host_id); |
| 381 | |
| 382 | /* |
| 383 | * Get a specific host |
| 384 | * |
| 385 | * @param rwcal - module handle. |
| 386 | * @param account - cloud account information. |
| 387 | * @param host_id - the id of the host to return |
| 388 | * @param host - the requested host info |
| 389 | * |
| 390 | * @return - rw_status_t |
| 391 | */ |
| 392 | rw_status_t rwcal_get_host( |
| 393 | rwcal_module_ptr_t rwcal, |
| 394 | rwpb_gi_Rwcal_CloudAccount *account, |
| 395 | const char *host_id, |
| 396 | rwpb_gi_Rwcal_HostInfoItem **host); |
| 397 | |
| 398 | /* |
| 399 | * Get a list of hosts |
| 400 | * |
| 401 | * @param rwcal - module handle. |
| 402 | * @param account - cloud account information. |
| 403 | * @param hosts - on success, contains a NULL-terminated list of hosts. |
| 404 | * |
| 405 | * @return - rw_status_t |
| 406 | */ |
| 407 | rw_status_t rwcal_get_host_list( |
| 408 | rwcal_module_ptr_t rwcal, |
| 409 | rwpb_gi_Rwcal_CloudAccount *account, |
| 410 | rwpb_gi_Rwcal_VimResources **hosts); |
| 411 | |
| 412 | /* |
| 413 | * Create a new port |
| 414 | * |
| 415 | * @param rwcal - module handle. |
| 416 | * @param account - cloud account information. |
| 417 | * @param port - port info |
| 418 | * @param port_id - on success, contains a NULL-terminated string |
| 419 | * containing the new port id |
| 420 | * |
| 421 | * @return - rw_status_t |
| 422 | */ |
| 423 | rw_status_t rwcal_create_port( |
| 424 | rwcal_module_ptr_t rwcal, |
| 425 | rwpb_gi_Rwcal_CloudAccount *account, |
| 426 | rwpb_gi_Rwcal_PortInfoItem *port, |
| 427 | char **port_id); |
| 428 | |
| 429 | /* |
| 430 | * Delete a port |
| 431 | * |
| 432 | * @param rwcal - module handle. |
| 433 | * @param account - cloud account information. |
| 434 | * @param port_id - the id of the port to remove |
| 435 | * |
| 436 | * @return - rw_status_t |
| 437 | */ |
| 438 | rw_status_t rwcal_delete_port( |
| 439 | rwcal_module_ptr_t rwcal, |
| 440 | rwpb_gi_Rwcal_CloudAccount *account, |
| 441 | const char *port_id); |
| 442 | |
| 443 | /* |
| 444 | * Get a specific port |
| 445 | * |
| 446 | * @param rwcal - module handle. |
| 447 | * @param account - cloud account information. |
| 448 | * @param port_id - the id of the port to return |
| 449 | * @param port - the requested port info |
| 450 | * |
| 451 | * @return - rw_status_t |
| 452 | */ |
| 453 | rw_status_t rwcal_get_port( |
| 454 | rwcal_module_ptr_t rwcal, |
| 455 | rwpb_gi_Rwcal_CloudAccount *account, |
| 456 | const char *port_id, |
| 457 | rwpb_gi_Rwcal_PortInfoItem **port); |
| 458 | |
| 459 | /* |
| 460 | * Get a list of ports |
| 461 | * |
| 462 | * @param rwcal - module handle. |
| 463 | * @param account - cloud account information. |
| 464 | * @param ports - on success, contains a NULL-terminated list of ports. |
| 465 | * |
| 466 | * @return - rw_status_t |
| 467 | */ |
| 468 | rw_status_t rwcal_get_port_list( |
| 469 | rwcal_module_ptr_t rwcal, |
| 470 | rwpb_gi_Rwcal_CloudAccount *account, |
| 471 | rwpb_gi_Rwcal_VimResources **ports); |
| 472 | |
| 473 | /* |
| 474 | * Create a new network |
| 475 | * |
| 476 | * @param rwcal - module handle. |
| 477 | * @param account - cloud account information. |
| 478 | * @param network - network info |
| 479 | * @param network_id - on success, contains a NULL-terminated string |
| 480 | * containing the new network id |
| 481 | * |
| 482 | * @return - rw_status_t |
| 483 | */ |
| 484 | rw_status_t rwcal_create_network( |
| 485 | rwcal_module_ptr_t rwcal, |
| 486 | rwpb_gi_Rwcal_CloudAccount *account, |
| 487 | rwpb_gi_Rwcal_NetworkInfoItem *network, |
| 488 | char **network_id); |
| 489 | |
| 490 | /* |
| 491 | * Delete a network |
| 492 | * |
| 493 | * @param rwcal - module handle. |
| 494 | * @param account - cloud account information. |
| 495 | * @param network_id - the id of the network to remove |
| 496 | * |
| 497 | * @return - rw_status_t |
| 498 | */ |
| 499 | rw_status_t rwcal_delete_network( |
| 500 | rwcal_module_ptr_t rwcal, |
| 501 | rwpb_gi_Rwcal_CloudAccount *account, |
| 502 | const char *network_id); |
| 503 | |
| 504 | /* |
| 505 | * Get a specific network |
| 506 | * |
| 507 | * @param rwcal - module handle. |
| 508 | * @param account - cloud account information. |
| 509 | * @param network_id - the id of the network to return |
| 510 | * @param network - the requested network info |
| 511 | * |
| 512 | * @return - rw_status_t |
| 513 | */ |
| 514 | rw_status_t rwcal_get_network( |
| 515 | rwcal_module_ptr_t rwcal, |
| 516 | rwpb_gi_Rwcal_CloudAccount *account, |
| 517 | const char *network_id, |
| 518 | rwpb_gi_Rwcal_NetworkInfoItem **network); |
| 519 | |
| 520 | /* |
| 521 | * Get a the management network |
| 522 | * |
| 523 | * @param rwcal - module handle. |
| 524 | * @param account - cloud account information. |
| 525 | * @param network - the management network info |
| 526 | * |
| 527 | * @return - rw_status_t |
| 528 | */ |
| 529 | rw_status_t rwcal_get_management_network( |
| 530 | rwcal_module_ptr_t rwcal, |
| 531 | rwpb_gi_Rwcal_CloudAccount *account, |
| 532 | rwpb_gi_Rwcal_NetworkInfoItem **network); |
| 533 | |
| 534 | /* |
| 535 | * Get a list of networks |
| 536 | * |
| 537 | * @param rwcal - module handle. |
| 538 | * @param account - cloud account information. |
| 539 | * @param networks - on success, contains a NULL-terminated list of networks. |
| 540 | * |
| 541 | * @return - rw_status_t |
| 542 | */ |
| 543 | rw_status_t rwcal_get_network_list( |
| 544 | rwcal_module_ptr_t rwcal, |
| 545 | rwpb_gi_Rwcal_CloudAccount *account, |
| 546 | rwpb_gi_Rwcal_VimResources **networks); |
| 547 | |
| 548 | /* |
| 549 | * Get a RwLog Context so that log messages can go to rwlog |
| 550 | * |
| 551 | * @param rwcal - module handle. |
| 552 | * |
| 553 | * @return - rwlog_ctx_t |
| 554 | */ |
| 555 | rwlog_ctx_t *rwcal_get_rwlog_ctx(rwcal_module_ptr_t rwcal); |
| 556 | |
| 557 | __END_DECLS |
| 558 | |
| 559 | #endif |
| 560 | |
| 561 | |