You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by hu...@apache.org on 2014/07/14 15:37:07 UTC
[03/44] CLOUDSTACK-6278 Baremetal Advanced Networking support
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7b444183/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/schema/SecurityGroupVmRuleSet.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/schema/SecurityGroupVmRuleSet.java b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/schema/SecurityGroupVmRuleSet.java
new file mode 100644
index 0000000..2c50c0e
--- /dev/null
+++ b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/schema/SecurityGroupVmRuleSet.java
@@ -0,0 +1,263 @@
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2012.07.11 at 03:24:15 PM PDT
+//
+
+
+package com.cloud.baremetal.networkservice.schema;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for anonymous complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType>
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element name="vmName" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ * <element name="vmId" type="{http://www.w3.org/2001/XMLSchema}long"/>
+ * <element name="vmIp" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ * <element name="vmMac" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ * <element name="signature" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ * <element name="sequenceNumber" type="{http://www.w3.org/2001/XMLSchema}long"/>
+ * <sequence maxOccurs="unbounded" minOccurs="0">
+ * <element name="ingressRules" type="{}SecurityGroupRule"/>
+ * </sequence>
+ * <sequence maxOccurs="unbounded" minOccurs="0">
+ * <element name="egressRules" type="{}SecurityGroupRule"/>
+ * </sequence>
+ * </sequence>
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "", propOrder = {
+ "vmName",
+ "vmId",
+ "vmIp",
+ "vmMac",
+ "signature",
+ "sequenceNumber",
+ "ingressRules",
+ "egressRules"
+})
+@XmlRootElement(name = "SecurityGroupVmRuleSet")
+public class SecurityGroupVmRuleSet {
+
+ @XmlElement(required = true)
+ protected String vmName;
+ protected long vmId;
+ @XmlElement(required = true)
+ protected String vmIp;
+ @XmlElement(required = true)
+ protected String vmMac;
+ @XmlElement(required = true)
+ protected String signature;
+ protected long sequenceNumber;
+ protected List<SecurityGroupRule> ingressRules;
+ protected List<SecurityGroupRule> egressRules;
+
+ /**
+ * Gets the value of the vmName property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getVmName() {
+ return vmName;
+ }
+
+ /**
+ * Sets the value of the vmName property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setVmName(String value) {
+ this.vmName = value;
+ }
+
+ /**
+ * Gets the value of the vmId property.
+ *
+ */
+ public long getVmId() {
+ return vmId;
+ }
+
+ /**
+ * Sets the value of the vmId property.
+ *
+ */
+ public void setVmId(long value) {
+ this.vmId = value;
+ }
+
+ /**
+ * Gets the value of the vmIp property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getVmIp() {
+ return vmIp;
+ }
+
+ /**
+ * Sets the value of the vmIp property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setVmIp(String value) {
+ this.vmIp = value;
+ }
+
+ /**
+ * Gets the value of the vmMac property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getVmMac() {
+ return vmMac;
+ }
+
+ /**
+ * Sets the value of the vmMac property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setVmMac(String value) {
+ this.vmMac = value;
+ }
+
+ /**
+ * Gets the value of the signature property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getSignature() {
+ return signature;
+ }
+
+ /**
+ * Sets the value of the signature property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setSignature(String value) {
+ this.signature = value;
+ }
+
+ /**
+ * Gets the value of the sequenceNumber property.
+ *
+ */
+ public long getSequenceNumber() {
+ return sequenceNumber;
+ }
+
+ /**
+ * Sets the value of the sequenceNumber property.
+ *
+ */
+ public void setSequenceNumber(long value) {
+ this.sequenceNumber = value;
+ }
+
+ /**
+ * Gets the value of the ingressRules property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the ingressRules property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ * <pre>
+ * getIngressRules().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link SecurityGroupRule }
+ *
+ *
+ */
+ public List<SecurityGroupRule> getIngressRules() {
+ if (ingressRules == null) {
+ ingressRules = new ArrayList<SecurityGroupRule>();
+ }
+ return this.ingressRules;
+ }
+
+ /**
+ * Gets the value of the egressRules property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the egressRules property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ * <pre>
+ * getEgressRules().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link SecurityGroupRule }
+ *
+ *
+ */
+ public List<SecurityGroupRule> getEgressRules() {
+ if (egressRules == null) {
+ egressRules = new ArrayList<SecurityGroupRule>();
+ }
+ return this.egressRules;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7b444183/plugins/hypervisors/baremetal/src/org/apache/cloudstack/api/AddBaremetalRctCmd.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/baremetal/src/org/apache/cloudstack/api/AddBaremetalRctCmd.java b/plugins/hypervisors/baremetal/src/org/apache/cloudstack/api/AddBaremetalRctCmd.java
new file mode 100755
index 0000000..554e2ec
--- /dev/null
+++ b/plugins/hypervisors/baremetal/src/org/apache/cloudstack/api/AddBaremetalRctCmd.java
@@ -0,0 +1,68 @@
+package org.apache.cloudstack.api;
+
+import com.cloud.baremetal.manager.BaremetalVlanManager;
+import com.cloud.baremetal.networkservice.BaremetalRctResponse;
+import com.cloud.event.EventTypes;
+import com.cloud.exception.ConcurrentOperationException;
+import com.cloud.exception.InsufficientCapacityException;
+import com.cloud.exception.NetworkRuleConflictException;
+import com.cloud.exception.ResourceAllocationException;
+import com.cloud.exception.ResourceUnavailableException;
+import org.apache.cloudstack.context.CallContext;
+import org.apache.log4j.Logger;
+
+import javax.inject.Inject;
+
+/**
+ * Created by frank on 5/8/14.
+ */
+@APICommand(name = "addBaremetalRct", description = "adds baremetal rack configuration text", responseObject = BaremetalRctResponse.class,
+ requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
+public class AddBaremetalRctCmd extends BaseAsyncCmd {
+ private static final String s_name = "addbaremetalrctresponse";
+ public static final Logger s_logger = Logger.getLogger(AddBaremetalRctCmd.class);
+
+ @Inject
+ private BaremetalVlanManager vlanMgr;
+
+ @Parameter(name=ApiConstants.BAREMETAL_RCT_URL, required = true, description = "http url to baremetal RCT configuration")
+ private String rctUrl;
+
+ public String getRctUrl() {
+ return rctUrl;
+ }
+
+ public void setRctUrl(String rctUrl) {
+ this.rctUrl = rctUrl;
+ }
+
+ public String getEventType() {
+ return EventTypes.EVENT_BAREMETAL_RCT_ADD;
+ }
+
+ @Override
+ public String getEventDescription() {
+ return "Adding baremetal rct configuration";
+ }
+
+ @Override
+ public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException {
+ try {
+ BaremetalRctResponse rsp = vlanMgr.addRct(this);
+ this.setResponseObject(rsp);
+ } catch (Exception e) {
+ s_logger.warn(String.format("unable to add baremetal RCT[%s]", getRctUrl()), e);
+ throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, e.getMessage());
+ }
+ }
+
+ @Override
+ public String getCommandName() {
+ return s_name;
+ }
+
+ @Override
+ public long getEntityOwnerId() {
+ return CallContext.current().getCallingAccount().getId();
+ }
+}