1 /**
2 *
3 * Copyright (C) 2011 Cloud Conscious, LLC. <info@cloudconscious.com>
4 *
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 package org.jclouds.vcloud.domain.network.nat.rules;
20
21 import static com.google.common.base.Preconditions.checkNotNull;
22
23 import javax.annotation.Nullable;
24
25 import org.jclouds.vcloud.domain.network.nat.NatRule;
26
27 /**
28 * The OneToOneVmRule element describes a NAT rule that specifies network address translation
29 * details for a single virtual machine. The external IP address can be specified manually or
30 * assigned automatically at deployment time. The internal IP address is discovered by looking up
31 * the specified VmReference and NIC ID.
32 *
33 * @since vcloud 0.9
34 * @author Adrian Cole
35 */
36 public class OneToOneVmRule implements NatRule {
37 private final MappingMode mappingMode;
38 @Nullable
39 private final String externalIP;
40 @Nullable
41 private final String vAppScopedVmId;
42 private final int vmNicId;
43
44 public OneToOneVmRule(MappingMode mappingMode, @Nullable String externalIp, @Nullable String vAppScopedVmId,
45 int vmNicId) {
46 this.mappingMode = checkNotNull(mappingMode, "mappingMode");
47 this.externalIP = externalIp;
48 this.vAppScopedVmId = vAppScopedVmId;
49 this.vmNicId = vmNicId;
50 }
51
52 /**
53 * @return how IP address mapping is implemented by the NAT service
54 * @since vcloud 0.9
55 */
56 public MappingMode getMappingMode() {
57 return mappingMode;
58 }
59
60 /**
61 * @return if MappingMode is manual, specifies the external IP address of this Vm, otherwise
62 * null.
63 * @since vcloud 0.9
64 */
65 @Nullable
66 @Override
67 public String getExternalIP() {
68 return externalIP;
69 }
70
71 /**
72 * @return readâonly identifier created on import
73 * @since vcloud 0.9
74 */
75 @Nullable
76 public String getVAppScopedVmId() {
77 return vAppScopedVmId;
78 }
79
80 /**
81 * @return device number of the NIC on the referenced virtual machine
82 * @since vcloud 0.9
83 */
84 public int getVmNicId() {
85 return vmNicId;
86 }
87
88 }