From 183b248c4e47a49a9d5b0b27b9bf79519e3fe907 Mon Sep 17 00:00:00 2001 From: Hugo Trippaers Date: Tue, 29 Jul 2014 17:56:51 +0200 Subject: [PATCH] Include a type field in all json configuration objects --- .../virtualnetwork/model/ConfigBase.java | 14 +++ .../virtualnetwork/model/GuestNetwork.java | 5 +- .../virtualnetwork/model/NetworkACL.java | 92 +++++++++++++++++++ 3 files changed, 109 insertions(+), 2 deletions(-) create mode 100644 core/src/com/cloud/agent/resource/virtualnetwork/model/ConfigBase.java create mode 100644 core/src/com/cloud/agent/resource/virtualnetwork/model/NetworkACL.java diff --git a/core/src/com/cloud/agent/resource/virtualnetwork/model/ConfigBase.java b/core/src/com/cloud/agent/resource/virtualnetwork/model/ConfigBase.java new file mode 100644 index 00000000000..f84a1c65397 --- /dev/null +++ b/core/src/com/cloud/agent/resource/virtualnetwork/model/ConfigBase.java @@ -0,0 +1,14 @@ +package com.cloud.agent.resource.virtualnetwork.model; + +public abstract class ConfigBase { + private String type = "unknown"; + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + +} diff --git a/core/src/com/cloud/agent/resource/virtualnetwork/model/GuestNetwork.java b/core/src/com/cloud/agent/resource/virtualnetwork/model/GuestNetwork.java index 9bb59d7889c..336997ae0c4 100644 --- a/core/src/com/cloud/agent/resource/virtualnetwork/model/GuestNetwork.java +++ b/core/src/com/cloud/agent/resource/virtualnetwork/model/GuestNetwork.java @@ -19,7 +19,7 @@ package com.cloud.agent.resource.virtualnetwork.model; -public class GuestNetwork { +public class GuestNetwork extends ConfigBase { private boolean add; private String macAddress; private String device; @@ -32,11 +32,12 @@ public class GuestNetwork { public GuestNetwork() { // Empty constructor for (de)serialization + setType("guestnetwork"); } public GuestNetwork(boolean add, String macAddress, String device, String routerGuestIp, String routerGuestNetmask, String routerGuestGateway, String cidr, String dns, String domainName) { - super(); + setType("guestnetwork"); this.add = add; this.macAddress = macAddress; this.device = device; diff --git a/core/src/com/cloud/agent/resource/virtualnetwork/model/NetworkACL.java b/core/src/com/cloud/agent/resource/virtualnetwork/model/NetworkACL.java new file mode 100644 index 00000000000..bf79b10a54c --- /dev/null +++ b/core/src/com/cloud/agent/resource/virtualnetwork/model/NetworkACL.java @@ -0,0 +1,92 @@ +// +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// + +package com.cloud.agent.resource.virtualnetwork.model; + +public class NetworkACL extends ConfigBase { + private String device; + private String macAddress; + private boolean privateGatewayAcl; + private String nicIp; + private String nicNetmask; + private String rule; + + public NetworkACL() { + setType("networkacl"); + } + + public NetworkACL(String device, String macAddress, boolean privateGatewayAcl, String nicIp, String nicNetmask, String rule) { + setType("networkacl"); + this.device = device; + this.macAddress = macAddress; + this.privateGatewayAcl = privateGatewayAcl; + this.nicIp = nicIp; + this.nicNetmask = nicNetmask; + this.rule = rule; //FIXME Split this in o + } + + public String getDevice() { + return device; + } + + public void setDevice(String device) { + this.device = device; + } + + public String getMacAddress() { + return macAddress; + } + + public void setMacAddress(String macAddress) { + this.macAddress = macAddress; + } + + public boolean isPrivateGatewayAcl() { + return privateGatewayAcl; + } + + public void setPrivateGatewayAcl(boolean privateGatewayAcl) { + this.privateGatewayAcl = privateGatewayAcl; + } + + public String getNicIp() { + return nicIp; + } + + public void setNicIp(String nicIp) { + this.nicIp = nicIp; + } + + public String getNicNetmask() { + return nicNetmask; + } + + public void setNicNetmask(String nicNetmask) { + this.nicNetmask = nicNetmask; + } + + public String getRule() { + return rule; + } + + public void setRule(String rule) { + this.rule = rule; + } + +}