| 1 | /** |
| 2 | * Licensed to jclouds, Inc. (jclouds) under one or more |
| 3 | * contributor license agreements. See the NOTICE file |
| 4 | * distributed with this work for additional information |
| 5 | * regarding copyright ownership. jclouds licenses this file |
| 6 | * to you under the Apache License, Version 2.0 (the |
| 7 | * "License"); you may not use this file except in compliance |
| 8 | * with the License. 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, |
| 13 | * software distributed under the License is distributed on an |
| 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | * KIND, either express or implied. See the License for the |
| 16 | * specific language governing permissions and limitations |
| 17 | * under the License. |
| 18 | */ |
| 19 | package org.jclouds.cim; |
| 20 | |
| 21 | import static com.google.common.base.Preconditions.checkNotNull; |
| 22 | |
| 23 | import java.util.List; |
| 24 | import java.util.Map; |
| 25 | |
| 26 | import com.google.common.base.Function; |
| 27 | import com.google.common.collect.ImmutableList; |
| 28 | import com.google.common.collect.ImmutableSet; |
| 29 | import com.google.common.collect.Lists; |
| 30 | import com.google.common.collect.Maps; |
| 31 | |
| 32 | /** |
| 33 | * |
| 34 | * The ResourceAllocationSettingData class represents settings specifically |
| 35 | * related to an allocated resource that are outside the scope of the CIM class |
| 36 | * typically used to represent the resource itself. These settings include |
| 37 | * information specific to the allocation that may not be visible to the |
| 38 | * consumer of the resource itself. For example, a virtual processor may look |
| 39 | * like a 2 ghz processor to the consumer (virtual computer system), however the |
| 40 | * virtualization system may use time-slicing to schedule the the virtual |
| 41 | * processor to only allow it to use 1 ghz. |
| 42 | * |
| 43 | * @author Adrian Cole |
| 44 | * @see <a href= |
| 45 | * "http://dmtf.org/sites/default/files/cim/cim_schema_v2280/cim_schema_2.28.0Final-Doc.zip" |
| 46 | * /> |
| 47 | * |
| 48 | */ |
| 49 | public class ResourceAllocationSettingData extends ManagedElement { |
| 50 | |
| 51 | public static Builder builder() { |
| 52 | return new Builder(); |
| 53 | } |
| 54 | |
| 55 | /** |
| 56 | * {@inheritDoc} |
| 57 | */ |
| 58 | @Override |
| 59 | public Builder toBuilder() { |
| 60 | return builder().fromResourceAllocationSettingData(this); |
| 61 | } |
| 62 | |
| 63 | public static class Builder extends ManagedElement.Builder { |
| 64 | |
| 65 | protected String address; |
| 66 | protected String addressOnParent; |
| 67 | protected String allocationUnits; |
| 68 | protected Boolean automaticAllocation; |
| 69 | protected Boolean automaticDeallocation; |
| 70 | protected ConsumerVisibility consumerVisibility; |
| 71 | protected Long limit; |
| 72 | protected MappingBehavior mappingBehavior; |
| 73 | protected String otherResourceType; |
| 74 | protected String parent; |
| 75 | protected String poolID; |
| 76 | protected Long reservation; |
| 77 | protected String resourceSubType; |
| 78 | protected ResourceType resourceType; |
| 79 | protected Long virtualQuantity; |
| 80 | protected String virtualQuantityUnits; |
| 81 | protected Integer weight; |
| 82 | protected List<String> connections = Lists.newArrayList(); |
| 83 | protected List<String> hostResources = Lists.newArrayList(); |
| 84 | |
| 85 | /** |
| 86 | * @see ResourceAllocationSettingData#getAddress |
| 87 | */ |
| 88 | public Builder address(String address) { |
| 89 | this.address = address; |
| 90 | return this; |
| 91 | } |
| 92 | |
| 93 | /** |
| 94 | * @see ResourceAllocationSettingData#getAddressOnParent |
| 95 | */ |
| 96 | public Builder addressOnParent(String addressOnParent) { |
| 97 | this.addressOnParent = addressOnParent; |
| 98 | return this; |
| 99 | } |
| 100 | |
| 101 | /** |
| 102 | * @see ResourceAllocationSettingData#getAllocationUnits |
| 103 | */ |
| 104 | public Builder allocationUnits(String allocationUnits) { |
| 105 | this.allocationUnits = allocationUnits; |
| 106 | return this; |
| 107 | } |
| 108 | |
| 109 | /** |
| 110 | * @see ResourceAllocationSettingData#getAutomaticAllocation |
| 111 | */ |
| 112 | public Builder automaticAllocation(Boolean automaticAllocation) { |
| 113 | this.automaticAllocation = automaticAllocation; |
| 114 | return this; |
| 115 | } |
| 116 | |
| 117 | /** |
| 118 | * @see ResourceAllocationSettingData#getAutomaticDeallocation |
| 119 | */ |
| 120 | public Builder automaticDeallocation(Boolean automaticDeallocation) { |
| 121 | this.automaticDeallocation = automaticDeallocation; |
| 122 | return this; |
| 123 | } |
| 124 | |
| 125 | /** |
| 126 | * @see ResourceAllocationSettingData#getConsumerVisibility |
| 127 | */ |
| 128 | public Builder consumerVisibility(ConsumerVisibility consumerVisibility) { |
| 129 | this.consumerVisibility = consumerVisibility; |
| 130 | return this; |
| 131 | } |
| 132 | |
| 133 | /** |
| 134 | * @see ResourceAllocationSettingData#getLimit |
| 135 | */ |
| 136 | public Builder limit(Long limit) { |
| 137 | this.limit = limit; |
| 138 | return this; |
| 139 | } |
| 140 | |
| 141 | /** |
| 142 | * @see ResourceAllocationSettingData#getMappingBehavior |
| 143 | */ |
| 144 | public Builder mappingBehavior(MappingBehavior mappingBehavior) { |
| 145 | this.mappingBehavior = mappingBehavior; |
| 146 | return this; |
| 147 | } |
| 148 | |
| 149 | /** |
| 150 | * @see ResourceAllocationSettingData#getOtherResourceType |
| 151 | */ |
| 152 | public Builder otherResourceType(String otherResourceType) { |
| 153 | this.otherResourceType = otherResourceType; |
| 154 | return this; |
| 155 | } |
| 156 | |
| 157 | /** |
| 158 | * @see ResourceAllocationSettingData#getParent |
| 159 | */ |
| 160 | public Builder parent(String parent) { |
| 161 | this.parent = parent; |
| 162 | return this; |
| 163 | } |
| 164 | |
| 165 | /** |
| 166 | * @see ResourceAllocationSettingData#getPoolID |
| 167 | */ |
| 168 | public Builder poolID(String poolID) { |
| 169 | this.poolID = poolID; |
| 170 | return this; |
| 171 | } |
| 172 | |
| 173 | /** |
| 174 | * @see ResourceAllocationSettingData#getReservation |
| 175 | */ |
| 176 | public Builder reservation(Long reservation) { |
| 177 | this.reservation = reservation; |
| 178 | return this; |
| 179 | } |
| 180 | |
| 181 | /** |
| 182 | * @see ResourceAllocationSettingData#getResourceSubType |
| 183 | */ |
| 184 | public Builder resourceSubType(String resourceSubType) { |
| 185 | this.resourceSubType = resourceSubType; |
| 186 | return this; |
| 187 | } |
| 188 | |
| 189 | /** |
| 190 | * @see ResourceAllocationSettingData#getResourceType |
| 191 | */ |
| 192 | public Builder resourceType(ResourceType resourceType) { |
| 193 | this.resourceType = resourceType; |
| 194 | return this; |
| 195 | } |
| 196 | |
| 197 | /** |
| 198 | * @see ResourceAllocationSettingData#getVirtualQuantity |
| 199 | */ |
| 200 | public Builder virtualQuantity(Long virtualQuantity) { |
| 201 | this.virtualQuantity = virtualQuantity; |
| 202 | return this; |
| 203 | } |
| 204 | |
| 205 | /** |
| 206 | * @see ResourceAllocationSettingData#getVirtualQuantityUnits |
| 207 | */ |
| 208 | public Builder virtualQuantityUnits(String virtualQuantityUnits) { |
| 209 | this.virtualQuantityUnits = virtualQuantityUnits; |
| 210 | return this; |
| 211 | } |
| 212 | |
| 213 | /** |
| 214 | * @see ResourceAllocationSettingData#getWeight |
| 215 | */ |
| 216 | public Builder weight(Integer weight) { |
| 217 | this.weight = weight; |
| 218 | return this; |
| 219 | } |
| 220 | |
| 221 | /** |
| 222 | * @see ResourceAllocationSettingData#getConnection |
| 223 | */ |
| 224 | public Builder connection(String connection) { |
| 225 | this.connections.add(checkNotNull(connection, "connection")); |
| 226 | return this; |
| 227 | } |
| 228 | |
| 229 | /** |
| 230 | * @see ResourceAllocationSettingData#getHostResource |
| 231 | */ |
| 232 | public Builder hostResource(String hostResource) { |
| 233 | this.hostResources.add(checkNotNull(hostResource, "hostResource")); |
| 234 | return this; |
| 235 | } |
| 236 | |
| 237 | /** |
| 238 | * @see ResourceAllocationSettingData#getConnections |
| 239 | */ |
| 240 | public Builder connections(List<String> connections) { |
| 241 | this.connections.addAll(checkNotNull(connections, "connections")); |
| 242 | return this; |
| 243 | } |
| 244 | |
| 245 | /** |
| 246 | * @see ResourceAllocationSettingData#getHostResources |
| 247 | */ |
| 248 | public Builder hostResources(List<String> hostResources) { |
| 249 | this.hostResources.addAll(checkNotNull(hostResources, "hostResources")); |
| 250 | return this; |
| 251 | } |
| 252 | |
| 253 | public ResourceAllocationSettingData build() { |
| 254 | return new ResourceAllocationSettingData(elementName, instanceID, caption, description, address, |
| 255 | addressOnParent, allocationUnits, automaticAllocation, automaticDeallocation, consumerVisibility, limit, |
| 256 | mappingBehavior, otherResourceType, parent, poolID, reservation, resourceSubType, resourceType, |
| 257 | virtualQuantity, virtualQuantityUnits, weight, connections, hostResources); |
| 258 | } |
| 259 | |
| 260 | public Builder fromResourceAllocationSettingData(ResourceAllocationSettingData in) { |
| 261 | return fromManagedElement(in).address(in.getAddress()).addressOnParent(in.getAddressOnParent()) |
| 262 | .allocationUnits(in.getAllocationUnits()).automaticAllocation(in.isAutomaticAllocation()) |
| 263 | .automaticDeallocation(in.isAutomaticDeallocation()).consumerVisibility(in.getConsumerVisibility()) |
| 264 | .limit(in.getLimit()).mappingBehavior(in.getMappingBehavior()) |
| 265 | .otherResourceType(in.getOtherResourceType()).parent(in.getParent()).poolID(in.getPoolID()) |
| 266 | .reservation(in.getReservation()).resourceSubType(in.getResourceSubType()) |
| 267 | .resourceType(in.getResourceType()).virtualQuantity(in.getVirtualQuantity()) |
| 268 | .virtualQuantityUnits(in.getVirtualQuantityUnits()).weight(in.getWeight()) |
| 269 | .connections(in.getConnections()).hostResources(in.getHostResources()); |
| 270 | } |
| 271 | |
| 272 | /** |
| 273 | * {@inheritDoc} |
| 274 | */ |
| 275 | @Override |
| 276 | public Builder fromManagedElement(ManagedElement in) { |
| 277 | return Builder.class.cast(super.fromManagedElement(in)); |
| 278 | } |
| 279 | |
| 280 | /** |
| 281 | * {@inheritDoc} |
| 282 | */ |
| 283 | @Override |
| 284 | public Builder caption(String caption) { |
| 285 | return Builder.class.cast(super.caption(caption)); |
| 286 | } |
| 287 | |
| 288 | /** |
| 289 | * {@inheritDoc} |
| 290 | */ |
| 291 | @Override |
| 292 | public Builder description(String description) { |
| 293 | return Builder.class.cast(super.description(description)); |
| 294 | } |
| 295 | |
| 296 | /** |
| 297 | * {@inheritDoc} |
| 298 | */ |
| 299 | @Override |
| 300 | public Builder elementName(String elementName) { |
| 301 | return Builder.class.cast(super.elementName(elementName)); |
| 302 | } |
| 303 | |
| 304 | /** |
| 305 | * {@inheritDoc} |
| 306 | */ |
| 307 | @Override |
| 308 | public Builder instanceID(String instanceID) { |
| 309 | return Builder.class.cast(super.instanceID(instanceID)); |
| 310 | } |
| 311 | |
| 312 | } |
| 313 | |
| 314 | /** |
| 315 | * The type of resource this allocation setting represents. |
| 316 | */ |
| 317 | public static enum ResourceType { |
| 318 | |
| 319 | OTHER(1), COMPUTER_SYSTEM(2), PROCESSOR(3), MEMORY(4), IDE_CONTROLLER(5), PARALLEL_SCSI_HBA(6), FC_HBA(7), ISCSI_HBA( |
| 320 | 8), IB_HCA(9), ETHERNET_ADAPTER(10), OTHER_NETWORK_ADAPTER(11), IO_SLOT(12), IO_DEVICE(13), FLOPPY_DRIVE(14), CD_DRIVE( |
| 321 | 15), DVD_DRIVE(16), DISK_DRIVE(17), TAPE_DRIVE(18), STORAGE_EXTENT(19), OTHER_STORAGE_DEVICE(20), SERIAL_PORT( |
| 322 | 21), PARALLEL_PORT(22), USB_CONTROLLER(23), GRAPHICS_CONTROLLER(24), IEEE_1394_CONTROLLER(25), PARTITIONABLE_UNIT( |
| 323 | 26), BASE_PARTITIONABLE_UNIT(27), POWER(28), COOLING_CAPACITY(29), ETHERNET_SWITCH_PORT(30), LOGICAL_DISK( |
| 324 | 31), STORAGE_VOLUME(32), ETHERNET_CONNECTION(33), DMTF_RESERVED(Integer.valueOf("8000", 16)), VENDOR_RESERVED( |
| 325 | Integer.valueOf("FFFF", 16)); |
| 326 | |
| 327 | protected final int code; |
| 328 | |
| 329 | ResourceType(int code) { |
| 330 | this.code = code; |
| 331 | } |
| 332 | |
| 333 | public String value() { |
| 334 | return code + ""; |
| 335 | } |
| 336 | |
| 337 | protected final static Map<Integer, ResourceType> RESOURCE_TYPE_BY_ID = Maps.uniqueIndex( |
| 338 | ImmutableSet.copyOf(ResourceType.values()), new Function<ResourceType, Integer>() { |
| 339 | |
| 340 | @Override |
| 341 | public Integer apply(ResourceType input) { |
| 342 | return input.code; |
| 343 | } |
| 344 | |
| 345 | }); |
| 346 | |
| 347 | public static ResourceType fromValue(String type) { |
| 348 | return RESOURCE_TYPE_BY_ID.get(new Integer(checkNotNull(type, "type"))); |
| 349 | } |
| 350 | } |
| 351 | |
| 352 | /** |
| 353 | * Describes the consumers visibility to the allocated resource. |
| 354 | */ |
| 355 | public static enum ConsumerVisibility { |
| 356 | UNKNOWN(0), |
| 357 | /** |
| 358 | * indicates the underlying or host resource is utilized and passed |
| 359 | * through to the consumer, possibly using partitioning. At least one item |
| 360 | * shall be present in the HostResource property. |
| 361 | */ |
| 362 | PASSED_THROUGH(2), |
| 363 | /** |
| 364 | * indicates the resource is virtualized and may not map directly to an |
| 365 | * underlying/host resource. Some implementations may support specific |
| 366 | * assignment for virtualized resources, in which case the host |
| 367 | * resource(s) are exposed using the HostResource property. |
| 368 | */ |
| 369 | VIRTUALIZED(3), |
| 370 | /** |
| 371 | * indicates a representation of the resource does not exist within the |
| 372 | * context of the resource consumer. |
| 373 | */ |
| 374 | NOT_REPRESENTED(4), DMTF_RESERVED(32767), VENDOR_RESERVED(65535); |
| 375 | |
| 376 | protected final int code; |
| 377 | |
| 378 | ConsumerVisibility(int code) { |
| 379 | this.code = code; |
| 380 | } |
| 381 | |
| 382 | public String value() { |
| 383 | return code + ""; |
| 384 | } |
| 385 | |
| 386 | protected final static Map<Integer, ConsumerVisibility> MAPPING_BEHAVIOR_BY_ID = Maps.uniqueIndex( |
| 387 | ImmutableSet.copyOf(ConsumerVisibility.values()), new Function<ConsumerVisibility, Integer>() { |
| 388 | |
| 389 | @Override |
| 390 | public Integer apply(ConsumerVisibility input) { |
| 391 | return input.code; |
| 392 | } |
| 393 | |
| 394 | }); |
| 395 | |
| 396 | public static ConsumerVisibility fromValue(String behavior) { |
| 397 | return MAPPING_BEHAVIOR_BY_ID.get(new Integer(checkNotNull(behavior, "behavior"))); |
| 398 | } |
| 399 | } |
| 400 | |
| 401 | /** |
| 402 | * Specifies how this resource maps to underlying resourcesIf the |
| 403 | * HostResource array contains any entries, this property reflects how the |
| 404 | * resource maps to those specific resources. |
| 405 | */ |
| 406 | public static enum MappingBehavior { |
| 407 | UNKNOWN(0), NOT_SUPPORTED(2), DEDICATED(3), SOFT_AFFINITY(4), HARD_AFFINITY(5), DMTF_RESERVED(32767), VENDOR_RESERVED( |
| 408 | 65535); |
| 409 | |
| 410 | protected final int code; |
| 411 | |
| 412 | MappingBehavior(int code) { |
| 413 | this.code = code; |
| 414 | } |
| 415 | |
| 416 | public String value() { |
| 417 | return code + ""; |
| 418 | } |
| 419 | |
| 420 | protected final static Map<Integer, MappingBehavior> MAPPING_BEHAVIOR_BY_ID = Maps.uniqueIndex( |
| 421 | ImmutableSet.copyOf(MappingBehavior.values()), new Function<MappingBehavior, Integer>() { |
| 422 | |
| 423 | @Override |
| 424 | public Integer apply(MappingBehavior input) { |
| 425 | return input.code; |
| 426 | } |
| 427 | |
| 428 | }); |
| 429 | |
| 430 | public static MappingBehavior fromValue(String behavior) { |
| 431 | return MAPPING_BEHAVIOR_BY_ID.get(new Integer(checkNotNull(behavior, "behavior"))); |
| 432 | } |
| 433 | } |
| 434 | |
| 435 | protected final String address; |
| 436 | protected final String addressOnParent; |
| 437 | protected final String allocationUnits; |
| 438 | protected final Boolean automaticAllocation; |
| 439 | protected final Boolean automaticDeallocation; |
| 440 | protected final ConsumerVisibility consumerVisibility; |
| 441 | protected final Long limit; |
| 442 | protected final MappingBehavior mappingBehavior; |
| 443 | protected final String otherResourceType; |
| 444 | protected final String parent; |
| 445 | protected final String poolID; |
| 446 | protected final Long reservation; |
| 447 | protected final String resourceSubType; |
| 448 | protected final ResourceType resourceType; |
| 449 | protected final Long virtualQuantity; |
| 450 | protected final String virtualQuantityUnits; |
| 451 | protected final Integer weight; |
| 452 | protected final List<String> connections; |
| 453 | protected final List<String> hostResources; |
| 454 | |
| 455 | public ResourceAllocationSettingData(String elementName, String instanceID, String caption, String description, |
| 456 | String address, String addressOnParent, String allocationUnits, Boolean automaticAllocation, |
| 457 | Boolean automaticDeallocation, ConsumerVisibility consumerVisibility, Long limit, |
| 458 | MappingBehavior mappingBehavior, String otherResourceType, String parent, String poolID, Long reservation, |
| 459 | String resourceSubType, ResourceType resourceType, Long virtualQuantity, String virtualQuantityUnits, |
| 460 | Integer weight, List<String> connections, List<String> hostResources) { |
| 461 | super(elementName, instanceID, caption, description); |
| 462 | this.address = address; |
| 463 | this.addressOnParent = addressOnParent; |
| 464 | this.allocationUnits = allocationUnits; |
| 465 | this.automaticAllocation = automaticAllocation; |
| 466 | this.automaticDeallocation = automaticDeallocation; |
| 467 | this.consumerVisibility = consumerVisibility; |
| 468 | this.limit = limit; |
| 469 | this.mappingBehavior = mappingBehavior; |
| 470 | this.otherResourceType = otherResourceType; |
| 471 | this.parent = parent; |
| 472 | this.poolID = poolID; |
| 473 | this.reservation = reservation; |
| 474 | this.resourceSubType = resourceSubType; |
| 475 | this.resourceType = resourceType; |
| 476 | this.virtualQuantity = virtualQuantity; |
| 477 | this.virtualQuantityUnits = virtualQuantityUnits; |
| 478 | this.weight = weight; |
| 479 | this.connections = ImmutableList.copyOf(connections); |
| 480 | this.hostResources = ImmutableList.copyOf(hostResources); |
| 481 | } |
| 482 | |
| 483 | /** |
| 484 | * The address of the resource. For example, the MAC address of a Ethernet |
| 485 | * port. |
| 486 | */ |
| 487 | public String getAddress() { |
| 488 | return address; |
| 489 | } |
| 490 | |
| 491 | /** |
| 492 | * Describes the address of this resource in the context of the Parent. The |
| 493 | * Parent/AddressOnParent properties are used to describe the controller |
| 494 | * relationship as well the ordering of devices on a controller.For example, |
| 495 | * if the parent is a PCI Controller, this property would specify the PCI |
| 496 | * slot of this child device. |
| 497 | */ |
| 498 | public String getAddressOnParent() { |
| 499 | return addressOnParent; |
| 500 | } |
| 501 | |
| 502 | /** |
| 503 | * This property specifies the units of allocation used by the Reservation |
| 504 | * and Limit properties. For example, when ResourceType=Processor, |
| 505 | * AllocationUnits may be set to hertz*10^6 or percent. When |
| 506 | * ResourceType=Memory, AllocationUnits may be set to bytes*10^3. It is |
| 507 | * expected that profiles constrain the units that apply in context of |
| 508 | * particular resource types. The value of this property shall be a legal |
| 509 | * value of the Programmatic Units qualifier as defined in Annex C.1 of |
| 510 | * DSP0004 V2.5 or later. |
| 511 | */ |
| 512 | public String getAllocationUnits() { |
| 513 | return allocationUnits; |
| 514 | } |
| 515 | |
| 516 | /** |
| 517 | * This property specifies if the resource will be automatically allocated. |
| 518 | * For example when set to true, when the consuming virtual computer system |
| 519 | * is powered on, this resource would be allocated. A value of false |
| 520 | * indicates the resource must be explicitly allocated. For example, the |
| 521 | * setting may represent removable media (cdrom, floppy, etc.) where at power |
| 522 | * on time, the media is not present. An explicit operation is required to |
| 523 | * allocate the resource. |
| 524 | */ |
| 525 | public Boolean isAutomaticAllocation() { |
| 526 | return automaticAllocation; |
| 527 | } |
| 528 | |
| 529 | /** |
| 530 | * This property specifies if the resource will be automatically |
| 531 | * de-allocated. For example, when set to true, when the consuming virtual |
| 532 | * computer system is powered off, this resource would be de-allocated. When |
| 533 | * set to false, the resource will remain allocated and must be explicitly |
| 534 | * de-allocated. |
| 535 | */ |
| 536 | public Boolean isAutomaticDeallocation() { |
| 537 | return automaticDeallocation; |
| 538 | } |
| 539 | |
| 540 | /** |
| 541 | * Describes the consumers visibility to the allocated resource. |
| 542 | */ |
| 543 | public ConsumerVisibility getConsumerVisibility() { |
| 544 | return consumerVisibility; |
| 545 | } |
| 546 | |
| 547 | /** |
| 548 | * This property specifies the upper bound, or maximum amount of resource |
| 549 | * that will be granted for this allocation. For example, a system which |
| 550 | * supports memory paging may support setting the Limit of a Memory |
| 551 | * allocation below that of the VirtualQuantity, thus forcing paging to occur |
| 552 | * for this allocation. The value of the Limit property is expressed in the |
| 553 | * unit specified by the value of the AllocationUnits property. |
| 554 | */ |
| 555 | public Long getLimit() { |
| 556 | return limit; |
| 557 | } |
| 558 | |
| 559 | /** |
| 560 | * Specifies how this resource maps to underlying resourcesIf the |
| 561 | * HostResource array contains any entries, this property reflects how the |
| 562 | * resource maps to those specific resources. |
| 563 | */ |
| 564 | public MappingBehavior getMappingBehavior() { |
| 565 | return mappingBehavior; |
| 566 | } |
| 567 | |
| 568 | /** |
| 569 | * A string that describes the resource type when a well defined value is not |
| 570 | * available and ResourceType has the value "Other". |
| 571 | */ |
| 572 | public String getOtherResourceType() { |
| 573 | return otherResourceType; |
| 574 | } |
| 575 | |
| 576 | /** |
| 577 | * The Parent of the resource. For example, a controller for the current |
| 578 | * allocation |
| 579 | */ |
| 580 | public String getParent() { |
| 581 | return parent; |
| 582 | } |
| 583 | |
| 584 | /** |
| 585 | * This property specifies which ResourcePool the resource is currently |
| 586 | * allocated from, or which ResourcePool the resource will be allocated from |
| 587 | * when the allocation occurs. |
| 588 | */ |
| 589 | public String getPoolID() { |
| 590 | return poolID; |
| 591 | } |
| 592 | |
| 593 | /** |
| 594 | * This property specifies the amount of resource guaranteed to be available |
| 595 | * for this allocation. On system which support over-commitment of resources, |
| 596 | * this value is typically used for admission control to prevent an an |
| 597 | * allocation from being accepted thus preventing starvation. The value of |
| 598 | * the Reservation property is expressed in the unit specified by the value |
| 599 | * of the AllocationUnits property. |
| 600 | */ |
| 601 | public Long getReservation() { |
| 602 | return reservation; |
| 603 | } |
| 604 | |
| 605 | /** |
| 606 | * A string describing an implementation specific sub-type for this resource. |
| 607 | * F |
| 608 | */ |
| 609 | public String getResourceSubType() { |
| 610 | return resourceSubType; |
| 611 | } |
| 612 | |
| 613 | /** |
| 614 | * The type of resource this allocation setting represents. |
| 615 | */ |
| 616 | public ResourceType getResourceType() { |
| 617 | return resourceType; |
| 618 | } |
| 619 | |
| 620 | /** |
| 621 | * This property specifies the quantity of resources presented to the |
| 622 | * consumer. For example, when ResourceType=Processor, this property would |
| 623 | * reflect the number of discrete Processors presented to the virtual |
| 624 | * computer system. When ResourceType=Memory, this property could reflect the |
| 625 | * number of MB reported to the virtual computer system. The value of the |
| 626 | * VirtualQuantity property should be expressed in units as defined by the |
| 627 | * value of the VirtualQuantityUnits property. |
| 628 | */ |
| 629 | public Long getVirtualQuantity() { |
| 630 | return virtualQuantity; |
| 631 | } |
| 632 | |
| 633 | /** |
| 634 | * This property specifies the units used by the VirtualQuantity property. |
| 635 | * For example - if ResourceType=Processor, the value of the |
| 636 | * VirtualQuantityUnits property may be set to "count", indicating that the |
| 637 | * value of the VirtualQuantity property is expressed as a count. - if |
| 638 | * ResourceType=Memory, the value of the VirtualQuantityUnits property may be |
| 639 | * set to "bytes*10^3", indicating that the value of the VirtualQuantity |
| 640 | * property is expressed in kilobyte. It is expected that profiles constrain |
| 641 | * the units that apply in context of particular resource types. The value of |
| 642 | * this property shall be a legal value of the Programmatic Units qualifier |
| 643 | * as defined in Annex C.1 of DSP0004 V2.5 or later. |
| 644 | */ |
| 645 | public String getVirtualQuantityUnits() { |
| 646 | return virtualQuantityUnits; |
| 647 | } |
| 648 | |
| 649 | /** |
| 650 | * This property specifies a relative priority for this allocation in |
| 651 | * relation to other allocations from the same ResourcePool. This property |
| 652 | * has no unit of measure, and is only relevant when compared to other |
| 653 | * allocations vying for the same host resources. |
| 654 | */ |
| 655 | public Integer getWeight() { |
| 656 | return weight; |
| 657 | } |
| 658 | |
| 659 | /** |
| 660 | * The thing to which this resource is connected. For example, a named |
| 661 | * network or switch port. |
| 662 | */ |
| 663 | public List<String> getConnections() { |
| 664 | return connections; |
| 665 | } |
| 666 | |
| 667 | /** |
| 668 | * This property exposes specific assignment of resources. Each non-null |
| 669 | * value of the HostResource property shall be formated as a URI per RFC3986. |
| 670 | * If this resource is modeled then a value should be a WBEM URI (DSP0207). |
| 671 | * If the resource is not modeled then see the appropriate profile. Profiles |
| 672 | * may further constrain the type of URI. A NULL value or empty array |
| 673 | * requests the implementation decide the kind of host resource. If the |
| 674 | * virtual resource is mapped to more than oneunderlying resource, this |
| 675 | * property may be left NULL. If NULL, the DeviceAllocatedFromPool or |
| 676 | * ResourceAllocationFromPool associations may be used to determine the pool |
| 677 | * of host resources this virtual resource may use. If specific assignment is |
| 678 | * utilized, all underlying resources used by this virtual resource should be |
| 679 | * listed.The kind of dependency is specified by the ConsumerVisibility and |
| 680 | * the MappingBehavior properties. Typically the array contains one item, |
| 681 | * however multiple host resources may be specified. A client may set the |
| 682 | * value(s) to indicate that the requested virtual resource allocation be |
| 683 | * based on host resources that are identified by element values. |
| 684 | */ |
| 685 | public List<String> getHostResources() { |
| 686 | return hostResources; |
| 687 | } |
| 688 | |
| 689 | @Override |
| 690 | public String toString() { |
| 691 | return String |
| 692 | .format( |
| 693 | "[elementName=%s, instanceID=%s, caption=%s, description=%s, address=%s, addressOnParent=%s, allocationUnits=%s, automaticAllocation=%s, automaticDeallocation=%s, connections=%s, consumerVisibility=%s, hostResources=%s, limit=%s, mappingBehavior=%s, otherResourceType=%s, parent=%s, poolID=%s, reservation=%s, resourceSubType=%s, resourceType=%s, virtualQuantity=%s, virtualQuantityUnits=%s, weight=%s]", |
| 694 | elementName, instanceID, caption, description, address, addressOnParent, allocationUnits, |
| 695 | automaticAllocation, automaticDeallocation, connections, consumerVisibility, hostResources, limit, |
| 696 | mappingBehavior, otherResourceType, parent, poolID, reservation, resourceSubType, resourceType, |
| 697 | virtualQuantity, virtualQuantityUnits, weight); |
| 698 | } |
| 699 | |
| 700 | @Override |
| 701 | public int hashCode() { |
| 702 | final int prime = 31; |
| 703 | int result = super.hashCode(); |
| 704 | result = prime * result + ((address == null) ? 0 : address.hashCode()); |
| 705 | result = prime * result + ((addressOnParent == null) ? 0 : addressOnParent.hashCode()); |
| 706 | result = prime * result + ((resourceSubType == null) ? 0 : resourceSubType.hashCode()); |
| 707 | result = prime * result + ((resourceType == null) ? 0 : resourceType.hashCode()); |
| 708 | return result; |
| 709 | } |
| 710 | |
| 711 | @Override |
| 712 | public boolean equals(Object obj) { |
| 713 | if (this == obj) |
| 714 | return true; |
| 715 | if (!super.equals(obj)) |
| 716 | return false; |
| 717 | if (getClass() != obj.getClass()) |
| 718 | return false; |
| 719 | ResourceAllocationSettingData other = (ResourceAllocationSettingData) obj; |
| 720 | if (address == null) { |
| 721 | if (other.address != null) |
| 722 | return false; |
| 723 | } else if (!address.equals(other.address)) |
| 724 | return false; |
| 725 | if (addressOnParent == null) { |
| 726 | if (other.addressOnParent != null) |
| 727 | return false; |
| 728 | } else if (!addressOnParent.equals(other.addressOnParent)) |
| 729 | return false; |
| 730 | if (resourceSubType == null) { |
| 731 | if (other.resourceSubType != null) |
| 732 | return false; |
| 733 | } else if (!resourceSubType.equals(other.resourceSubType)) |
| 734 | return false; |
| 735 | if (resourceType == null) { |
| 736 | if (other.resourceType != null) |
| 737 | return false; |
| 738 | } else if (!resourceType.equals(other.resourceType)) |
| 739 | return false; |
| 740 | return true; |
| 741 | } |
| 742 | |
| 743 | } |