Skip to content

Commit

Permalink
=initial changes
Browse files Browse the repository at this point in the history
  • Loading branch information
nitinmeh committed Apr 25, 2013
1 parent 08f6a24 commit d1642a4
Show file tree
Hide file tree
Showing 64 changed files with 2,555 additions and 120 deletions.
3 changes: 3 additions & 0 deletions api/src/com/cloud/event/EventTypes.java
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@ public class EventTypes {
public static final String EVENT_VOLUME_UPLOAD = "VOLUME.UPLOAD";
public static final String EVENT_VOLUME_MIGRATE = "VOLUME.MIGRATE";
public static final String EVENT_VOLUME_RESIZE = "VOLUME.RESIZE";
public static final String EVENT_VOLUME_DETAIL_UPDATE = "VOLUME.DETAIL.UPDATE";
public static final String EVENT_VOLUME_DETAIL_ADD = "VOLUME.DETAIL.ADD";
public static final String EVENT_VOLUME_DETAIL_REMOVE = "VOLUME.DETAIL.REMOVE";

// Domains
public static final String EVENT_DOMAIN_CREATE = "DOMAIN.CREATE";
Expand Down
2 changes: 2 additions & 0 deletions api/src/com/cloud/network/Network.java
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,8 @@ public void setIp6Address(String ip6Address) {

boolean getSpecifyIpRanges();

boolean getDisplayNetwork();

/**
* @return
*/
Expand Down
7 changes: 7 additions & 0 deletions api/src/com/cloud/network/NetworkProfile.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public class NetworkProfile implements Network {
private boolean restartRequired;
private boolean specifyIpRanges;
private Long vpcId;
private boolean displayNetwork;

public NetworkProfile(Network network) {
this.id = network.getId();
Expand Down Expand Up @@ -81,6 +82,7 @@ public NetworkProfile(Network network) {
this.restartRequired = network.isRestartRequired();
this.specifyIpRanges = network.getSpecifyIpRanges();
this.vpcId = network.getVpcId();
this.displayNetwork = network.getDisplayNetwork();
}

public String getDns1() {
Expand Down Expand Up @@ -231,6 +233,11 @@ public boolean getSpecifyIpRanges() {
return false;
}

@Override
public boolean getDisplayNetwork() {
return displayNetwork;
}

@Override
public Long getVpcId() {
return vpcId;
Expand Down
13 changes: 7 additions & 6 deletions api/src/com/cloud/storage/VolumeApiService.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,7 @@
*/
package com.cloud.storage;

import org.apache.cloudstack.api.command.user.volume.AttachVolumeCmd;
import org.apache.cloudstack.api.command.user.volume.CreateVolumeCmd;
import org.apache.cloudstack.api.command.user.volume.DetachVolumeCmd;
import org.apache.cloudstack.api.command.user.volume.MigrateVolumeCmd;
import org.apache.cloudstack.api.command.user.volume.ResizeVolumeCmd;
import org.apache.cloudstack.api.command.user.volume.UploadVolumeCmd;
import org.apache.cloudstack.api.command.user.volume.*;

import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.PermissionDeniedException;
Expand Down Expand Up @@ -79,4 +74,10 @@ public interface VolumeApiService {
Volume attachVolumeToVM(AttachVolumeCmd command);

Volume detachVolumeFromVM(DetachVolumeCmd cmmd);

void updateVolumeDetails(UpdateVolumeDetailCmd updateVolumeDetailCmd);

void removeVolumeDetail(RemoveVolumeDetailCmd removeVolumeDetailCmd);

void addVolumeDetail(AddVolumeDetailCmd addVolumeDetailCmd);
}
16 changes: 16 additions & 0 deletions api/src/com/cloud/storage/VolumeDetail.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.cloud.storage;

import org.apache.cloudstack.acl.ControlledEntity;
import org.apache.cloudstack.api.Identity;
import org.apache.cloudstack.api.InternalIdentity;

/**
* Created with IntelliJ IDEA.
* User: nitinmehta
* Date: 24/04/13
* Time: 5:55 PM
* To change this template use File | Settings | File Templates.
*/
public interface VolumeDetail extends ControlledEntity, InternalIdentity, Identity {

}
22 changes: 16 additions & 6 deletions api/src/com/cloud/vm/UserVmService.java
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,10 @@ UserVm startVirtualMachine(StartVMCmd cmd) throws StorageUnavailableException, E
* TODO
* @param defaultIp
* TODO
* @param displayVm
* - Boolean flag whether to the display the vm to the end user or not
* @param affinityGroupIdList
*
* @param accountName
* - an optional account for the virtual machine. Must be used
* with domainId
Expand All @@ -197,9 +200,9 @@ UserVm startVirtualMachine(StartVMCmd cmd) throws StorageUnavailableException, E
* @throws InsufficientResourcesException
*/
UserVm createBasicSecurityGroupVirtualMachine(DataCenter zone, ServiceOffering serviceOffering, VirtualMachineTemplate template, List<Long> securityGroupIdList, Account owner, String hostName,
String displayName, Long diskOfferingId, Long diskSize, String group, HypervisorType hypervisor,
String displayName, Long diskOfferingId, Long diskSize, String group, HypervisorType hypervisor,
HTTPMethod httpmethod, String userData, String sshKeyPair, Map<Long, IpAddresses> requestedIps,
IpAddresses defaultIp, String keyboard, List<Long> affinityGroupIdList)
IpAddresses defaultIp, Boolean displayVm, String keyboard, List<Long> affinityGroupIdList)
throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException, StorageUnavailableException, ResourceAllocationException;

/**
Expand Down Expand Up @@ -250,7 +253,10 @@ UserVm createBasicSecurityGroupVirtualMachine(DataCenter zone, ServiceOffering s
* TODO
* @param defaultIps
* TODO
* @param displayVm
* - Boolean flag whether to the display the vm to the end user or not
* @param affinityGroupIdList
*
* @param accountName
* - an optional account for the virtual machine. Must be used
* with domainId
Expand All @@ -270,8 +276,8 @@ UserVm createBasicSecurityGroupVirtualMachine(DataCenter zone, ServiceOffering s
* @throws InsufficientResourcesException
*/
UserVm createAdvancedSecurityGroupVirtualMachine(DataCenter zone, ServiceOffering serviceOffering, VirtualMachineTemplate template, List<Long> networkIdList, List<Long> securityGroupIdList,
Account owner, String hostName, String displayName, Long diskOfferingId, Long diskSize, String group, HypervisorType hypervisor, HTTPMethod httpmethod, String userData, String sshKeyPair,
Map<Long, IpAddresses> requestedIps, IpAddresses defaultIps, String keyboard, List<Long> affinityGroupIdList)
Account owner, String hostName, String displayName, Long diskOfferingId, Long diskSize, String group, HypervisorType hypervisor, HTTPMethod httpmethod, String userData, String sshKeyPair,
Map<Long, IpAddresses> requestedIps, IpAddresses defaultIps, Boolean displayVm, String keyboard, List<Long> affinityGroupIdList)
throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException, StorageUnavailableException, ResourceAllocationException;

/**
Expand Down Expand Up @@ -319,7 +325,10 @@ UserVm createAdvancedSecurityGroupVirtualMachine(DataCenter zone, ServiceOfferin
* TODO
* @param defaultIps
* TODO
* @param displayVm
* - Boolean flag whether to the display the vm to the end user or not
* @param affinityGroupIdList
*
* @param accountName
* - an optional account for the virtual machine. Must be used
* with domainId
Expand All @@ -340,8 +349,9 @@ UserVm createAdvancedSecurityGroupVirtualMachine(DataCenter zone, ServiceOfferin
*/
UserVm createAdvancedVirtualMachine(DataCenter zone, ServiceOffering serviceOffering, VirtualMachineTemplate template, List<Long> networkIdList, Account owner, String hostName,
String displayName, Long diskOfferingId, Long diskSize, String group, HypervisorType hypervisor,
HTTPMethod httpmethod, String userData, String sshKeyPair, Map<Long, IpAddresses> requestedIps,
IpAddresses defaultIps, String keyboard, List<Long> affinityGroupIdList)
HTTPMethod httpmethod, String userData, String sshKeyPair, Map<Long, IpAddresses> requestedIps,
IpAddresses defaultIps, Boolean displayVm, String keyboard, List<Long> affinityGroupIdList)

throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException, StorageUnavailableException, ResourceAllocationException;

/**
Expand Down
4 changes: 4 additions & 0 deletions api/src/org/apache/cloudstack/api/ApiConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,11 @@ public class ApiConstants {
public static final String DISK_OFFERING_ID = "diskofferingid";
public static final String DISK_SIZE = "disksize";
public static final String DISPLAY_NAME = "displayname";
public static final String DISPLAY_NETWORK = "displaynetwork";
public static final String DISPLAY_TEXT = "displaytext";
public static final String DISPLAY_VM = "displayvm";
public static final String DISPLAY_OFFERING = "displayoffering";
public static final String DISPLAY_VOLUME = "displayvolume";
public static final String DNS1 = "dns1";
public static final String DNS2 = "dns2";
public static final String IP6_DNS1 = "ip6dns1";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ public class CreateDiskOfferingCmd extends BaseCmd {
@Parameter(name=ApiConstants.STORAGE_TYPE, type=CommandType.STRING, description="the storage type of the disk offering. Values are local and shared.")
private String storageType = ServiceOffering.StorageType.shared.toString();

/////////////////////////////////////////////////////
@Parameter(name=ApiConstants.DISPLAY_OFFERING, type=CommandType.BOOLEAN, description="an optional field, whether to display the offering to the end user or not.")
private Boolean displayOffering;

/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////

Expand Down Expand Up @@ -94,6 +97,10 @@ public String getStorageType() {
return storageType;
}

public Boolean getDisplayOffering() {
return displayOffering;
}

/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
// 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 org.apache.cloudstack.api.command.user.network;

import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.response.NicResponse;
import org.apache.cloudstack.api.response.SuccessResponse;
import org.apache.cloudstack.api.response.UserVmResponse;
import org.apache.cloudstack.api.response.VolumeResponse;
import org.apache.log4j.Logger;

import com.cloud.async.AsyncJob;
import com.cloud.event.EventTypes;
import com.cloud.storage.Volume;
import com.cloud.user.Account;
import com.cloud.user.UserContext;

@APICommand(name = "addNicDetail", description="Adds detail for the volume.", since="4.2", responseObject=SuccessResponse.class)
public class AddNicDetailCmd extends BaseAsyncCmd {
public static final Logger s_logger = Logger.getLogger(AddNicDetailCmd.class.getName());
private static final String s_name = "addNicDetailresponse";

/////////////////////////////////////////////////////
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////

@Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType=NicResponse.class,
required=true, description="the ID of the nic")
private Long id;

@Parameter(name=ApiConstants.NAME, type=CommandType.STRING,
required=true, description="the name of the field")
private String name;

@Parameter(name=ApiConstants.VALUE, type=CommandType.STRING,
required=true, description="the value of the field")
private String value;

/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////


public String getName() {
return name;
}

public String getValue() {
return value;
}

public Long getId() {
return id;
}

/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////

@Override
public String getCommandName() {
return s_name;
}

public AsyncJob.Type getInstanceType() {
return AsyncJob.Type.Volume;
}

public Long getInstanceId() {
return getId();
}

@Override
public long getEntityOwnerId() {
Volume volume = _responseGenerator.findVolumeById(getId());
if (volume == null) {
return Account.ACCOUNT_ID_SYSTEM; // bad id given, parent this command to SYSTEM so ERROR events are tracked
}
return volume.getAccountId();
}

@Override
public String getEventType() {
return EventTypes.EVENT_VOLUME_ATTACH;
}

@Override
public String getEventDescription() {
return "adding detail to the nic: " + getId();
}

@Override
public void execute(){
_networkService.addNicDetail(this);
this.setResponseObject(new SuccessResponse(getCommandName()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ public class CreateNetworkCmd extends BaseCmd {
@Parameter(name=ApiConstants.IP6_CIDR, type=CommandType.STRING, description="the CIDR of IPv6 network, must be at least /64")
private String ip6Cidr;

@Parameter(name=ApiConstants.DISPLAY_NETWORK, type=CommandType.BOOLEAN, description="an optional field, whether to the display the network to the end user or not.")
private Boolean displayNetwork;

/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
Expand Down Expand Up @@ -189,6 +192,10 @@ public Long getVpcId() {
return vpcId;
}

public Boolean getDisplayNetwork() {
return displayNetwork;
}

public Long getZoneId() {
Long physicalNetworkId = getPhysicalNetworkId();

Expand Down
Loading

0 comments on commit d1642a4

Please sign in to comment.