|
| 1 | +// Licensed to the Apache Software Foundation (ASF) under one |
| 2 | +// or more contributor license agreements. See the NOTICE file |
| 3 | +// distributed with this work for additional information |
| 4 | +// regarding copyright ownership. The ASF licenses this file |
| 5 | +// to you under the Apache License, Version 2.0 (the |
| 6 | +// "License"); you may not use this file except in compliance |
| 7 | +// with the License. You may obtain a copy of the License at |
| 8 | +// |
| 9 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +// |
| 11 | +// Unless required by applicable law or agreed to in writing, |
| 12 | +// software distributed under the License is distributed on an |
| 13 | +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 14 | +// KIND, either express or implied. See the License for the |
| 15 | +// specific language governing permissions and limitations |
| 16 | +// under the License. |
| 17 | +package com.cloud.agent.api; |
| 18 | + |
| 19 | +import java.net.URI; |
| 20 | + |
| 21 | +import com.cloud.utils.net.NetUtils; |
| 22 | + |
| 23 | +public class PvlanSetupCommand extends Command { |
| 24 | + public enum Type { |
| 25 | + DHCP, |
| 26 | + VM |
| 27 | + } |
| 28 | + private String op; |
| 29 | + private String primary; |
| 30 | + private String isolated; |
| 31 | + private String vmMac; |
| 32 | + private String dhcpName; |
| 33 | + private String dhcpMac; |
| 34 | + private String dhcpIp; |
| 35 | + private Type type; |
| 36 | + private String networkTag; |
| 37 | + |
| 38 | + protected PvlanSetupCommand() {} |
| 39 | + |
| 40 | + protected PvlanSetupCommand(Type type, String op, URI uri, String networkTag) |
| 41 | + { |
| 42 | + this.type = type; |
| 43 | + this.op = op; |
| 44 | + this.primary = NetUtils.getPrimaryPvlanFromUri(uri); |
| 45 | + this.isolated = NetUtils.getIsolatedPvlanFromUri(uri); |
| 46 | + this.networkTag = networkTag; |
| 47 | + } |
| 48 | + |
| 49 | + static public PvlanSetupCommand createDhcpSetup(String op, URI uri, String networkTag, String dhcpName, String dhcpMac, String dhcpIp) |
| 50 | + { |
| 51 | + PvlanSetupCommand cmd = new PvlanSetupCommand(Type.DHCP, op, uri, networkTag); |
| 52 | + cmd.setDhcpName(dhcpName); |
| 53 | + cmd.setDhcpMac(dhcpMac); |
| 54 | + cmd.setDhcpIp(dhcpIp); |
| 55 | + return cmd; |
| 56 | + } |
| 57 | + |
| 58 | + static public PvlanSetupCommand createVmSetup(String op, URI uri, String networkTag, String vmMac) |
| 59 | + { |
| 60 | + PvlanSetupCommand cmd = new PvlanSetupCommand(Type.VM, op, uri, networkTag); |
| 61 | + cmd.setVmMac(vmMac); |
| 62 | + return cmd; |
| 63 | + } |
| 64 | + |
| 65 | + @Override |
| 66 | + public boolean executeInSequence() { |
| 67 | + return true; |
| 68 | + } |
| 69 | + |
| 70 | + public String getOp() { |
| 71 | + return op; |
| 72 | + } |
| 73 | + |
| 74 | + public String getPrimary() { |
| 75 | + return primary; |
| 76 | + } |
| 77 | + |
| 78 | + public String getIsolated() { |
| 79 | + return isolated; |
| 80 | + } |
| 81 | + |
| 82 | + public String getVmMac() { |
| 83 | + return vmMac; |
| 84 | + } |
| 85 | + |
| 86 | + protected void setVmMac(String vmMac) { |
| 87 | + this.vmMac = vmMac; |
| 88 | + } |
| 89 | + |
| 90 | + public String getDhcpMac() { |
| 91 | + return dhcpMac; |
| 92 | + } |
| 93 | + |
| 94 | + protected void setDhcpMac(String dhcpMac) { |
| 95 | + this.dhcpMac = dhcpMac; |
| 96 | + } |
| 97 | + |
| 98 | + public String getDhcpIp() { |
| 99 | + return dhcpIp; |
| 100 | + } |
| 101 | + |
| 102 | + protected void setDhcpIp(String dhcpIp) { |
| 103 | + this.dhcpIp = dhcpIp; |
| 104 | + } |
| 105 | + |
| 106 | + public Type getType() { |
| 107 | + return type; |
| 108 | + } |
| 109 | + |
| 110 | + public String getDhcpName() { |
| 111 | + return dhcpName; |
| 112 | + } |
| 113 | + |
| 114 | + public void setDhcpName(String dhcpName) { |
| 115 | + this.dhcpName = dhcpName; |
| 116 | + } |
| 117 | + |
| 118 | + public String getNetworkTag() { |
| 119 | + return networkTag; |
| 120 | + } |
| 121 | +} |
0 commit comments