Merge branch 'master' of ssh://git.cloud.com/var/lib/git/cloudstack-oss

This commit is contained in:
Abhinandan Prateek 2011-12-04 15:12:48 +05:30
commit d09ed94ebb
77 changed files with 880 additions and 754 deletions

View File

@ -19,10 +19,16 @@
package com.cloud.agent;
import java.util.*;
import java.net.*;
import java.io.*;
import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.net.MulticastSocket;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.util.ArrayList;
import java.util.List;
import org.apache.log4j.Logger;
public class MultiCaster implements Runnable {

View File

@ -18,7 +18,7 @@
*/
package com.cloud.agent;
import java.net.*;
import java.net.InetAddress;
public interface MultiCasterListener {
public void onMultiCasting(byte[] data, int off, int len, InetAddress addrFrom);

View File

@ -19,7 +19,7 @@
package com.cloud.agent;
import java.io.Serializable;
import java.io.Serializable;
public class SimulatorCmd implements Serializable {
private static final long serialVersionUID = 1L;

View File

@ -5,19 +5,12 @@ import java.util.Map;
import javax.naming.ConfigurationException;
import com.cloud.agent.api.Answer;
import com.cloud.agent.api.CheckHealthAnswer;
import com.cloud.agent.api.CheckHealthCommand;
import com.cloud.agent.api.GetHostStatsAnswer;
import com.cloud.agent.api.GetHostStatsCommand;
import com.cloud.agent.api.HostStatsEntry;
import com.cloud.agent.api.MaintainCommand;
import com.cloud.agent.api.PingTestCommand;
import com.cloud.agent.api.PrepareForMigrationAnswer;
import com.cloud.agent.api.PrepareForMigrationCommand;
import com.cloud.agent.api.ReadyAnswer;
import com.cloud.agent.api.ReadyCommand;
import com.cloud.agent.api.SecurityIngressRulesCmd;
import com.cloud.agent.api.ShutdownCommand;
import com.cloud.resource.AgentResourceBase;
import com.cloud.simulator.MockHost;
import com.cloud.utils.component.Manager;

View File

@ -8,20 +8,16 @@ import com.cloud.agent.api.Answer;
import com.cloud.agent.api.AttachIsoCommand;
import com.cloud.agent.api.AttachVolumeAnswer;
import com.cloud.agent.api.AttachVolumeCommand;
import com.cloud.agent.api.BackupSnapshotAnswer;
import com.cloud.agent.api.BackupSnapshotCommand;
import com.cloud.agent.api.ComputeChecksumCommand;
import com.cloud.agent.api.CreatePrivateTemplateFromSnapshotCommand;
import com.cloud.agent.api.CreatePrivateTemplateFromVolumeCommand;
import com.cloud.agent.api.CreateStoragePoolCommand;
import com.cloud.agent.api.CreateVolumeFromSnapshotAnswer;
import com.cloud.agent.api.CreateVolumeFromSnapshotCommand;
import com.cloud.agent.api.DeleteSnapshotBackupAnswer;
import com.cloud.agent.api.DeleteSnapshotBackupCommand;
import com.cloud.agent.api.DeleteStoragePoolCommand;
import com.cloud.agent.api.GetStorageStatsAnswer;
import com.cloud.agent.api.GetStorageStatsCommand;
import com.cloud.agent.api.ManageSnapshotAnswer;
import com.cloud.agent.api.ManageSnapshotCommand;
import com.cloud.agent.api.ModifyStoragePoolCommand;
import com.cloud.agent.api.SecStorageSetupCommand;
@ -31,8 +27,6 @@ import com.cloud.agent.api.storage.CopyVolumeAnswer;
import com.cloud.agent.api.storage.CopyVolumeCommand;
import com.cloud.agent.api.storage.CreateAnswer;
import com.cloud.agent.api.storage.CreateCommand;
import com.cloud.agent.api.storage.CreatePrivateTemplateAnswer;
import com.cloud.agent.api.storage.CreatePrivateTemplateCommand;
import com.cloud.agent.api.storage.DeleteTemplateCommand;
import com.cloud.agent.api.storage.DestroyCommand;
import com.cloud.agent.api.storage.DownloadCommand;

View File

@ -10,15 +10,15 @@ import java.net.URI;
import java.net.URISyntaxException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.HashMap;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map;
import java.util.UUID;
import javax.ejb.Local;
import javax.naming.ConfigurationException;
import org.apache.log4j.Logger;
import org.apache.log4j.Logger;
import com.cloud.agent.api.Answer;
import com.cloud.agent.api.AttachIsoCommand;
@ -60,11 +60,11 @@ import com.cloud.agent.api.storage.PrimaryStorageDownloadAnswer;
import com.cloud.agent.api.storage.PrimaryStorageDownloadCommand;
import com.cloud.agent.api.to.StorageFilerTO;
import com.cloud.agent.api.to.VolumeTO;
import com.cloud.simulator.MockVm;
import com.cloud.simulator.MockHost;
import com.cloud.simulator.MockSecStorageVO;
import com.cloud.simulator.MockStoragePoolVO;
import com.cloud.simulator.MockVMVO;
import com.cloud.simulator.MockVm;
import com.cloud.simulator.MockVolumeVO;
import com.cloud.simulator.MockVolumeVO.MockVolumeType;
import com.cloud.simulator.dao.MockHostDao;
@ -72,9 +72,9 @@ import com.cloud.simulator.dao.MockSecStorageDao;
import com.cloud.simulator.dao.MockStoragePoolDao;
import com.cloud.simulator.dao.MockVMDao;
import com.cloud.simulator.dao.MockVolumeDao;
import com.cloud.storage.VMTemplateStorageResourceAssoc;
import com.cloud.storage.Storage.ImageFormat;
import com.cloud.storage.Storage.StoragePoolType;
import com.cloud.storage.VMTemplateStorageResourceAssoc;
import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
import com.cloud.storage.template.TemplateInfo;
import com.cloud.utils.component.Inject;

View File

@ -4,11 +4,8 @@
package com.cloud.agent.manager;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import com.cloud.agent.api.Answer;
import com.cloud.agent.api.CheckVirtualMachineCommand;
@ -19,14 +16,12 @@ import com.cloud.agent.api.GetVmStatsCommand;
import com.cloud.agent.api.GetVncPortCommand;
import com.cloud.agent.api.MigrateAnswer;
import com.cloud.agent.api.MigrateCommand;
import com.cloud.agent.api.NetworkUsageAnswer;
import com.cloud.agent.api.NetworkUsageCommand;
import com.cloud.agent.api.RebootCommand;
import com.cloud.agent.api.SecurityIngressRuleAnswer;
import com.cloud.agent.api.SecurityIngressRulesCmd;
import com.cloud.agent.api.SecurityGroupRuleAnswer;
import com.cloud.agent.api.SecurityGroupRulesCmd;
import com.cloud.agent.api.StartCommand;
import com.cloud.agent.api.StopCommand;
import com.cloud.agent.api.VmStatsEntry;
import com.cloud.agent.api.check.CheckSshAnswer;
import com.cloud.agent.api.check.CheckSshCommand;
import com.cloud.agent.api.proxy.CheckConsoleProxyLoadCommand;
@ -35,14 +30,9 @@ import com.cloud.agent.api.routing.DhcpEntryCommand;
import com.cloud.agent.api.routing.IpAssocCommand;
import com.cloud.agent.api.routing.LoadBalancerConfigCommand;
import com.cloud.agent.api.routing.SavePasswordCommand;
import com.cloud.agent.api.routing.SetPortForwardingRulesAnswer;
import com.cloud.agent.api.routing.SetPortForwardingRulesCommand;
import com.cloud.agent.api.routing.SetStaticNatRulesAnswer;
import com.cloud.agent.api.routing.SetStaticNatRulesCommand;
import com.cloud.agent.api.routing.VmDataCommand;
import com.cloud.agent.api.storage.DestroyCommand;
import com.cloud.agent.api.to.NicTO;
import com.cloud.simulator.MockVm;
import com.cloud.utils.Pair;
import com.cloud.utils.component.Manager;
import com.cloud.vm.VirtualMachine.State;
@ -80,7 +70,7 @@ public interface MockVmManager extends Manager {
Answer SavePassword(SavePasswordCommand cmd);
HashMap<String, Pair<Long, Long>> syncNetworkGroups(SimulatorInfo info);
SecurityIngressRuleAnswer AddSecurityIngressRules(SecurityIngressRulesCmd cmd, SimulatorInfo info);
SecurityGroupRuleAnswer AddSecurityGroupRules(SecurityGroupRulesCmd cmd, SimulatorInfo info);
MigrateAnswer Migrate(MigrateCommand cmd, SimulatorInfo info);
GetDomRVersionAnswer getDomRVersion(GetDomRVersionCmd cmd);

View File

@ -6,8 +6,6 @@ package com.cloud.agent.manager;
import java.util.HashMap;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@ -32,8 +30,8 @@ import com.cloud.agent.api.MigrateCommand;
import com.cloud.agent.api.NetworkUsageAnswer;
import com.cloud.agent.api.NetworkUsageCommand;
import com.cloud.agent.api.RebootCommand;
import com.cloud.agent.api.SecurityIngressRuleAnswer;
import com.cloud.agent.api.SecurityIngressRulesCmd;
import com.cloud.agent.api.SecurityGroupRuleAnswer;
import com.cloud.agent.api.SecurityGroupRulesCmd;
import com.cloud.agent.api.StartAnswer;
import com.cloud.agent.api.StartCommand;
import com.cloud.agent.api.StopAnswer;
@ -47,19 +45,13 @@ import com.cloud.agent.api.routing.DhcpEntryCommand;
import com.cloud.agent.api.routing.IpAssocCommand;
import com.cloud.agent.api.routing.LoadBalancerConfigCommand;
import com.cloud.agent.api.routing.SavePasswordCommand;
import com.cloud.agent.api.routing.SetPortForwardingRulesAnswer;
import com.cloud.agent.api.routing.SetPortForwardingRulesCommand;
import com.cloud.agent.api.routing.SetStaticNatRulesAnswer;
import com.cloud.agent.api.routing.SetStaticNatRulesCommand;
import com.cloud.agent.api.routing.VmDataCommand;
import com.cloud.agent.api.storage.DestroyCommand;
import com.cloud.agent.api.to.NicTO;
import com.cloud.agent.api.to.VirtualMachineTO;
import com.cloud.network.Networks.TrafficType;
import com.cloud.simulator.MockHost;
import com.cloud.simulator.MockHostVO;
import com.cloud.simulator.MockSecurityRulesVO;
import com.cloud.simulator.MockVMVO;
import com.cloud.simulator.MockVm;
@ -69,7 +61,6 @@ import com.cloud.simulator.dao.MockVMDao;
import com.cloud.utils.Pair;
import com.cloud.utils.Ternary;
import com.cloud.utils.component.Inject;
import com.cloud.vm.VirtualMachine.State;
@Local(value = { MockVmManager.class })
@ -360,9 +351,9 @@ public class MockVmManagerImpl implements MockVmManager {
}
@Override
public SecurityIngressRuleAnswer AddSecurityIngressRules(SecurityIngressRulesCmd cmd, SimulatorInfo info) {
public SecurityGroupRuleAnswer AddSecurityGroupRules(SecurityGroupRulesCmd cmd, SimulatorInfo info) {
if (!info.isEnabled()) {
return new SecurityIngressRuleAnswer(cmd, false, "Disabled", SecurityIngressRuleAnswer.FailureReason.CANNOT_BRIDGE_FIREWALL);
return new SecurityGroupRuleAnswer(cmd, false, "Disabled", SecurityGroupRuleAnswer.FailureReason.CANNOT_BRIDGE_FIREWALL);
}
Map<String, Ternary<String,Long, Long>> rules = _securityRules.get(info.getHostUuid());
@ -377,10 +368,10 @@ public class MockVmManagerImpl implements MockVmManager {
rules.put(cmd.getVmName(), new Ternary<String, Long,Long>(cmd.getSignature(), cmd.getVmId(), cmd.getSeqNum()));
}
return new SecurityIngressRuleAnswer(cmd);
return new SecurityGroupRuleAnswer(cmd);
}
private boolean logSecurityGroupAction(SecurityIngressRulesCmd cmd, Ternary<String,Long, Long> rule) {
private boolean logSecurityGroupAction(SecurityGroupRulesCmd cmd, Ternary<String,Long, Long> rule) {
String action = ", do nothing";
String reason = ", reason=";
Long currSeqnum = rule == null? null: rule.third();
@ -424,8 +415,9 @@ public class MockVmManagerImpl implements MockVmManager {
}
s_logger.info("Programmed network rules for vm " + cmd.getVmName() + " seqno=" + cmd.getSeqNum()
+ " signature=" + cmd.getSignature()
+ " guestIp=" + cmd.getGuestIp() + ", numrules="
+ cmd.getRuleSet().length + " total cidrs=" + cmd.getTotalNumCidrs() + action + reason);
+ " guestIp=" + cmd.getGuestIp() + ", numIngressRules="
+ cmd.getIngressRuleSet().length + ", numEgressRules="
+ cmd.getEgressRuleSet().length + " total cidrs=" + cmd.getTotalNumCidrs() + action + reason);
return updateSeqnoAndSig;
}

View File

@ -4,7 +4,6 @@ import java.sql.Connection;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import javax.ejb.Local;
import javax.naming.ConfigurationException;
@ -40,7 +39,7 @@ import com.cloud.agent.api.PingTestCommand;
import com.cloud.agent.api.RebootCommand;
import com.cloud.agent.api.SecStorageSetupCommand;
import com.cloud.agent.api.SecStorageVMSetupCommand;
import com.cloud.agent.api.SecurityIngressRulesCmd;
import com.cloud.agent.api.SecurityGroupRulesCmd;
import com.cloud.agent.api.StartCommand;
import com.cloud.agent.api.StopCommand;
import com.cloud.agent.api.StoragePoolInfo;
@ -62,10 +61,8 @@ import com.cloud.agent.api.storage.DownloadCommand;
import com.cloud.agent.api.storage.DownloadProgressCommand;
import com.cloud.agent.api.storage.ListTemplateCommand;
import com.cloud.agent.api.storage.PrimaryStorageDownloadCommand;
import com.cloud.resource.AgentResourceBase;
import com.cloud.simulator.MockConfigurationVO;
import com.cloud.simulator.MockHost;
import com.cloud.simulator.MockHostVO;
import com.cloud.simulator.dao.MockConfigurationDao;
import com.cloud.simulator.dao.MockHostDao;
import com.cloud.utils.Pair;
@ -211,8 +208,8 @@ public class SimulatorManagerImpl implements SimulatorManager {
return _mockVmMgr.CheckConsoleProxyLoad((CheckConsoleProxyLoadCommand)cmd);
} else if (cmd instanceof WatchConsoleProxyLoadCommand) {
return _mockVmMgr.WatchConsoleProxyLoad((WatchConsoleProxyLoadCommand)cmd);
} else if (cmd instanceof SecurityIngressRulesCmd) {
return _mockVmMgr.AddSecurityIngressRules((SecurityIngressRulesCmd)cmd, info);
} else if (cmd instanceof SecurityGroupRulesCmd) {
return _mockVmMgr.AddSecurityGroupRules((SecurityGroupRulesCmd)cmd, info);
} else if (cmd instanceof SavePasswordCommand) {
return _mockVmMgr.SavePassword((SavePasswordCommand)cmd);
} else if (cmd instanceof PrimaryStorageDownloadCommand) {

View File

@ -4,8 +4,6 @@ import com.cloud.agent.manager.MockAgentManagerImpl;
import com.cloud.agent.manager.MockStorageManagerImpl;
import com.cloud.agent.manager.MockVmManagerImpl;
import com.cloud.agent.manager.SimulatorManagerImpl;
import com.cloud.network.NetworkUsageManagerImpl;
import com.cloud.simulator.dao.MockConfigurationDaoImpl;
import com.cloud.simulator.dao.MockHostDaoImpl;
import com.cloud.simulator.dao.MockSecStorageDaoImpl;

View File

@ -7,14 +7,12 @@ package com.cloud.resource;
import java.io.File;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.net.InetAddress;
import java.net.URL;
import java.util.ArrayList;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import javax.naming.ConfigurationException;
@ -27,17 +25,13 @@ import com.cloud.agent.api.PingCommand;
import com.cloud.agent.api.StartupCommand;
import com.cloud.agent.manager.MockAgentManager;
import com.cloud.agent.manager.MockStorageManager;
import com.cloud.agent.manager.MockStorageManagerImpl;
import com.cloud.agent.manager.MockVmManager;
import com.cloud.agent.manager.SimulatorManager;
import com.cloud.agent.manager.SimulatorManager.AgentType;
import com.cloud.host.Host;
import com.cloud.host.Host.Type;
import com.cloud.resource.ServerResource;
import com.cloud.simulator.MockHost;
import com.cloud.utils.component.ComponentLocator;
import com.cloud.utils.net.MacAddress;
import com.cloud.utils.net.NetUtils;
public class AgentResourceBase implements ServerResource {
private static final Logger s_logger = Logger

View File

@ -6,32 +6,24 @@ package com.cloud.resource;
import java.util.HashMap;
import java.util.Map;
import javax.naming.ConfigurationException;
import org.apache.log4j.Logger;
import com.cloud.agent.api.Answer;
import com.cloud.agent.api.Command;
import com.cloud.agent.api.PingCommand;
import com.cloud.agent.api.PingStorageCommand;
import com.cloud.agent.api.ReadyAnswer;
import com.cloud.agent.api.ReadyCommand;
import com.cloud.agent.api.StartupCommand;
import com.cloud.agent.api.StartupSecondaryStorageCommand;
import com.cloud.agent.api.storage.ssCommand;
import com.cloud.agent.manager.SimulatorManager;
import com.cloud.agent.manager.SimulatorManager.AgentType;
import com.cloud.host.Host;
import com.cloud.host.Host.Type;
import com.cloud.storage.resource.SecondaryStorageResource;
import com.cloud.vm.SecondaryStorageVm;

View File

@ -41,25 +41,19 @@ import com.cloud.agent.api.StartupCommand;
import com.cloud.agent.api.StartupRoutingCommand;
import com.cloud.agent.manager.MockAgentManager;
import com.cloud.agent.manager.MockStorageManager;
import com.cloud.agent.manager.SimulatorManager;
import com.cloud.agent.manager.SimulatorManagerImpl;
import com.cloud.dc.ClusterVO;
import com.cloud.dc.dao.ClusterDao;
import com.cloud.exception.ConnectionException;
import com.cloud.exception.DiscoveryException;
import com.cloud.resource.Discoverer;
import com.cloud.host.Host;
import com.cloud.host.HostVO;
import com.cloud.host.Status;
import com.cloud.host.dao.HostDao;
import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.storage.VMTemplateHostVO;
import com.cloud.storage.VMTemplateVO;
import com.cloud.storage.VMTemplateZoneVO;
import com.cloud.storage.dao.VMTemplateDao;
import com.cloud.storage.dao.VMTemplateHostDao;
import com.cloud.storage.dao.VMTemplateZoneDao;
import com.cloud.storage.VMTemplateStorageResourceAssoc;
import com.cloud.utils.component.Inject;
/**

View File

@ -1,6 +1,5 @@
package com.cloud.server;
import com.cloud.server.ManagementServerExtImpl;
public class ManagementServerSimulatorImpl extends ManagementServerExtImpl {
@Override

View File

@ -1,14 +1,10 @@
package com.cloud.simulator;
import javax.persistence.Column;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.Table;
@Entity

View File

@ -1,14 +1,10 @@
package com.cloud.simulator;
import javax.persistence.Column;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.Table;
@Entity

View File

@ -1,16 +1,12 @@
package com.cloud.simulator;
import javax.persistence.Column;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorType;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.Table;
import com.cloud.storage.Storage.StoragePoolType;

View File

@ -1,14 +1,10 @@
package com.cloud.simulator;
import javax.persistence.Column;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.Table;
import com.cloud.vm.VirtualMachine.State;

View File

@ -1,16 +1,12 @@
package com.cloud.simulator;
import javax.persistence.Column;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorType;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.Table;
import com.cloud.storage.VMTemplateStorageResourceAssoc;

View File

@ -2,14 +2,11 @@ package com.cloud.simulator.dao;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.Formatter;
import java.util.List;
import javax.ejb.Local;
import com.cloud.simulator.MockConfigurationVO;
import com.cloud.storage.VMTemplateHostVO;
import com.cloud.utils.db.GenericDaoBase;
import com.cloud.utils.db.SearchBuilder;
import com.cloud.utils.db.SearchCriteria;

View File

@ -2,12 +2,9 @@ package com.cloud.simulator.dao;
import javax.ejb.Local;
import com.cloud.simulator.MockHost;
import com.cloud.simulator.MockHostVO;
import com.cloud.utils.db.GenericDaoBase;
import com.cloud.utils.db.SearchBuilder;
import com.cloud.utils.db.SearchCriteria;

View File

@ -2,9 +2,7 @@ package com.cloud.simulator.dao;
import javax.ejb.Local;
import com.cloud.simulator.MockHostVO;
import com.cloud.simulator.MockSecStorageVO;
import com.cloud.simulator.MockVMVO;
import com.cloud.utils.db.GenericDaoBase;
import com.cloud.utils.db.SearchBuilder;
import com.cloud.utils.db.SearchCriteria;

View File

@ -1,16 +1,13 @@
package com.cloud.simulator.dao;
import java.util.List;
import java.util.Map;
import javax.ejb.Local;
import javax.naming.ConfigurationException;
import com.cloud.simulator.MockSecurityRulesVO;
import com.cloud.utils.db.GenericDaoBase;
import com.cloud.utils.db.SearchBuilder;
import com.cloud.utils.db.SearchCriteria;
@Local(value={MockSecurityRulesDao.class})

View File

@ -10,9 +10,7 @@ import javax.naming.ConfigurationException;
import com.cloud.simulator.MockHostVO;
import com.cloud.simulator.MockVMVO;
import com.cloud.utils.component.Inject;
import com.cloud.utils.db.Filter;
import com.cloud.utils.db.GenericDaoBase;
import com.cloud.utils.db.GenericSearchBuilder;
import com.cloud.utils.db.JoinBuilder;
import com.cloud.utils.db.SearchBuilder;
import com.cloud.utils.db.SearchCriteria;

View File

@ -130,6 +130,7 @@ public class ApiConstants {
public static final String PASSWORD = "password";
public static final String NEW_PASSWORD = "new_password";
public static final String PASSWORD_ENABLED = "passwordenabled";
public static final String SSHKEY_ENABLED = "sshkeyenabled";
public static final String PATH = "path";
public static final String POD_ID = "podid";
public static final String POLICY_ID = "policyid";

View File

@ -42,7 +42,6 @@ import com.cloud.exception.ResourceAllocationException;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.network.IpAddress;
import com.cloud.network.Network;
import com.cloud.network.Networks.TrafficType;
import com.cloud.user.UserContext;
@Implementation(description="Acquires and associates a public IP to an account.", responseObject=IPAddressResponse.class)
@ -160,7 +159,7 @@ public class AssociateIPAddrCmd extends BaseAsyncCreateCmd {
@Override
public void create() throws ResourceAllocationException{
try {
IpAddress ip = _networkService.allocateIP(this);
IpAddress ip = _networkService.allocateIP(getNetworkId(), _accountService.getAccount(getEntityOwnerId()));
if (ip != null) {
this.setEntityId(ip.getId());
} else {
@ -178,7 +177,7 @@ public class AssociateIPAddrCmd extends BaseAsyncCreateCmd {
@Override
public void execute() throws ResourceUnavailableException, ResourceAllocationException, ConcurrentOperationException, InsufficientCapacityException {
UserContext.current().setEventDetails("Ip Id: "+getEntityId());
UserContext.current().setEventDetails("Ip Id: " + getEntityId());
IpAddress result = _networkService.associateIP(this);
if (result != null) {
IPAddressResponse ipResponse = _responseGenerator.createIPAddressResponse(result);

View File

@ -170,23 +170,11 @@ public class ListPublicIpAddressesCmd extends BaseListCmd {
return allocatedOnly;
}
public void setAllocatedOnly(Boolean allocatedOnly) {
this.allocatedOnly = allocatedOnly;
}
public Boolean getForVirtualNetwork() {
return forVirtualNetwork;
}
public void setForVirtualNetwork(Boolean forVirtualNetwork) {
this.forVirtualNetwork = forVirtualNetwork;
}
public Boolean getForLoadBalancing() {
return forLoadBalancing;
}
public void setForLoadBalancing(Boolean forLoadBalancing) {
this.forLoadBalancing = forLoadBalancing;
}
}

View File

@ -75,6 +75,9 @@ public class RegisterTemplateCmd extends BaseCmd {
@Parameter(name=ApiConstants.PASSWORD_ENABLED, type=CommandType.BOOLEAN, description="true if the template supports the password reset feature; default is false")
private Boolean passwordEnabled;
@Parameter(name=ApiConstants.SSHKEY_ENABLED, type=CommandType.BOOLEAN, description="true if the template supports the sshkey upload feature; default is false")
private Boolean sshKeyEnabled;
@Parameter(name=ApiConstants.IS_EXTRACTABLE, type=CommandType.BOOLEAN, description="true if the template or its derivatives are extractable; default is false")
private Boolean extractable;
@ -148,6 +151,10 @@ public class RegisterTemplateCmd extends BaseCmd {
public Boolean isPasswordEnabled() {
return passwordEnabled;
}
public Boolean isSshKeyEnabled() {
return sshKeyEnabled;
}
public Boolean isExtractable() {
return extractable;

View File

@ -1,4 +1,5 @@
/**
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
*
* This software is licensed under the GNU General Public License v3 or later.
@ -44,4 +45,5 @@ public interface Event extends ControlledEntity{
String getLevel();
long getStartId();
String getParameters();
String getAccountType();
}

View File

@ -41,7 +41,7 @@ public interface NetworkService {
List<? extends Network> getIsolatedNetworksOwnedByAccountInZone(long zoneId, Account owner);
IpAddress allocateIP(AssociateIPAddrCmd cmd) throws ResourceAllocationException, InsufficientAddressCapacityException, ConcurrentOperationException;
IpAddress allocateIP(long networkId, Account ipOwner) throws ResourceAllocationException, InsufficientAddressCapacityException, ConcurrentOperationException;
/**
* Associates a public IP address for a router.

View File

@ -64,6 +64,8 @@ public interface VirtualMachineTemplate extends ControlledEntity {
String getDisplayText();
boolean getEnablePassword();
boolean getEnableSshKey();
boolean isCrossZones();

View File

@ -69,7 +69,10 @@ public class EventVO implements Event, Identity {
private long domainId;
@Column(name="account_name", table="account", insertable=false, updatable=false)
private String accountName;
private String accountName;
@Column(name="type", table="account", insertable=false, updatable=false)
private String accountType;
@Column(name="removed", table="account", insertable=false, updatable=false)
private Date removed;
@ -148,16 +151,12 @@ public class EventVO implements Event, Identity {
public long getDomainId() {
return domainId;
}
public void setDomainId(long domainId) {
this.domainId = domainId;
}
@Override
public String getAccountName() {
return accountName;
}
public void setAccountName(String accountName) {
this.accountName = accountName;
}
}
@Override
public int getTotalSize() {
return totalSize;
@ -196,5 +195,11 @@ public class EventVO implements Event, Identity {
public void setUuid(String uuid) {
this.uuid = uuid;
}
}
@Override
public String getAccountType() {
return accountType;
}
}

View File

@ -38,6 +38,7 @@ import com.cloud.agent.api.BackupSnapshotCommand;
import com.cloud.agent.api.BumpUpPriorityCommand;
import com.cloud.agent.api.CheckHealthAnswer;
import com.cloud.agent.api.CheckHealthCommand;
import com.cloud.agent.api.CheckNetworkAnswer;
import com.cloud.agent.api.CheckNetworkCommand;
import com.cloud.agent.api.CheckOnHostAnswer;
import com.cloud.agent.api.CheckOnHostCommand;
@ -395,7 +396,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
} else if (cmd instanceof GetDomRVersionCmd) {
answer = execute((GetDomRVersionCmd)cmd);
} else if (cmd instanceof CheckNetworkCommand) {
//answer = execute((CheckNetworkCommand) cmd);
answer = execute((CheckNetworkCommand) cmd);
} else {
answer = Answer.createUnsupportedCommandAnswer(cmd);
}
@ -433,6 +434,15 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
s_logger.trace("End executeRequest(), cmd: " + cmd.getClass().getSimpleName());
return answer;
}
protected Answer execute(CheckNetworkCommand cmd) {
if (s_logger.isInfoEnabled()) {
s_logger.info("Executing resource CheckNetworkCommand " + _gson.toJson(cmd));
}
// TODO setup portgroup for private network needs to be done here now
return new CheckNetworkAnswer(cmd, true , "Network Setup check by names is done");
}
protected Answer execute(NetworkUsageCommand cmd) {

View File

@ -124,7 +124,10 @@ public class VMTemplateVO implements VirtualMachineTemplate, Identity {
private String uuid;
@Column(name="sort_key")
int sortKey;
private int sortKey;
@Column(name="enable_sshkey")
private boolean enableSshKey;
@Transient
Map details;
@ -150,10 +153,11 @@ public class VMTemplateVO implements VirtualMachineTemplate, Identity {
this.uuid = UUID.randomUUID().toString();
}
public VMTemplateVO(long id, String name, ImageFormat format, boolean isPublic, boolean featured, boolean isExtractable, TemplateType type, String url, boolean requiresHvm, int bits, long accountId, String cksum, String displayText, boolean enablePassword, long guestOSId, boolean bootable, HypervisorType hyperType, String templateTag, Map details) {
public VMTemplateVO(long id, String name, ImageFormat format, boolean isPublic, boolean featured, boolean isExtractable, TemplateType type, String url, boolean requiresHvm, int bits, long accountId, String cksum, String displayText, boolean enablePassword, long guestOSId, boolean bootable, HypervisorType hyperType, String templateTag, Map details, Boolean sshKeyEnabled) {
this(id, name, format, isPublic, featured, isExtractable, type, url, requiresHvm, bits, accountId, cksum, displayText, enablePassword, guestOSId, bootable, hyperType, details);
this.templateTag = templateTag;
this.uuid = UUID.randomUUID().toString();
this.enableSshKey = sshKeyEnabled;
}
public VMTemplateVO(Long id, String uniqueName, String name, ImageFormat format, boolean isPublic, boolean featured, TemplateType type, String url, Date created, boolean requiresHvm, int bits, long accountId, String cksum, String displayText, boolean enablePassword, long guestOSId, boolean bootable, HypervisorType hyperType) {
@ -456,5 +460,14 @@ public class VMTemplateVO implements VirtualMachineTemplate, Identity {
public int getSortKey() {
return sortKey;
}
@Override
public boolean getEnableSshKey() {
return enableSshKey;
}
public void setEnableSshKey(boolean enable) {
enableSshKey = enable;
}
}

View File

@ -1,9 +1,9 @@
#!/bin/bash
# $Id: installrtng.sh 11251 2010-07-23 23:40:44Z abhishek $ $HeadURL: svn://svn.lab.vmops.com/repos/vmdev/java/scripts/storage/secondary/installrtng.sh $
usage() {
printf "Usage: %s: -m <secondary storage mount point> -f <system vm template file> [-h <hypervisor name: kvm|vmware|xenserver>]\n" $(basename $0) >&2
printf "Usage: %s: -m <secondary storage mount point> -f <system vm template file> [-h <hypervisor name: kvm|vmware|xenserver> -s <mgmt server secret key>]\n" $(basename $0) >&2
printf "or\n" >&2
printf "%s: -m <secondary storage mount point> -u <http url for system vm template> [-h <hypervisor name: kvm|vmware|xenserver>]\n" $(basename $0) >&2
printf "%s: -m <secondary storage mount point> -u <http url for system vm template> [-h <hypervisor name: kvm|vmware|xenserver> -s <mgmt server secret key>]\n" $(basename $0) >&2
}
failed() {
@ -16,8 +16,9 @@ fflag=
ext="vhd"
templateId=1
hyper=
msKey=password
DISKSPACE=5120000 #free disk space required in kilobytes
while getopts 'm:h:f:u:Ft:e:' OPTION
while getopts 'm:h:f:u:Ft:e:s:' OPTION
do
case $OPTION in
m) mflag=1
@ -36,6 +37,9 @@ do
;;
h) hyper="$OPTARG"
;;
s) sflag=1
msKey="$OPTARG"
;;
?) usage
failed 2
;;
@ -68,7 +72,13 @@ fi
dbHost=$(sed '/^\#/d' /etc/cloud/management/db.properties | grep 'db.cloud.host' | tail -n 1 | cut -d "=" -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
dbUser=$(sed '/^\#/d' /etc/cloud/management/db.properties | grep 'db.cloud.username' | tail -n 1 | cut -d "=" -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
dbPassword=$(sed '/^\#/d' /etc/cloud/management/db.properties | grep 'db.cloud.password' | tail -n 1 | cut -d "=" -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
if [ "$sflag" == "1" ]
then
encPassword=$(sed '/^\#/d' /etc/cloud/management/db.properties | grep 'db.cloud.password' | tail -n 1 | cut -d "=" -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//'i | sed 's/^ENC(\(.*\))/\1/')
dbPassword=(`java -classpath /usr/share/java/cloud-jasypt-1.8.jar org.jasypt.intf.cli.JasyptPBEStringDecryptionCLI decrypt.sh input=$encPassword password=$msKey verbose=false`)
else
dbPassword=$(sed '/^\#/d' /etc/cloud/management/db.properties | grep 'db.cloud.password' | tail -n 1 | cut -d "=" -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//'i )
fi
if [ "$hyper" == "kvm" ]
then
@ -87,6 +97,12 @@ else
failed 2
fi
if [ ! $templateId ]
then
echo "Unable to get template Id from database"
failed 8
fi
localfile=$(uuidgen).$ext
mntpoint=`echo "$mntpoint" | sed 's|/*$||'`

View File

@ -239,11 +239,12 @@ def default_network_rules_systemvm(vm_name, brname):
try:
execute("iptables -A " + brfw + "-OUT" + " -m physdev --physdev-is-bridged --physdev-out " + vif + " -j " + vmchain)
execute("iptables -A " + brfw + "-IN" + " -m physdev --physdev-is-bridged --physdev-in " + vif + " -j " + vmchain)
execute("iptables -A " + vmchain + " -m physdev --physdev-is-bridged --physdev-in " + vif + " -j RETURN")
except:
logging.debug("Failed to program default rules")
return 'false'
execute("iptables -A " + vmchain + " -j RETURN")
execute("iptables -A " + vmchain + " -j ACCEPT")
if write_rule_log_for_vm(vm_name, '-1', '_ignore_', domid, '_initial_', '-1') == False:
logging.debug("Failed to log default network rules for systemvm, ignoring")
@ -617,13 +618,14 @@ def add_network_rules(vm_name, vm_id, vm_ip, signature, seqno, vmMac, rules, vif
ips = cidrs.split(",")
ips.pop()
allow_any = False
action = "RETURN"
if ruletype == 'E':
vmchain = egress_chain_name(vm_name)
direction = "-d"
action = "RETURN"
egressrule = egressrule + 1
else:
vmchain = vm_name
action = "ACCEPT"
direction = "-s"
if '0.0.0.0/0' in ips:
i = ips.index('0.0.0.0/0')
@ -730,8 +732,8 @@ def addFWFramework(brname):
execute("iptables -I FORWARD -o " + brname + " -m physdev --physdev-is-bridged -j " + brfw)
phydev = execute("brctl show |grep " + brname + " | awk '{print $4}'").strip()
execute("iptables -A " + brfw + " -m state --state RELATED,ESTABLISHED -j ACCEPT")
execute("iptables -A " + brfw + " -m physdev --physdev-is-bridged --physdev-is-out -j " + brfwout)
execute("iptables -A " + brfw + " -m physdev --physdev-is-bridged --physdev-is-in -j " + brfwin)
execute("iptables -A " + brfw + " -m physdev --physdev-is-bridged --physdev-is-out -j " + brfwout)
execute("iptables -A " + brfw + " -m physdev --physdev-is-bridged --physdev-out " + phydev + " -j ACCEPT")

View File

@ -288,7 +288,7 @@ public class ApiDBUtils {
}
public static List<UserVmVO> searchForUserVMs(Criteria c) {
return _userVmMgr.searchForUserVMs(c);
return _userVmMgr.searchForUserVMs(c, true);
}
public static List<? extends StoragePoolVO> searchForStoragePools(Criteria c) {

View File

@ -634,50 +634,26 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
@Override
@DB
@ActionEvent(eventType = EventTypes.EVENT_NET_IP_ASSIGN, eventDescription = "allocating Ip", create = true)
public IpAddress allocateIP(AssociateIPAddrCmd cmd) throws ResourceAllocationException, InsufficientAddressCapacityException, ConcurrentOperationException {
String accountName = cmd.getAccountName();
long domainId = cmd.getDomainId();
Long zoneId = cmd.getZoneId();
public IpAddress allocateIP(long networkId, Account ipOwner) throws ResourceAllocationException, InsufficientAddressCapacityException, ConcurrentOperationException {
Account caller = UserContext.current().getCaller();
long userId = UserContext.current().getCallerUserId();
Account ipOwner = _accountMgr.getActiveAccountByName(accountName, domainId);
if (ipOwner == null) {
throw new InvalidParameterValueException("Unable to find account " + accountName + " in domain " + domainId + ", permission denied");
}
_accountMgr.checkAccess(caller, null, ipOwner);
DataCenterVO zone = null;
if (zoneId != null) {
zone = _dcDao.findById(zoneId);
if (zone == null) {
throw new InvalidParameterValueException("Can't find zone by id " + zoneId);
}
if (zone.getNetworkType() == NetworkType.Basic) {
throw new InvalidParameterValueException("Can't associate ip in basic zone");
}
if (Grouping.AllocationState.Disabled == zone.getAllocationState() && !_accountMgr.isRootAdmin(caller.getType())) {
throw new PermissionDeniedException("Cannot perform this operation, Zone is currently disabled: " + zoneId);
}
}
long ownerId = ipOwner.getId();
Long networkId = cmd.getNetworkId();
Network network = null;
if (networkId != null) {
network = _networksDao.findById(networkId);
if (network == null) {
throw new InvalidParameterValueException("Network id is invalid: " + networkId);
}
Network network = _networksDao.findById(networkId);
if (network == null) {
throw new InvalidParameterValueException("Network id is invalid: " + networkId);
}
DataCenter zone = _configMgr.getZone(network.getDataCenterId());
// Check that network belongs to IP owner - skip this check for Basic zone as there is just one guest network, and it
// belongs to the system
if (zone.getNetworkType() != NetworkType.Basic && network.getAccountId() != ipOwner.getId()) {
throw new InvalidParameterValueException("The owner of the network is not the same as owner of the IP");
}
VlanType vlanType = VlanType.VirtualNetwork;
boolean assign = false;
//For basic zone, if there isn't a public network outside of the guest network, specify the vlan type to be direct attached
@ -686,9 +662,12 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
vlanType = VlanType.DirectAttached;
assign = true;
}
}
if (Grouping.AllocationState.Disabled == zone.getAllocationState() && !_accountMgr.isRootAdmin(caller.getType())) {
throw new PermissionDeniedException("Cannot perform this operation, Zone is currently disabled: " + zone.getId());
}
PublicIp ip = null;
Transaction txn = Transaction.currentTxn();
@ -726,17 +705,17 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
if (!sharedSourceNat) {
// First IP address should be source nat when it's being associated with Guest Virtual network
List<IPAddressVO> addrs = listPublicIpAddressesInVirtualNetwork(ownerId, zoneId, true, networkId);
List<IPAddressVO> addrs = listPublicIpAddressesInVirtualNetwork(ownerId, zone.getId(), true, networkId);
if (addrs.isEmpty() && network.getGuestType() == Network.GuestType.Isolated) {
isSourceNat = true;
}
}
ip = fetchNewPublicIp(zoneId, null, null, ipOwner, vlanType, network.getId(), isSourceNat, assign, null);
ip = fetchNewPublicIp(zone.getId(), null, null, ipOwner, vlanType, network.getId(), isSourceNat, assign, null);
if (ip == null) {
throw new InsufficientAddressCapacityException("Unable to find available public IP addresses", DataCenter.class, zoneId);
throw new InsufficientAddressCapacityException("Unable to find available public IP addresses", DataCenter.class, zone.getId());
}
UserContext.current().setEventDetails("Ip Id: " + ip.getId());
Ip ipAddress = ip.getAddress();

View File

@ -145,6 +145,9 @@ public class NetworkVO implements Network, Identity {
@Enumerated(value=EnumType.STRING)
ControlledEntity.ACLType aclType;
@Column(name="specified_cidr")
boolean specifiedCidr;
public NetworkVO() {
this.uuid = UUID.randomUUID().toString();
}
@ -221,6 +224,7 @@ public class NetworkVO implements Network, Identity {
this.networkDomain = networkDomain;
this.uuid = UUID.randomUUID().toString();
this.guestType = guestType;
this.specifiedCidr = false;
}
@Override
@ -470,4 +474,12 @@ public class NetworkVO implements Network, Identity {
return aclType;
}
public boolean isSpecifiedCidr() {
return specifiedCidr;
}
public void setSpecifiedCidr(boolean specifiedCidr) {
this.specifiedCidr = specifiedCidr;
}
}

View File

@ -39,6 +39,7 @@ import com.cloud.network.Network.State;
import com.cloud.network.NetworkManager;
import com.cloud.network.NetworkVO;
import com.cloud.network.Networks.BroadcastDomainType;
import com.cloud.network.Networks.TrafficType;
import com.cloud.network.PhysicalNetworkVO;
import com.cloud.network.dao.NetworkDao;
import com.cloud.network.dao.PhysicalNetworkDao;
@ -88,7 +89,8 @@ public class ExternalGuestNetworkGuru extends GuestNetworkGuru {
NetworkVO config = (NetworkVO) super.design(offering, plan, userSpecified, owner);
if (config == null) {
return null;
} else if (_networkMgr.networkIsConfiguredForExternalNetworking(plan.getDataCenterId(), config.getId())) {
} else {
/* In order to revert userSpecified network setup */
config.setState(State.Allocated);
}
@ -103,10 +105,6 @@ public class ExternalGuestNetworkGuru extends GuestNetworkGuru {
return null;
}
if (!_networkMgr.networkIsConfiguredForExternalNetworking(config.getDataCenterId(), config.getId())) {
return super.implement(config, offering, dest, context);
}
DataCenter zone = dest.getDataCenter();
NetworkVO implemented = new NetworkVO(config.getTrafficType(), config.getMode(), config.getBroadcastDomainType(), config.getNetworkOfferingId(), State.Allocated,
config.getDataCenterId(), config.getPhysicalNetworkId());
@ -199,7 +197,7 @@ public class ExternalGuestNetworkGuru extends GuestNetworkGuru {
public NicProfile allocate(Network config, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm) throws InsufficientVirtualNetworkCapcityException,
InsufficientAddressCapacityException {
if (_networkMgr.networkIsConfiguredForExternalNetworking(config.getDataCenterId(), config.getId()) && nic != null && nic.getRequestedIp() != null) {
if (nic != null && nic.getRequestedIp() != null) {
throw new CloudRuntimeException("Does not support custom ip allocation at this time: " + nic);
}
@ -209,12 +207,11 @@ public class ExternalGuestNetworkGuru extends GuestNetworkGuru {
return null;
}
if (_networkMgr.networkIsConfiguredForExternalNetworking(config.getDataCenterId(), config.getId())) {
profile.setStrategy(ReservationStrategy.Start);
profile.setIp4Address(null);
profile.setGateway(null);
profile.setNetmask(null);
}
profile.setStrategy(ReservationStrategy.Start);
profile.setGateway(null);
profile.setNetmask(null);
/* We won't clear IP address, because router may set gateway as it IP, and it would be updated properly later */
//profile.setIp4Address(null);
return profile;
}
@ -227,13 +224,11 @@ public class ExternalGuestNetworkGuru extends GuestNetworkGuru {
return;
}
if (_networkMgr.networkIsConfiguredForExternalNetworking(config.getDataCenterId(), config.getId())) {
nic.setIp4Address(null);
nic.setGateway(null);
nic.setNetmask(null);
nic.setBroadcastUri(null);
nic.setIsolationUri(null);
}
nic.setIp4Address(null);
nic.setGateway(null);
nic.setNetmask(null);
nic.setBroadcastUri(null);
nic.setIsolationUri(null);
}
@Override
@ -244,30 +239,26 @@ public class ExternalGuestNetworkGuru extends GuestNetworkGuru {
return;
}
DataCenter dc = _dcDao.findById(config.getDataCenterId());
if (_networkMgr.networkIsConfiguredForExternalNetworking(config.getDataCenterId(), config.getId())) {
nic.setBroadcastUri(config.getBroadcastUri());
nic.setIsolationUri(config.getBroadcastUri());
nic.setDns1(dc.getDns1());
nic.setDns2(dc.getDns2());
nic.setNetmask(NetUtils.cidr2Netmask(config.getCidr()));
long cidrAddress = NetUtils.ip2Long(config.getCidr().split("/")[0]);
int cidrSize = getGloballyConfiguredCidrSize();
nic.setGateway(config.getGateway());
nic.setBroadcastUri(config.getBroadcastUri());
nic.setIsolationUri(config.getBroadcastUri());
nic.setDns1(dc.getDns1());
nic.setDns2(dc.getDns2());
nic.setNetmask(NetUtils.cidr2Netmask(config.getCidr()));
long cidrAddress = NetUtils.ip2Long(config.getCidr().split("/")[0]);
int cidrSize = getGloballyConfiguredCidrSize();
nic.setGateway(config.getGateway());
if (nic.getIp4Address() == null) {
String guestIp = _networkMgr.acquireGuestIpAddress(config, null);
if (guestIp == null) {
throw new InsufficientVirtualNetworkCapcityException("Unable to acquire guest IP address for network " + config, DataCenter.class, dc.getId());
}
nic.setIp4Address(guestIp);
} else {
long ipMask = NetUtils.ip2Long(nic.getIp4Address()) & ~(0xffffffffffffffffl << (32 - cidrSize));
nic.setIp4Address(NetUtils.long2Ip(cidrAddress | ipMask));
if (nic.getIp4Address() == null) {
String guestIp = _networkMgr.acquireGuestIpAddress(config, null);
if (guestIp == null) {
throw new InsufficientVirtualNetworkCapcityException("Unable to acquire guest IP address for network " + config, DataCenter.class, dc.getId());
}
nic.setIp4Address(guestIp);
} else {
super.reserve(nic, config, vm, dest, context);
long ipMask = NetUtils.ip2Long(nic.getIp4Address()) & ~(0xffffffffffffffffl << (32 - cidrSize));
nic.setIp4Address(NetUtils.long2Ip(cidrAddress | ipMask));
}
}
@ -278,7 +269,8 @@ public class ExternalGuestNetworkGuru extends GuestNetworkGuru {
}
NetworkVO network = _networkDao.findById(nic.getNetworkId());
if (network != null && _networkMgr.networkIsConfiguredForExternalNetworking(network.getDataCenterId(), network.getId())) {
if (network != null) {
return true;
} else {
return super.release(nic, vm, reservationId);

View File

@ -125,13 +125,12 @@ public class GuestNetworkGuru extends AdapterBase implements NetworkGuru {
network.setBroadcastUri(userSpecified.getBroadcastUri());
network.setState(State.Setup);
}
network.setSpecifiedCidr(true);
} else {
String guestNetworkCidr = dc.getGuestNetworkCidr();
String[] cidrTuple = guestNetworkCidr.split("\\/");
network.setGateway(NetUtils.getIpRangeStartIpFromCidr(cidrTuple[0], Long.parseLong(cidrTuple[1])));
network.setCidr(guestNetworkCidr);
;
}
return network;

View File

@ -1427,51 +1427,56 @@ public class ManagementServerImpl implements ManagementServer {
String accountName = cmd.getAccountName();
Long domainId = cmd.getDomainId();
Long projectId = cmd.getProjectId();
if ((caller == null) || isAdmin(caller.getType())) {
if (_accountMgr.isAdmin(caller.getType())) {
isAdmin = true;
// validate domainId before proceeding
if (domainId != null) {
if ((caller != null) && !_domainDao.isChildDomain(caller.getDomainId(), domainId)) {
throw new PermissionDeniedException("Invalid domain id (" + domainId + ") given, unable to list events.");
}
Domain domain = _domainDao.findById(domainId);
if (domain == null) {
throw new InvalidParameterValueException("Unable to find domain by id " + domainId);
}
_accountMgr.checkAccess(caller, _domainDao.findById(domainId));
if (accountName != null) {
Account userAccount = _accountDao.findAccount(accountName, domainId);
if (userAccount != null) {
permittedAccounts.add(userAccount.getId());
} else {
throw new InvalidParameterValueException("Unable to find account " + accountName + " in domain " + domainId);
}
}
} else {
domainId = ((caller == null) ? DomainVO.ROOT_DOMAIN : caller.getDomainId());
if (accountName != null) {
Account userAccount = _accountDao.findAccount(accountName, domainId);
if (userAccount != null) {
permittedAccounts.add(userAccount.getId());
} else {
throw new InvalidParameterValueException("DomainId is not specified. Unable to find account " + accountName + " in default root domain " + domainId);
Account userAccount = _accountDao.findNonProjectAccountIncludingRemoved(accountName, domainId);
if (userAccount == null) {
throw new InvalidParameterValueException("Unable to find account " + accountName + " in domain " + domainId);
}
permittedAccounts.add(userAccount.getId());
}
} else {
domainId = caller.getDomainId();
if (accountName != null) {
Account userAccount = _accountDao.findNonProjectAccountIncludingRemoved(accountName, domainId);
if (userAccount == null) {
throw new InvalidParameterValueException("Can't find account " + accountName + " in domain id=" + domainId);
}
permittedAccounts.add(userAccount.getId());
}
}
} else {
permittedAccounts.add(caller.getId());
}
//set project information
boolean skipProjectEvents = true;
if (projectId != null) {
permittedAccounts.clear();
Project project = _projectMgr.getProject(projectId);
if (project == null) {
throw new InvalidParameterValueException("Unable to find project by id " + projectId);
}
if (!_projectMgr.canAccessProjectAccount(caller, project.getProjectAccountId())) {
throw new InvalidParameterValueException("Account " + caller + " can't access project id=" + projectId);
}
permittedAccounts.add(project.getProjectAccountId());
} else if (caller.getType() == Account.ACCOUNT_TYPE_NORMAL){
permittedAccounts.addAll(_projectMgr.listPermittedProjectAccounts(caller.getId()));
if (projectId == -1) {
permittedAccounts.addAll(_projectMgr.listPermittedProjectAccounts(caller.getId()));
} else {
permittedAccounts.clear();
Project project = _projectMgr.getProject(projectId);
if (project == null) {
throw new InvalidParameterValueException("Unable to find project by id " + projectId);
}
if (!_projectMgr.canAccessProjectAccount(caller, project.getProjectAccountId())) {
throw new InvalidParameterValueException("Account " + caller + " can't access project id=" + projectId);
}
permittedAccounts.add(project.getProjectAccountId());
}
skipProjectEvents = false;
}
Filter searchFilter = new Filter(EventVO.class, "createDate", false, cmd.getStartIndex(), cmd.getPageSizeVal());
@ -1503,24 +1508,35 @@ public class ManagementServerImpl implements ManagementServer {
sb.and("createDateB", sb.entity().getCreateDate(), SearchCriteria.Op.BETWEEN);
sb.and("createDateG", sb.entity().getCreateDate(), SearchCriteria.Op.GTEQ);
sb.and("createDateL", sb.entity().getCreateDate(), SearchCriteria.Op.LTEQ);
sb.and("accountType", sb.entity().getAccountType(), SearchCriteria.Op.NEQ);
if ((permittedAccounts.isEmpty()) && (accountName == null) && (domainId != null) && isAdmin) {
// if accountId isn't specified, we can do a domain match for the admin case
SearchBuilder<DomainVO> domainSearch = _domainDao.createSearchBuilder();
domainSearch.and("path", domainSearch.entity().getPath(), SearchCriteria.Op.LIKE);
sb.join("domainSearch", domainSearch, sb.entity().getDomainId(), domainSearch.entity().getId(), JoinBuilder.JoinType.INNER);
if (isAdmin && permittedAccounts.isEmpty() && domainId != null) {
// if accountId isn't specified, we can do a domain match for the admin case
SearchBuilder<DomainVO> domainSearch = _domainDao.createSearchBuilder();
domainSearch.and("path", domainSearch.entity().getPath(), SearchCriteria.Op.LIKE);
sb.join("domainSearch", domainSearch, sb.entity().getDomainId(), domainSearch.entity().getId(), JoinBuilder.JoinType.INNER);
}
SearchCriteria<EventVO> sc = sb.create();
if (!permittedAccounts.isEmpty()) {
sc.setParameters("accountId", permittedAccounts.toArray());
} else if (domainId != null) {
sc.setJoinParameters("domainSearch", "path", _domainDao.findById(domainId).getPath() + "%");
}
if (skipProjectEvents) {
sc.setParameters("accountType", Account.ACCOUNT_TYPE_PROJECT);
}
if (id != null) {
sc.setParameters("id", id);
}
if (keyword != null) {
SearchCriteria<EventVO> ssc = _eventDao.createSearchCriteria();
ssc.addOr("type", SearchCriteria.Op.LIKE, "%" + keyword + "%");
ssc.addOr("description", SearchCriteria.Op.LIKE, "%" + keyword + "%");
ssc.addOr("level", SearchCriteria.Op.LIKE, "%" + keyword + "%");
sc.addAnd("level", SearchCriteria.Op.SC, ssc);
}
@ -1528,18 +1544,6 @@ public class ManagementServerImpl implements ManagementServer {
sc.setParameters("levelEQ", level);
}
if (!permittedAccounts.isEmpty()) {
sc.setParameters("accountId", permittedAccounts.toArray());
} else if (domainId != null) {
if (accountName != null) {
sc.setParameters("domainIdEQ", domainId);
sc.setParameters("accountName", "%" + accountName + "%");
} else if (isAdmin) {
DomainVO domain = _domainDao.findById(domainId);
sc.setJoinParameters("domainSearch", "path", domain.getPath() + "%");
}
}
if (type != null) {
sc.setParameters("type", type);
}
@ -1904,8 +1908,22 @@ public class ManagementServerImpl implements ManagementServer {
vlanSearch.and("vlanType", vlanSearch.entity().getVlanType(), SearchCriteria.Op.EQ);
sb.join("vlanSearch", vlanSearch, sb.entity().getVlanId(), vlanSearch.entity().getId(), JoinBuilder.JoinType.INNER);
boolean allocatedOnly = false;
if ((isAllocated != null) && (isAllocated == true)) {
sb.and("allocated", sb.entity().getAllocatedTime(), SearchCriteria.Op.NNULL);
allocatedOnly = true;
}
VlanType vlanType = null;
if (forVirtualNetwork != null) {
vlanType = (Boolean) forVirtualNetwork ? VlanType.VirtualNetwork : VlanType.DirectAttached;
} else {
vlanType = VlanType.VirtualNetwork;
}
//don't show SSVM/CPVM ips
if (vlanType == VlanType.VirtualNetwork && (allocatedOnly)) {
sb.and("associatedNetworkId", sb.entity().getAssociatedWithNetworkId(), SearchCriteria.Op.NNULL);
}
SearchCriteria<IPAddressVO> sc = sb.create();
@ -1916,13 +1934,6 @@ public class ManagementServerImpl implements ManagementServer {
sc.setJoinParameters("domainSearch", "path", domain.getPath() + "%");
}
VlanType vlanType = null;
if (forVirtualNetwork != null) {
vlanType = (Boolean) forVirtualNetwork ? VlanType.VirtualNetwork : VlanType.DirectAttached;
} else {
vlanType = VlanType.VirtualNetwork;
}
sc.setJoinParameters("vlanSearch", "vlanType", vlanType);
if (zone != null) {

2
server/src/com/cloud/template/TemplateAdapter.java Normal file → Executable file
View File

@ -48,5 +48,5 @@ public interface TemplateAdapter extends Adapter {
public TemplateProfile prepare(boolean isIso, Long userId, String name, String displayText, Integer bits,
Boolean passwordEnabled, Boolean requiresHVM, String url, Boolean isPublic, Boolean featured,
Boolean isExtractable, String format, Long guestOSId, Long zoneId, HypervisorType hypervisorType,
String chksum, Boolean bootable, String templateTag, Account templateOwner, Map details) throws ResourceAllocationException;
String chksum, Boolean bootable, String templateTag, Account templateOwner, Map details, Boolean sshKeyEnabled) throws ResourceAllocationException;
}

View File

@ -93,12 +93,13 @@ public abstract class TemplateAdapterBase implements TemplateAdapter {
Boolean isExtractable, String format, Long guestOSId, Long zoneId, HypervisorType hypervisorType,
String accountName, Long domainId, String chksum, Boolean bootable, Map details) throws ResourceAllocationException {
return prepare(isIso, userId, name, displayText, bits, passwordEnabled, requiresHVM, url, isPublic, featured, isExtractable, format, guestOSId, zoneId, hypervisorType,
chksum, bootable, null, null, details);
chksum, bootable, null, null, details, false);
}
public TemplateProfile prepare(boolean isIso, Long userId, String name, String displayText, Integer bits,
Boolean passwordEnabled, Boolean requiresHVM, String url, Boolean isPublic, Boolean featured,
Boolean isExtractable, String format, Long guestOSId, Long zoneId, HypervisorType hypervisorType,
String chksum, Boolean bootable, String templateTag, Account templateOwner, Map details) throws ResourceAllocationException {
String chksum, Boolean bootable, String templateTag, Account templateOwner, Map details, Boolean sshkeyEnabled) throws ResourceAllocationException {
//Long accountId = null;
// parameters verification
@ -201,7 +202,7 @@ public abstract class TemplateAdapterBase implements TemplateAdapter {
Long id = _tmpltDao.getNextInSequence(Long.class, "id");
UserContext.current().setEventDetails("Id: " +id+ " name: " + name);
return new TemplateProfile(id, userId, name, displayText, bits, passwordEnabled, requiresHVM, url, isPublic,
featured, isExtractable, imgfmt, guestOSId, zoneId, hypervisorType, templateOwner.getAccountName(), templateOwner.getDomainId(), templateOwner.getAccountId(), chksum, bootable, templateTag, details);
featured, isExtractable, imgfmt, guestOSId, zoneId, hypervisorType, templateOwner.getAccountName(), templateOwner.getDomainId(), templateOwner.getAccountId(), chksum, bootable, templateTag, details, sshkeyEnabled);
}
@Override
@ -214,7 +215,7 @@ public abstract class TemplateAdapterBase implements TemplateAdapter {
return prepare(false, UserContext.current().getCallerUserId(), cmd.getTemplateName(), cmd.getDisplayText(),
cmd.getBits(), cmd.isPasswordEnabled(), cmd.getRequiresHvm(), cmd.getUrl(), cmd.isPublic(), cmd.isFeatured(),
cmd.isExtractable(), cmd.getFormat(), cmd.getOsTypeId(), cmd.getZoneId(), HypervisorType.getType(cmd.getHypervisor()),
cmd.getChecksum(), true, cmd.getTemplateTag(), owner, cmd.getDetails());
cmd.getChecksum(), true, cmd.getTemplateTag(), owner, cmd.getDetails(), cmd.isSshKeyEnabled());
}
public TemplateProfile prepare(RegisterIsoCmd cmd) throws ResourceAllocationException {
@ -225,7 +226,7 @@ public abstract class TemplateAdapterBase implements TemplateAdapter {
return prepare(true, UserContext.current().getCallerUserId(), cmd.getIsoName(), cmd.getDisplayText(), 64, false,
true, cmd.getUrl(), cmd.isPublic(), cmd.isFeatured(), cmd.isExtractable(), ImageFormat.ISO.toString(), cmd.getOsTypeId(),
cmd.getZoneId(), HypervisorType.None, cmd.getChecksum(), cmd.isBootable(), null, owner, null);
cmd.getZoneId(), HypervisorType.None, cmd.getChecksum(), cmd.isBootable(), null, owner, null, false);
}
protected VMTemplateVO persistTemplate(TemplateProfile profile) {
@ -234,7 +235,7 @@ public abstract class TemplateAdapterBase implements TemplateAdapter {
profile.getFeatured(), profile.getIsExtractable(), TemplateType.USER, profile.getUrl(), profile.getRequiresHVM(),
profile.getBits(), profile.getAccountId(), profile.getCheckSum(), profile.getDisplayText(),
profile.getPasswordEnabled(), profile.getGuestOsId(), profile.getBootable(), profile.getHypervisorType(), profile.getTemplateTag(),
profile.getDetails());
profile.getDetails(), profile.getSshKeyEnabled());
if (zoneId == null || zoneId == -1) {
List<DataCenterVO> dcs = _dcDao.listAll();

16
server/src/com/cloud/template/TemplateProfile.java Normal file → Executable file
View File

@ -12,6 +12,7 @@ public class TemplateProfile {
String displayText;
Integer bits;
Boolean passwordEnabled;
Boolean sshKeyEnbaled;
Boolean requiresHvm;
String url;
Boolean isPublic;
@ -33,7 +34,7 @@ public class TemplateProfile {
public TemplateProfile(Long templateId, Long userId, String name, String displayText, Integer bits, Boolean passwordEnabled, Boolean requiresHvm,
String url, Boolean isPublic, Boolean featured, Boolean isExtractable, ImageFormat format, Long guestOsId, Long zoneId,
HypervisorType hypervisorType, String accountName, Long domainId, Long accountId, String chksum, Boolean bootable, Map details) {
HypervisorType hypervisorType, String accountName, Long domainId, Long accountId, String chksum, Boolean bootable, Map details, Boolean sshKeyEnabled) {
this.templateId = templateId;
this.userId = userId;
this.name = name;
@ -55,6 +56,7 @@ public class TemplateProfile {
this.chksum = chksum;
this.bootable = bootable;
this.details = details;
this.sshKeyEnbaled = sshKeyEnabled;
}
public TemplateProfile(Long userId, VMTemplateVO template, Long zoneId) {
@ -65,9 +67,9 @@ public class TemplateProfile {
public TemplateProfile(Long templateId, Long userId, String name, String displayText, Integer bits, Boolean passwordEnabled, Boolean requiresHvm,
String url, Boolean isPublic, Boolean featured, Boolean isExtractable, ImageFormat format, Long guestOsId, Long zoneId,
HypervisorType hypervisorType, String accountName, Long domainId, Long accountId, String chksum, Boolean bootable, String templateTag, Map details) {
HypervisorType hypervisorType, String accountName, Long domainId, Long accountId, String chksum, Boolean bootable, String templateTag, Map details, Boolean sshKeyEnabled) {
this(templateId, userId, name, displayText, bits, passwordEnabled, requiresHvm, url, isPublic, featured, isExtractable, format, guestOsId, zoneId,
hypervisorType, accountName, domainId, accountId, chksum, bootable, details);
hypervisorType, accountName, domainId, accountId, chksum, bootable, details, sshKeyEnabled);
this.templateTag = templateTag;
}
@ -226,4 +228,12 @@ public class TemplateProfile {
public void setDetails(Map details) {
this.details = details;
}
public void setSshKeyEnabled(Boolean enabled) {
this.sshKeyEnbaled = enabled;
}
public Boolean getSshKeyEnabled() {
return this.sshKeyEnbaled;
}
}

View File

@ -683,7 +683,7 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag
checkAccess(UserContext.current().getCaller(), domain);
Account account = _accountDao.findNonDisabledAccount(accountName, domainId);
Account account = _accountDao.findEnabledAccount(accountName, domainId);
if (account == null || account.getType() == Account.ACCOUNT_TYPE_PROJECT) {
throw new InvalidParameterValueException("Unable to find account " + accountName + " in domain id=" + domainId + " to create user");
}
@ -1066,7 +1066,7 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag
if(accountId != null){
account = _accountDao.findById(accountId);
}else{
account = _accountDao.findAccount(accountName, domainId);
account = _accountDao.findEnabledAccount(accountName, domainId);
}
// Check if account exists
@ -1084,8 +1084,8 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag
checkAccess(UserContext.current().getCaller(), _domainMgr.getDomain(account.getDomainId()));
// check if the given account name is unique in this domain for updating
Account duplicateAcccount = _accountDao.findAccount(newAccountName, domainId);
if (duplicateAcccount != null && duplicateAcccount.getRemoved() == null && duplicateAcccount.getId() != account.getId()) {// allow
Account duplicateAcccount = _accountDao.findActiveAccount(newAccountName, domainId);
if (duplicateAcccount != null && duplicateAcccount.getId() != account.getId()) {// allow
// same
// account
// to
@ -1385,18 +1385,20 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag
//set project information
if (projectId != null) {
permittedAccounts.clear();
Project project = _projectMgr.getProject(projectId);
if (project == null) {
throw new InvalidParameterValueException("Unable to find project by id " + projectId);
}
if (!_projectMgr.canAccessProjectAccount(caller, project.getProjectAccountId())) {
throw new InvalidParameterValueException("Account " + caller + " can't access project id=" + projectId);
}
permittedAccounts.add(project.getProjectAccountId());
} else if (caller.getType() == Account.ACCOUNT_TYPE_NORMAL){
permittedAccounts.addAll(_projectMgr.listPermittedProjectAccounts(caller.getId()));
}
if (projectId == -1) {
permittedAccounts.addAll(_projectMgr.listPermittedProjectAccounts(caller.getId()));
} else {
permittedAccounts.clear();
Project project = _projectMgr.getProject(projectId);
if (project == null) {
throw new InvalidParameterValueException("Unable to find project by id " + projectId);
}
if (!_projectMgr.canAccessProjectAccount(caller, project.getProjectAccountId())) {
throw new InvalidParameterValueException("Account " + caller + " can't access project id=" + projectId);
}
permittedAccounts.add(project.getProjectAccountId());
}
}
return new Pair<List<Long>, Long>(permittedAccounts, domainId);
}

View File

@ -18,9 +18,9 @@
package com.cloud.user.dao;
import java.util.Date;
import java.util.List;
import java.util.Date;
import java.util.List;
import com.cloud.user.Account;
import com.cloud.user.AccountVO;
import com.cloud.user.User;
@ -31,17 +31,24 @@ import com.cloud.utils.db.GenericDao;
public interface AccountDao extends GenericDao<AccountVO, Long> {
Pair<User, Account> findUserAccountByApiKey(String apiKey);
List<AccountVO> findAccountsLike(String accountName);
Account findActiveAccount(String accountName, Long domainId);
Account findActiveAccountByName(String accountName);
Account findAccount(String accountName, Long domainId);
List<AccountVO> findActiveAccounts(Long maxAccountId, Filter filter);
List<AccountVO> findRecentlyDeletedAccounts(Long maxAccountId, Date earliestRemovedDate, Filter filter);
List<AccountVO> findNewAccounts(Long minAccountId, Filter filter);
List<AccountVO> findCleanupsForRemovedAccounts(Long domainId);
List<AccountVO> findAdminAccountsForDomain(Long domainId);
List<AccountVO> findCleanupsForRemovedAccounts(Long domainId);
List<AccountVO> findActiveAccountsForDomain(Long domain);
void markForCleanup(long accountId);
List<AccountVO> listAccounts(String accountName, Long domainId, Filter filter);
List<AccountVO> findCleanupsForDisabledAccounts();
Account findNonDisabledAccount(String accountName, Long domainId);
//return account only in enabled state
Account findEnabledAccount(String accountName, Long domainId);
Account findEnabledNonProjectAccount(String accountName, Long domainId);
//returns account even when it's removed
Account findAccountIncludingRemoved(String accountName, Long domainId);
Account findNonProjectAccountIncludingRemoved(String accountName, Long domainId);
//returns only non-removed account
Account findActiveAccount(String accountName, Long domainId);
Account findActiveNonProjectAccount(String accountName, Long domainId);
}

View File

@ -38,7 +38,6 @@ import com.cloud.utils.db.Filter;
import com.cloud.utils.db.GenericDaoBase;
import com.cloud.utils.db.SearchBuilder;
import com.cloud.utils.db.SearchCriteria;
import com.cloud.utils.db.SearchCriteria.Op;
import com.cloud.utils.db.Transaction;
@Local(value={AccountDao.class})
@ -49,16 +48,20 @@ public class AccountDaoImpl extends GenericDaoBase<AccountVO, Long> implements A
"FROM `cloud`.`user` u, `cloud`.`account` a " +
"WHERE u.account_id = a.id AND u.api_key = ? and u.removed IS NULL";
protected final SearchBuilder<AccountVO> AccountNameSearch;
protected final SearchBuilder<AccountVO> AllFieldsSearch;
protected final SearchBuilder<AccountVO> AccountTypeSearch;
protected final SearchBuilder<AccountVO> DomainAccountsSearch;
protected final SearchBuilder<AccountVO> CleanupForRemovedAccountsSearch;
protected final SearchBuilder<AccountVO> CleanupForDisabledAccountsSearch;
protected final SearchBuilder<AccountVO> CleanupForDisabledAccountsSearch;
protected final SearchBuilder<AccountVO> NonProjectAccountSearch;
protected AccountDaoImpl() {
AccountNameSearch = createSearchBuilder();
AccountNameSearch.and("accountName", AccountNameSearch.entity().getAccountName(), SearchCriteria.Op.EQ);
AccountNameSearch.done();
AllFieldsSearch = createSearchBuilder();
AllFieldsSearch.and("accountName", AllFieldsSearch.entity().getAccountName(), SearchCriteria.Op.EQ);
AllFieldsSearch.and("domainId", AllFieldsSearch.entity().getDomainId(), SearchCriteria.Op.EQ);
AllFieldsSearch.and("state", AllFieldsSearch.entity().getState(), SearchCriteria.Op.EQ);
AllFieldsSearch.and("type", AllFieldsSearch.entity().getType(), SearchCriteria.Op.EQ);
AllFieldsSearch.done();
AccountTypeSearch = createSearchBuilder();
AccountTypeSearch.and("domainId", AccountTypeSearch.entity().getDomainId(), SearchCriteria.Op.EQ);
@ -80,7 +83,14 @@ public class AccountDaoImpl extends GenericDaoBase<AccountVO, Long> implements A
CleanupForDisabledAccountsSearch.and("cleanup", CleanupForDisabledAccountsSearch.entity().getNeedsCleanup(), SearchCriteria.Op.EQ);
CleanupForDisabledAccountsSearch.and("removed", CleanupForDisabledAccountsSearch.entity().getRemoved(), SearchCriteria.Op.NULL);
CleanupForDisabledAccountsSearch.and("state", CleanupForDisabledAccountsSearch.entity().getState(), SearchCriteria.Op.EQ);
CleanupForDisabledAccountsSearch.done();
CleanupForDisabledAccountsSearch.done();
NonProjectAccountSearch = createSearchBuilder();
NonProjectAccountSearch.and("accountName", NonProjectAccountSearch.entity().getAccountName(), SearchCriteria.Op.EQ);
NonProjectAccountSearch.and("domainId", NonProjectAccountSearch.entity().getDomainId(), SearchCriteria.Op.EQ);
NonProjectAccountSearch.and("state", NonProjectAccountSearch.entity().getState(), SearchCriteria.Op.EQ);
NonProjectAccountSearch.and("type", NonProjectAccountSearch.entity().getType(), SearchCriteria.Op.NEQ);
NonProjectAccountSearch.done();
}
@Override
@ -144,38 +154,57 @@ public class AccountDaoImpl extends GenericDaoBase<AccountVO, Long> implements A
}
@Override
public Account findNonDisabledAccount(String accountName, Long domainId) {
SearchCriteria<AccountVO> sc = AccountNameSearch.create("accountName", accountName);
sc.addAnd("domainId", SearchCriteria.Op.EQ, domainId);
sc.addAnd("state", SearchCriteria.Op.EQ, State.enabled);
public Account findEnabledAccount(String accountName, Long domainId) {
SearchCriteria<AccountVO> sc = AllFieldsSearch.create("accountName", accountName);
sc.setParameters("domainId",domainId);
sc.setParameters("state", State.enabled);
return findOneBy(sc);
}
@Override
public Account findEnabledNonProjectAccount(String accountName, Long domainId) {
SearchCriteria<AccountVO> sc = NonProjectAccountSearch.create("accountName", accountName);
sc.setParameters("domainId", domainId);
sc.setParameters("state", State.enabled);
sc.setParameters("type", Account.ACCOUNT_TYPE_PROJECT);
return findOneBy(sc);
}
@Override
public Account findActiveAccount(String accountName, Long domainId) {
SearchCriteria<AccountVO> sc = AccountNameSearch.create("accountName", accountName);
sc.addAnd("domainId", SearchCriteria.Op.EQ, domainId);
SearchCriteria<AccountVO> sc = AllFieldsSearch.create("accountName", accountName);
sc.setParameters("domainId", domainId);
return findOneBy(sc);
}
@Override
public Account findActiveNonProjectAccount(String accountName, Long domainId) {
SearchCriteria<AccountVO> sc = NonProjectAccountSearch.create("accountName", accountName);
sc.setParameters("domainId", domainId);
sc.setParameters("type", Account.ACCOUNT_TYPE_PROJECT);
return findOneBy(sc);
}
@Override
public Account findAccount(String accountName, Long domainId) {
SearchCriteria<AccountVO> sc = AccountNameSearch.create("accountName", accountName);
sc.addAnd("domainId", SearchCriteria.Op.EQ, domainId);
public Account findAccountIncludingRemoved(String accountName, Long domainId) {
SearchCriteria<AccountVO> sc = AllFieldsSearch.create("accountName", accountName);
sc.setParameters("domainId", domainId);
return findOneIncludingRemovedBy(sc);
}
@Override
public List<AccountVO> listAccounts(String accountName, Long domainId, Filter filter) {
SearchCriteria<AccountVO> sc = AccountNameSearch.create("accountName", accountName);
sc.addAnd("domainId", SearchCriteria.Op.EQ, domainId);
return listIncludingRemovedBy(sc, filter);
}
public Account findNonProjectAccountIncludingRemoved(String accountName, Long domainId) {
SearchCriteria<AccountVO> sc = NonProjectAccountSearch.create("accountName", accountName);
sc.setParameters("domainId", domainId);
sc.setParameters("type", Account.ACCOUNT_TYPE_PROJECT);
return findOneIncludingRemovedBy(sc);
}
@Override
public Account findActiveAccountByName(String accountName) {
SearchCriteria<AccountVO> sc = AccountNameSearch.create("accountName", accountName);
return findOneBy(sc);
public List<AccountVO> listAccounts(String accountName, Long domainId, Filter filter) {
SearchCriteria<AccountVO> sc = AllFieldsSearch.create("accountName", accountName);
sc.setParameters("domainId", domainId);
return listIncludingRemovedBy(sc, filter);
}
@Override
@ -215,20 +244,12 @@ public class AccountDaoImpl extends GenericDaoBase<AccountVO, Long> implements A
sc.addAnd("id", SearchCriteria.Op.GT, minAccountId);
return listIncludingRemovedBy(sc, filter);
}
@Override
public List<AccountVO> findAdminAccountsForDomain(Long domain) {
SearchCriteria<AccountVO> sc = AccountTypeSearch.create();
sc.addAnd("domainId", Op.EQ, domain);
sc.addAnd("type", Op.IN, Account.ACCOUNT_TYPE_ADMIN, Account.ACCOUNT_TYPE_DOMAIN_ADMIN, Account.ACCOUNT_TYPE_READ_ONLY_ADMIN, Account.ACCOUNT_TYPE_RESOURCE_DOMAIN_ADMIN);
return null;
}
}
@Override
public List<AccountVO> findActiveAccountsForDomain(Long domain) {
SearchCriteria<AccountVO> sc = DomainAccountsSearch.create();
sc.addAnd("domainId", Op.EQ, domain);
sc.setParameters("domainId", domain);
return listBy(sc);
}

View File

@ -84,9 +84,10 @@ public interface UserVmManager extends VirtualMachineGuru<UserVmVO>, UserVmServi
* Obtains a list of virtual machines by the specified search criteria.
* Can search by: "userId", "name", "state", "dataCenterId", "podId", "hostId"
* @param c
* @param skipProjectVms TODO
* @return List of UserVMs.
*/
List<UserVmVO> searchForUserVMs(Criteria c);
List<UserVmVO> searchForUserVMs(Criteria c, boolean skipProjectVms);
String getChecksum(Long hostId, String templatePath);
}

View File

@ -2994,19 +2994,23 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
}
//set project information
boolean skipProjectVms = true;
if (projectId != null) {
permittedAccounts.clear();
Project project = _projectMgr.getProject(projectId);
if (project == null) {
throw new InvalidParameterValueException("Unable to find project by id " + projectId);
}
if (!_projectMgr.canAccessProjectAccount(caller, project.getProjectAccountId())) {
throw new InvalidParameterValueException("Account " + caller + " can't access project id=" + projectId);
}
permittedAccounts.add(project.getProjectAccountId());
} else {
permittedAccounts.addAll(_projectMgr.listPermittedProjectAccounts(caller.getId()));
}
if (projectId == -1) {
permittedAccounts.addAll(_projectMgr.listPermittedProjectAccounts(caller.getId()));
} else {
permittedAccounts.clear();
Project project = _projectMgr.getProject(projectId);
if (project == null) {
throw new InvalidParameterValueException("Unable to find project by id " + projectId);
}
if (!_projectMgr.canAccessProjectAccount(caller, project.getProjectAccountId())) {
throw new InvalidParameterValueException("Account " + caller + " can't access project id=" + projectId);
}
permittedAccounts.add(project.getProjectAccountId());
}
skipProjectVms = false;
}
Criteria c = new Criteria("id", Boolean.TRUE, cmd.getStartIndex(), cmd.getPageSizeVal());
c.addCriteria(Criteria.KEYWORD, cmd.getKeyword());
@ -3044,11 +3048,11 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
}
c.addCriteria(Criteria.ISADMIN, isAdmin);
return searchForUserVMs(c);
return searchForUserVMs(c, skipProjectVms);
}
@Override
public List<UserVmVO> searchForUserVMs(Criteria c) {
public List<UserVmVO> searchForUserVMs(Criteria c, boolean skipProjectVms) {
Filter searchFilter = new Filter(UserVmVO.class, c.getOrderBy(), c.getAscending(), c.getOffset(), c.getLimit());
SearchBuilder<UserVmVO> sb = _vmDao.createSearchBuilder();
@ -3091,6 +3095,12 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
domainSearch.and("path", domainSearch.entity().getPath(), SearchCriteria.Op.LIKE);
sb.join("domainSearch", domainSearch, sb.entity().getDomainId(), domainSearch.entity().getId(), JoinBuilder.JoinType.INNER);
}
if (skipProjectVms) {
SearchBuilder<AccountVO> accountSearch = _accountDao.createSearchBuilder();
accountSearch.and("type", accountSearch.entity().getType(), SearchCriteria.Op.NEQ);
sb.join("accountSearch", accountSearch, sb.entity().getAccountId(), accountSearch.entity().getId(), JoinBuilder.JoinType.INNER);
}
if (groupId != null && (Long) groupId == -1) {
SearchBuilder<InstanceGroupVMMapVO> vmSearch = _groupVMMapDao.createSearchBuilder();
@ -3121,6 +3131,11 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
// populate the search criteria with the values passed in
SearchCriteria<UserVmVO> sc = sb.create();
if (skipProjectVms) {
sc.setJoinParameters("accountSearch", "type", Account.ACCOUNT_TYPE_PROJECT);
}
if (groupId != null && (Long) groupId == -1) {
sc.setJoinParameters("vmSearch", "instanceId", (Object) null);
} else if (groupId != null) {

View File

@ -57,7 +57,7 @@ public class MockNetworkManagerImpl implements NetworkManager, Manager, NetworkS
}
@Override
public IpAddress allocateIP(AssociateIPAddrCmd cmd) throws ResourceAllocationException, InsufficientAddressCapacityException, ConcurrentOperationException {
public IpAddress allocateIP(long networkId, Account ipOwner) throws ResourceAllocationException, InsufficientAddressCapacityException, ConcurrentOperationException {
// TODO Auto-generated method stub
return null;
}

View File

@ -171,7 +171,7 @@ public class MockUserVmManagerImpl implements UserVmManager, UserVmService, Mana
}
@Override
public List<UserVmVO> searchForUserVMs(Criteria c) {
public List<UserVmVO> searchForUserVMs(Criteria c, boolean skipProjectVms) {
// TODO Auto-generated method stub
return null;
}
@ -316,7 +316,7 @@ public class MockUserVmManagerImpl implements UserVmManager, UserVmService, Mana
}
@Override
public List<? extends UserVm> searchForUserVMs(ListVMsCmd cmd) {
public List<? extends UserVm> searchForUserVMs(ListVMsCmd cmd, boolean skipProjectVms) {
// TODO Auto-generated method stub
return null;
}

View File

@ -192,6 +192,7 @@ CREATE TABLE `cloud`.`networks` (
`reservation_id` char(40) COMMENT 'reservation id',
`is_default` int(1) unsigned NOT NULL DEFAULT 0 COMMENT '1 if network is default',
`guest_type` char(32) COMMENT 'type of guest network that can be shared or isolated',
`specified_cidr` int(1) unsigned NOT NULL COMMENT '1 if the CIDR/gateway/vlan are specified in this network',
`created` datetime NOT NULL COMMENT 'date created',
`removed` datetime COMMENT 'date removed if not null',
PRIMARY KEY (`id`),
@ -908,6 +909,7 @@ CREATE TABLE `cloud`.`vm_template` (
`checksum` varchar(255) COMMENT 'checksum for the template root disk',
`display_text` varchar(4096) NULL COMMENT 'Description text set by the admin for display purpose only',
`enable_password` int(1) unsigned NOT NULL default 1 COMMENT 'true if this template supports password reset',
`enable_sshkey` int(1) unsigned NOT NULL default 0 COMMENT 'true if this template supports sshkey reset',
`guest_os_id` bigint unsigned NOT NULL COMMENT 'the OS of the template',
`bootable` int(1) unsigned NOT NULL default 1 COMMENT 'true if this template represents a bootable ISO',
`prepopulate` int(1) unsigned NOT NULL default 0 COMMENT 'prepopulate this template to primary storage',

View File

@ -135,7 +135,6 @@ table tbody tr {
border-left: 1px solid #C4C5C5;
border-right: 1px solid #C4C5C5;
border-top: 1px solid transparent;
cursor: pointer;
}
table tbody tr.even {
@ -931,7 +930,7 @@ div.notification.corner-alert:hover div.message span {
/*List view*/
div.panel div.list-view {
overflow: auto;
height: 668px;
height: 652px;
margin-top: 30px;
border-bottom: 1px solid #E7E7E7;
}
@ -1010,6 +1009,14 @@ div.list-view td.state {
width: 129px;
}
div.list-view td.first {
cursor: pointer;
}
div.list-view td.first:hover {
color: #3A82CD;
}
div.list-view td.state span {
padding: 0 0 0 26px;
text-align: center;
@ -5014,7 +5021,7 @@ div.detail-group td.view-all div.view-all div.end {
}
div.panel.ui-dialog div.list-view div.fixed-header {
top: 33px;
top: 42px;
left: 20px;
width: 759px;
height: 49px;

View File

@ -789,8 +789,13 @@
</div>
</div>
<div class="head">
<span>Zone Configuration</span>
<div class="add">Add Network</div>
<span>Zone Configuration</span>
<!--
<div class="add">Add Physical Network</div>
-->
<div class="add">&nbsp;</div>
</div>
<ul class="system-main">
<li class="main public" rel="public">
@ -811,7 +816,7 @@
<!-- Zone resources -->
<div class="resources zone">
<div class="head">
<div class="add">Add Resource</div>
<div class="add" id="add_resource_button">Add Resource</div>
</div>
<ul>
<li class="pod">

View File

@ -400,6 +400,20 @@
}
},
staticNATDataProvider: function(args) {
args.response.success({
data: testData.data.ipAddresses[0]
});
},
vmDataProvider: function(args) {
args.response.success({
data: testData.data.instances[1]
});
},
vmDetails: cloudStack.sections.instances.listView.detailView,
staticNAT: {
noSelect: true,
fields: {

View File

@ -166,9 +166,12 @@
}
},
dataProvider: function(args) {
dataProvider: function(args) {
var array1 = [];
if("domains" in args.context)
array1.push("&domainid=" + args.context.domains[0].id);
$.ajax({
url: createURL("listAccounts&page=" + args.page + "&pagesize=" + pageSize),
url: createURL("listAccounts" + array1.join("") + "&page=" + args.page + "&pagesize=" + pageSize),
dataType: "json",
async: true,
success: function(json) {

View File

@ -34,6 +34,15 @@
});
$(function() {
/**
* Generic error handling
*/
$.ajaxSetup({
error: function(data) {
cloudStack.dialog.notice({ message: parseXMLHttpResponse(data) });
}
});
var $container = $('#cloudStack3-container');
var loginArgs = {

View File

@ -24,15 +24,16 @@
notification: function(args) {
return 'Domain is deleted';
}
},
},
createForm: {
title: 'Delete domain',
preFilter: function(args) {
title: 'Delete domain',
createLabel: 'Delete',
preFilter: function(args) {
if(isAdmin()) {
args.$form.find('.form-item[rel=isForced]').css('display', 'inline-block');
}
},
},
fields: {
isForced: {
label: 'Force delete',
@ -43,7 +44,7 @@
},
action: function(args) {
var array1 = [];
var array1 = [];
if(args.$form.find('.form-item[rel=isForced]').css("display") != "none") //uncomment after Brian fix it to include $form in args
array1.push("&cleanup=" + (args.data.isForced == "on"));
@ -58,6 +59,12 @@
{jobId: jid}
}
);
// Quick fix for proper UI reaction to delete domain
var $item = $('.name.selected').closest('li');
var $itemParent = $item.closest('li');
$itemParent.parent().parent().find('.name:first').click();
$item.remove();
}
});
},
@ -70,63 +77,63 @@
edit: {
label: 'Edit domain details',
messages: {
notification: function(args) {
notification: function(args) {
return 'Edited domain: ' + args.name;
}
},
action: function(args) {
var domainObj;
action: function(args) {
var domainObj;
$.ajax({
url: createURL("updateDomain&id=" + args.context.domains[0].id + "&name=" + todb(args.data.name)),
async: false,
dataType: "json",
success: function(json) {
success: function(json) {
domainObj = json.updatedomainresponse.domain;
}
});
});
$.ajax({
url: createURL("updateResourceLimit&domainid=" + args.context.domains[0].id + "&resourceType=0&max=" + args.data.vmLimit),
dataType: "json",
async: false,
success: function(json) {
domainObj["vmLimit"] = args.data.vmLimit;
success: function(json) {
domainObj["vmLimit"] = args.data.vmLimit;
}
});
});
$.ajax({
url: createURL("updateResourceLimit&domainid=" + args.context.domains[0].id + "&resourceType=1&max=" + args.data.ipLimit),
dataType: "json",
async: false,
success: function(json) {
domainObj["ipLimit"] = args.data.ipLimit;
success: function(json) {
domainObj["ipLimit"] = args.data.ipLimit;
}
});
});
$.ajax({
url: createURL("updateResourceLimit&domainid=" + args.context.domains[0].id + "&resourceType=2&max=" + args.data.volumeLimit),
dataType: "json",
async: false,
success: function(json) {
domainObj["volumeLimit"] = args.data.volumeLimit;
success: function(json) {
domainObj["volumeLimit"] = args.data.volumeLimit;
}
});
});
$.ajax({
url: createURL("updateResourceLimit&domainid=" + args.context.domains[0].id + "&resourceType=3&max=" + args.data.snapshotLimit),
dataType: "json",
async: false,
success: function(json) {
domainObj["snapshotLimit"] = args.data.snapshotLimit;
success: function(json) {
domainObj["snapshotLimit"] = args.data.snapshotLimit;
}
});
$.ajax({
url: createURL("updateResourceLimit&domainid=" + args.context.domains[0].id + "&resourceType=4&max=" + args.data.templateLimit),
dataType: "json",
async: false,
success: function(json) {
domainObj["templateLimit"] = args.data.templateLimit;
success: function(json) {
domainObj["templateLimit"] = args.data.templateLimit;
}
});
args.response.success({data: domainObj});
}
},
@ -181,23 +188,23 @@
},
{
id: { label: 'ID' },
vmLimit: {
vmLimit: {
label: 'Instance limits',
isEditable: true
},
ipLimit: {
ipLimit: {
label: 'Public IP limits',
isEditable: true
},
volumeLimit: {
volumeLimit: {
label: 'Volume limits',
isEditable: true
},
snapshotLimit: {
snapshotLimit: {
label: 'Snapshot limits',
isEditable: true
},
templateLimit: {
templateLimit: {
label: 'Template limits',
isEditable: true
},
@ -206,90 +213,90 @@
volumeTotal: { label: 'Volumes' }
}
],
dataProvider: function(args) {
var domainObj = args.context.domains[0];
$.ajax({
dataProvider: function(args) {
var domainObj = args.context.domains[0];
$.ajax({
url: createURL("listAccounts&domainid=" + domainObj.id),
async: false,
dataType: "json",
success: function(json) {
var items = json.listaccountsresponse.account;
success: function(json) {
var items = json.listaccountsresponse.account;
var total;
if (items != null)
total = items.length;
if (items != null)
total = items.length;
else
total = 0;
domainObj["accountTotal"] = total;
}
});
$.ajax({
total = 0;
domainObj["accountTotal"] = total;
}
});
$.ajax({
url: createURL("listVirtualMachines&domainid=" + domainObj.id),
async: false,
dataType: "json",
success: function(json) {
var items = json.listvirtualmachinesresponse.virtualmachine;
success: function(json) {
var items = json.listvirtualmachinesresponse.virtualmachine;
var total;
if (items != null)
total = items.length;
if (items != null)
total = items.length;
else
total = 0;
domainObj["vmTotal"] = total;
}
});
$.ajax({
total = 0;
domainObj["vmTotal"] = total;
}
});
$.ajax({
url: createURL("listVolumes&domainid=" + domainObj.id),
async: false,
dataType: "json",
success: function(json) {
var items = json.listvolumesresponse.volume;
success: function(json) {
var items = json.listvolumesresponse.volume;
var total;
if (items != null)
total = items.length;
if (items != null)
total = items.length;
else
total = 0;
domainObj["volumeTotal"] = total;
}
});
total = 0;
domainObj["volumeTotal"] = total;
}
});
$.ajax({
url: createURL("listResourceLimits&domainid=" + domainObj.id),
async: false,
dataType: "json",
success: function(json) {
var limits = json.listresourcelimitsresponse.resourcelimit;
if (limits != null) {
var limits = json.listresourcelimitsresponse.resourcelimit;
if (limits != null) {
for (var i = 0; i < limits.length; i++) {
var limit = limits[i];
switch (limit.resourcetype) {
case "0":
domainObj["vmLimit"] = limit.max;
case "0":
domainObj["vmLimit"] = limit.max;
break;
case "1":
domainObj["ipLimit"] = limit.max;
case "1":
domainObj["ipLimit"] = limit.max;
break;
case "2":
domainObj["volumeLimit"] = limit.max;
case "2":
domainObj["volumeLimit"] = limit.max;
break;
case "3":
domainObj["snapshotLimit"] = limit.max;
case "3":
domainObj["snapshotLimit"] = limit.max;
break;
case "4":
domainObj["templateLimit"] = limit.max;
case "4":
domainObj["templateLimit"] = limit.max;
break;
}
}
}
}
});
}
}
});
args.response.success({
data: domainObj,
actionFilter: domainActionfilter
});
}
}
}
}
},
labelField: 'name',
@ -326,19 +333,19 @@
}
}
};
var domainActionfilter = function(args) {
var jsonObj = args.context.item;
var allowedActions = [];
if(isAdmin()) {
allowedActions.push("create");
if(jsonObj.id != 1) { //"ROOT" domain is not allowed to edit or delete
var allowedActions = [];
if(isAdmin()) {
allowedActions.push("create");
if(jsonObj.id != 1) { //"ROOT" domain is not allowed to edit or delete
allowedActions.push("edit"); //merge updateResourceCount into edit
allowedActions.push("delete");
}
}
//allowedActions.push("updateResourceCount");
allowedActions.push("delete");
}
}
//allowedActions.push("updateResourceCount");
return allowedActions;
}
}
})(cloudStack, testData);

View File

@ -256,9 +256,8 @@
success: function(json) {
var networks = json.listnetworksresponse.network;
//***** Setup Virtual Network (begin) *****
//virtualNetwork is first radio button in required network section. Show virtualNetwork when its networkofferingavailability is 'Required' or'Optional'
var virtualNetwork = null;
//***** check if there is an isolated network with sourceNAT (begin) *****
var isolatedSourcenatNetwork = null;
if(selectedZoneObj.securitygroupsenabled == false) {
if (networks != null && networks.length > 0) {
for (var i = 0; i < networks.length; i++) {
@ -266,13 +265,13 @@
//loop through
var sourceNatObj = ipFindNetworkServiceByName("SourceNat", networks[i]);
if(sourceNatObj != null) {
virtualNetwork = networks[i];
isolatedSourcenatNetwork = networks[i];
break;
}
}
}
}
if (virtualNetwork == null) { //if there is no isolated network with sourceNat
if (isolatedSourcenatNetwork == null) { //if there is no isolated network with sourceNat, create one.
$.ajax({
url: createURL("listNetworkOfferings&guestiptype=Isolated&supportedServices=sourceNat&state=Enabled"), //get the network offering for isolated network with sourceNat
dataType: "json",
@ -292,8 +291,8 @@
dataType: "json",
async: false,
success: function(json) {
virtualNetwork = json.createnetworkresponse.network;
defaultNetworkArray.push(virtualNetwork);
isolatedSourcenatNetwork = json.createnetworkresponse.network;
defaultNetworkArray.push(isolatedSourcenatNetwork);
}
});
}
@ -301,41 +300,40 @@
}
}
});
}
else { //virtualNetwork != null (there is already a virtualNetwork)
if (virtualNetwork.networkofferingavailability == 'Required' || virtualNetwork.networkofferingavailability == 'Optional') {
defaultNetworkArray.push(virtualNetwork);
}
else { //virtualNetwork.networkofferingavailability == 'Unavailable'
//do not show virtualNetwork
}
}
}
}
//***** Setup Virtual Network (end) *****
//***** check if there is an isolated network with sourceNAT (end) *****
//***** Setup Direct Networks (begin) *****
//direct networks whose isdefault==true is 2nd~Nth radio buttons in required network section
//direct networks whose isdefault==false is a bunch of checkboxes in optional network section
//***** populate all networks (begin) **********************************
//isolatedSourcenatNetwork is first radio button in default network section. Show isolatedSourcenatNetwork when its networkofferingavailability is 'Required' or'Optional'
if (isolatedSourcenatNetwork.networkofferingavailability == 'Required' || isolatedSourcenatNetwork.networkofferingavailability == 'Optional') {
defaultNetworkArray.push(isolatedSourcenatNetwork);
}
//default networks are in default network section
//non-default networks are in additional network section
if (networks != null && networks.length > 0) {
for (var i = 0; i < networks.length; i++) {
//if selectedZoneObj.securitygroupsenabled is true and users still choose to select network instead of security group (from dialog), then UI won't show networks whose securitygroupenabled is true.
if(selectedZoneObj.securitygroupsenabled == true && networks[i].securitygroupenabled == true) {
continue;
}
//if(selectedZoneObj.securitygroupsenabled == true && networks[i].securitygroupenabled == true) {
// continue;
//}
if (networks[i].isdefault) {
if (virtualNetwork.networkofferingavailability == 'Required') {
continue; //don't display 2nd~Nth radio buttons in required network section when networkofferingavailability == 'Required'
if (isolatedSourcenatNetwork.networkofferingavailability == 'Required') {
continue; //don't display 2nd~Nth radio buttons in default network section when isolatedSourcenatNetwork.networkofferingavailability == 'Required'
}
if(networks[i].id != isolatedSourcenatNetwork.id) {
defaultNetworkArray.push(networks[i]);
}
defaultNetworkArray.push(networks[i]);
}
else {
optionalNetworkArray.push(networks[i]);
}
}
}
//***** Setup Direct Networks (end) *****
//***** populate all networks (end) ************************************
}
});
args.response.success({

View File

@ -814,6 +814,24 @@
}
},
staticNATDataProvider: function(args) {
$.ajax({
url: createURL('listPublicIpAddresses'),
data: {
id: args.context.ipAddresses[0].id
},
dataType: 'json',
async: true,
success: function(data) {
var ipAddress = data.listpublicipaddressesresponse.publicipaddress[0];
args.response.success({
data: ipAddress
});
}
});
},
vmDataProvider: function(args) {
$.ajax({
url: createURL('listVirtualMachines'),
@ -924,7 +942,32 @@
// Load balancing rules
loadBalancing: {
listView: cloudStack.sections.instances,
listView: $.extend(true, {}, cloudStack.sections.instances, {
listView: {
dataProvider: function(args) {
$.ajax({
url: createURL('listVirtualMachines'),
data: {
networkid: args.context.ipAddresses[0].associatednetworkid
},
dataType: 'json',
async: true,
success: function(data) {
args.response.success({
data: $.grep(
data.listvirtualmachinesresponse.virtualmachine,
function(instance) {
return $.inArray(instance.state, [
'Destroyed'
]) == -1;
}
)
});
}
});
}
}
}),
multipleAdd: true,
fields: {
'name': { edit: true, label: 'Name' },
@ -951,9 +994,8 @@
label: 'Add VMs',
action: function(args) {
$.ajax({
url: createURL(),
url: createURL('createLoadBalancerRule'),
data: $.extend(args.data, {
command: 'createLoadBalancerRule',
publicipid: args.context.ipAddresses[0].id
}),
dataType: 'json',
@ -962,9 +1004,8 @@
var itemData = args.itemData;
$.ajax({
url: createURL(),
url: createURL('assignToLoadBalancerRule'),
data: {
command: 'assignToLoadBalancerRule',
id: data.createloadbalancerruleresponse.id,
virtualmachineids: $.map(itemData, function(elem) {
return elem.id;
@ -995,9 +1036,8 @@
label: 'Remove load balancer rule',
action: function(args) {
$.ajax({
url: createURL(),
url: createURL('deleteLoadBalancerRule'),
data: {
command: 'deleteLoadBalancerRule',
id: args.context.multiRule[0].id
},
dataType: 'json',
@ -1021,16 +1061,15 @@
},
dataProvider: function(args) {
$.ajax({
url: createURL(),
url: createURL('listLoadBalancerRules'),
data: {
command: 'listLoadBalancerRules',
publicipid: args.context.ipAddresses[0].id
},
dataType: 'json',
async: true,
success: function(data) {
var loadBalancerData = data.listloadbalancerrulesresponse.loadbalancerrule;
var loadVMTotal = loadBalancerData.length;
var loadVMTotal = loadBalancerData ? loadBalancerData.length : 0;
var loadVMCurrent = 0;
$(loadBalancerData).each(function() {
@ -1038,11 +1077,10 @@
// Get instances
$.ajax({
url: createURL(),
url: createURL('listLoadBalancerRuleInstances'),
dataType: 'json',
async: true,
data: {
command: 'listLoadBalancerRuleInstances',
id: item.id
},
success: function(data) {
@ -1067,7 +1105,32 @@
// Port forwarding rules
portForwarding: {
listView: cloudStack.sections.instances,
listView: $.extend(true, {}, cloudStack.sections.instances, {
listView: {
dataProvider: function(args) {
$.ajax({
url: createURL('listVirtualMachines'),
data: {
networkid: args.context.ipAddresses[0].associatednetworkid
},
dataType: 'json',
async: true,
success: function(data) {
args.response.success({
data: $.grep(
data.listvirtualmachinesresponse.virtualmachine,
function(instance) {
return $.inArray(instance.state, [
'Destroyed'
]) == -1;
}
)
});
}
});
}
}
}),
fields: {
'private-ports': {
edit: true,
@ -1099,9 +1162,8 @@
label: 'Add VM',
action: function(args) {
$.ajax({
url: createURL(),
url: createURL('createPortForwardingRule'),
data: $.extend(args.data, {
command: 'createPortForwardingRule',
ipaddressid: args.context.ipAddresses[0].id,
virtualmachineid: args.itemData[0].id
}),
@ -1126,9 +1188,8 @@
label: 'Remove port forwarding rule',
action: function(args) {
$.ajax({
url: createURL(),
url: createURL('deletePortForwardingRule'),
data: {
command: 'deletePortForwardingRule',
id: args.context.multiRule[0].id
},
dataType: 'json',
@ -1152,9 +1213,8 @@
},
dataProvider: function(args) {
$.ajax({
url: createURL(),
url: createURL('listPortForwardingRules'),
data: {
command: 'listPortForwardingRules',
ipaddressid: args.context.ipAddresses[0].id
},
dataType: 'json',
@ -1163,18 +1223,17 @@
// Get instance
var portForwardingData = data
.listportforwardingrulesresponse.portforwardingrule;
var loadTotal = portForwardingData.length;
var loadTotal = portForwardingData ? portForwardingData.length : 0;
var loadCurrent = 0;
$(portForwardingData).each(function() {
var item = this;
$.ajax({
url: createURL(),
url: createURL('listVirtualMachines'),
dataType: 'json',
async: true,
data: {
command: 'listVirtualMachines',
id: item.virtualmachineid
},
success: function(data) {

View File

@ -106,6 +106,7 @@
noSelect: true,
fields: {
'username': { edit: true, label: 'Account' },
'role': { edit: 'ignore', label: 'Role' },
'add-user': { addButton: true, label: '' }
},
add: {
@ -222,6 +223,7 @@
data: $.map(data.listprojectaccountsresponse.projectaccount, function(elem) {
return {
id: elem.accountid,
role: elem.role,
username: elem.role == 'Owner' ?
elem.account + ' (owner)' : elem.account
};

View File

@ -58,6 +58,7 @@ var pollAsyncJobResult = function(args) {
else if (result.jobstatus == 2) { // Failed
var msg = (result.jobresult.errortext == null)? "": result.jobresult.errortext;
args.error({message: msg});
cloudStack.dialog.notice({ message: msg });
}
}
},

View File

@ -34,13 +34,13 @@
messages: {
confirm: function(args) {
return 'Are you sure you want to add ' + args.name + '?';
return 'Are you sure you want to add a volume?';
},
success: function(args) {
return 'Your new volume is being created.';
return 'Creating volume';
},
notification: function(args) {
return 'Creating new volume';
return 'create volume';
},
complete: function(args) {
return 'Volume has been created successfully!';
@ -161,16 +161,16 @@
label: 'Take snapshot',
messages: {
confirm: function(args) {
return 'Please confirm that you want to take a snapshot of ' + args.name;
return 'Please confirm that you want to take a snapshot'
},
success: function(args) {
return 'Your new snapshot ' + args.name + ' is being created.';
return 'Taking snapshot';
},
notification: function(args) {
return 'Made snapshot of volume: ' + args.name;
return 'Take snapshot';
},
complete: function(args) {
return 'Snapshot ' + args.name + ' is ready.';
return 'Snapshot has been taken successfully';
}
},
action: function(args) {
@ -445,16 +445,17 @@
},
attachDisk: {
label: 'Attach Disk',
messages: {
confirm: function(args) {
return 'Are you sure you want to attach disk?';
},
success: function(args) {
return 'Disk is being attached to instance';
return 'Attaching disk';
},
notification: function(args) {
return 'Attaching disk to instance';
return 'Attach disk';
},
complete: function(args) {
return 'Disk has been attached to instance';
@ -530,10 +531,10 @@
return 'Are you sure you want to detach disk ?';
},
success: function(args) {
return 'Disk is being detached.';
return 'Detaching disk';
},
notification: function(args) {
return 'Detaching disk';
return 'Detach disk';
},
complete: function(args) {
return 'Disk has been detached.';
@ -570,13 +571,13 @@
label: 'Download volume',
messages: {
confirm: function(args) {
return 'Are you sure you want to download volume ?';
return 'Are you sure you want to download volume?';
},
success: function(args) {
return 'Volume is being downloaded.';
return 'Downloading volume';
},
notification: function(args) {
return 'Downloading volume';
return 'Download volume';
},
complete: function(args) {
var url = decodeURIComponent(args.url);
@ -617,22 +618,17 @@
label: 'Create template',
addRow: 'false',
messages: {
confirm: function(args) {
/*
if (getUserPublicTemplateEnabled() == "true" || isAdmin()) {
$dialogCreateTemplate.find("#create_template_public_container").show();
}
*/
confirm: function(args) {
return 'Are you sure you want to create template?';
},
success: function(args) {
return 'Template is being created.';
},
notification: function(args) {
return 'Creating template';
},
notification: function(args) {
return 'Create template';
},
complete: function(args) {
return 'Template has been created.';
return 'Template has been created successfully.';
}
},
createForm: {
@ -711,16 +707,16 @@
label: 'Delete volume',
messages: {
confirm: function(args) {
return 'Are you sure you want to delete volume ?';
return 'Are you sure you want to delete volume?';
},
success: function(args) {
return 'Volume is being deleted.';
},
notification: function(args) {
return 'Deleting volume';
},
notification: function(args) {
return 'Delete volume';
},
complete: function(args) {
return 'Volume has been deleted.';
return 'Volume has been deleted';
}
},
action: function(args) {
@ -776,16 +772,16 @@
label: 'Take snapshot',
messages: {
confirm: function(args) {
return 'Please confirm that you want to take a snapshot of ' + args.name;
return 'Please confirm that you want to take a snapshot' ;
},
success: function(args) {
return 'Your new snapshot ' + args.name + ' is being created.';
return 'Taking snapshot';
},
notification: function(args) {
return 'Made snapshot of volume: ' + args.name;
return 'Take snapshot';
},
complete: function(args) {
return 'Snapshot ' + args.name + ' is ready.';
return 'Snapshot has been taken successfully';
}
},
action: function(args) {
@ -816,16 +812,17 @@
},
attachDisk: {
addRow: 'false',
label: 'Attach Disk',
messages: {
confirm: function(args) {
return 'Are you sure you want to attach disk?';
},
success: function(args) {
return 'Disk is being attached to instance';
return 'Attaching disk';
},
notification: function(args) {
return 'Attaching disk to instance';
return 'Attach disk';
},
complete: function(args) {
return 'Disk has been attached to instance';
@ -898,13 +895,13 @@
label: 'Detach disk',
messages: {
confirm: function(args) {
return 'Are you sure you want to detach disk ?';
return 'Are you sure you want to detach disk?';
},
success: function(args) {
return 'Disk is being detached.';
return 'Detaching disk';
},
notification: function(args) {
return 'Detaching disk';
return 'Detach disk';
},
complete: function(args) {
return 'Disk has been detached.';
@ -941,10 +938,10 @@
label: 'Download volume',
messages: {
confirm: function(args) {
return 'Are you sure you want to download volume ?';
return 'Are you sure you want to download volume?';
},
success: function(args) {
return 'Volume is being downloaded.';
return 'Downloading volume';
},
notification: function(args) {
return 'Downloading volume';
@ -991,10 +988,10 @@
return 'Are you sure you want to create template?';
},
success: function(args) {
return 'Template is being created.';
return 'Creating template';
},
notification: function(args) {
return 'Creating template';
return 'Create template';
},
complete: function(args) {
return 'Template has been created.';
@ -1075,13 +1072,13 @@
label: 'Delete volume',
messages: {
confirm: function(args) {
return 'Are you sure you want to delete volume ?';
return 'Are you sure you want to delete volume?';
},
success: function(args) {
return 'Volume is being deleted.';
return 'Deleting volume';
},
notification: function(args) {
return 'Deleting volume';
return 'Delete volume';
},
complete: function(args) {
return 'Volume has been deleted.';
@ -1202,10 +1199,10 @@
return 'Are you sure you want to create template?';
},
success: function(args) {
return 'Template is being created.';
return 'Creating template';
},
notification: function(args) {
return 'Creating template';
return 'Create template';
},
complete: function(args) {
return 'Template has been created.';
@ -1290,10 +1287,10 @@
return 'Are you sure you want to create volume?';
},
success: function(args) {
return 'Volume is being created.';
return 'Creating volume';
},
notification: function(args) {
return 'Creating volume';
return 'Create volume';
},
complete: function(args) {
return 'Volume has been created.';
@ -1347,13 +1344,13 @@
label: 'Delete snapshot',
messages: {
confirm: function(args) {
return 'Are you sure you want to delete snapshot ?';
return 'Are you sure you want to delete snapshot?';
},
success: function(args) {
return 'Snapshot is being deleted.';
return 'Deleting snapshot';
},
notification: function(args) {
return 'Deleting snapshot';
return 'Delete snapshot';
},
complete: function(args) {
return 'Snapshot has been deleted.';
@ -1413,10 +1410,10 @@
return 'Are you sure you want to create template?';
},
success: function(args) {
return 'Template is being created.';
return 'Creating template';
},
notification: function(args) {
return 'Creating template';
return 'Create template';
},
complete: function(args) {
return 'Template has been created.';
@ -1500,10 +1497,10 @@
return 'Are you sure you want to create volume?';
},
success: function(args) {
return 'Volume is being created.';
return 'Creating volume';
},
notification: function(args) {
return 'Creating volume';
return 'Create volume';
},
complete: function(args) {
return 'Volume has been created.';
@ -1557,13 +1554,13 @@
label: 'Delete snapshot',
messages: {
confirm: function(args) {
return 'Are you sure you want to delete snapshot ?';
return 'Are you sure you want to delete snapshot?';
},
success: function(args) {
return 'Snapshot is being deleted.';
return 'Deleting snapshot';
},
notification: function(args) {
return 'Deleting snapshot';
return 'Delete snapshot';
},
complete: function(args) {
return 'Snapshot has been deleted.';

View File

@ -136,7 +136,7 @@
args.response.success({
data: item,
notification: {
label: 'Added IP address',
label: 'IP range is added',
poll: function(args) {
args.complete();
}
@ -153,12 +153,9 @@
actions: {
destroy: {
label: 'Delete',
action: function(args) {
action: function(args) {
$.ajax({
url: createURL('deleteVlanIpRange'),
data: {
id: args.context.multiRule[0].id
},
url: createURL('deleteVlanIpRange&id=' + args.context.multiRule[0].id),
dataType: 'json',
async: true,
success: function(json) {
@ -927,7 +924,7 @@
networks: {
actions: {
add: {
label: 'Add Network',
label: 'Add physical network',
action: function(args) {
args.response.success();
}
@ -1092,7 +1089,7 @@
},
providerActions: {
enable: {
label: 'Enable',
label: 'Enable provider',
action: function(args) {
$.ajax({
url: createURL("updateNetworkServiceProvider&id=" + nspMap["virtualRouter"].id + "&state=Enabled"),
@ -1115,12 +1112,12 @@
});
},
messages: {
notification: function() { return 'Enabled Netscaler provider'; }
notification: function() { return 'Provider is enabled'; }
},
notification: { poll: pollAsyncJobResult }
},
disable: {
label: 'Disable',
label: 'Disable provider',
action: function(args) {
$.ajax({
url: createURL("updateNetworkServiceProvider&id=" + nspMap["virtualRouter"].id + "&state=Disabled"),
@ -1143,7 +1140,7 @@
});
},
messages: {
notification: function() { return 'Disabled Netscaler provider'; }
notification: function() { return 'Provider is disabled'; }
},
notification: { poll: pollAsyncJobResult }
}
@ -1178,7 +1175,7 @@
},
providerActions: {
enable: {
label: 'Enable',
label: 'Enable provider',
action: function(args) {
$.ajax({
url: createURL("updateNetworkServiceProvider&id=" + nspMap["netscaler"].id + "&state=Enabled"),
@ -1201,12 +1198,12 @@
});
},
messages: {
notification: function() { return 'Enabled Netscaler provider'; }
notification: function() { return 'Provider is enabled'; }
},
notification: { poll: pollAsyncJobResult }
},
disable: {
label: 'Disable',
label: 'Disable provider',
action: function(args) {
$.ajax({
url: createURL("updateNetworkServiceProvider&id=" + nspMap["netscaler"].id + "&state=Disabled"),
@ -1229,12 +1226,12 @@
});
},
messages: {
notification: function() { return 'Disabled Netscaler provider'; }
notification: function() { return 'Provider is disabled'; }
},
notification: { poll: pollAsyncJobResult }
},
shutdown: {
label: 'Shutdown',
label: 'Shutdown provider',
action: function(args) {
$.ajax({
url: createURL("deleteNetworkServiceProvider&id=" + nspMap["netscaler"].id),
@ -1256,7 +1253,7 @@
});
},
messages: {
notification: function() { return 'Shutdown Netscaler provider'; }
notification: function() { return 'Provider is shutdown'; }
},
notification: { poll: pollAsyncJobResult }
}
@ -1473,7 +1470,7 @@
},
providerActions: {
enable: {
label: 'Enable',
label: 'Enable provider',
action: function(args) {
$.ajax({
url: createURL("updateNetworkServiceProvider&id=" + nspMap["f5"].id + "&state=Enabled"),
@ -1496,12 +1493,12 @@
});
},
messages: {
notification: function() { return 'Enabled F5 provider'; }
notification: function() { return 'Provider is enabled'; }
},
notification: { poll: pollAsyncJobResult }
},
disable: {
label: 'Disable',
label: 'Disable provider',
action: function(args) {
$.ajax({
url: createURL("updateNetworkServiceProvider&id=" + nspMap["f5"].id + "&state=Disabled"),
@ -1524,12 +1521,12 @@
});
},
messages: {
notification: function() { return 'Disabled F5 provider'; }
notification: function() { return 'Provider is disabled'; }
},
notification: { poll: pollAsyncJobResult }
},
shutdown: {
label: 'Shutdown',
label: 'Shutdown provider',
action: function(args) {
$.ajax({
url: createURL("deleteNetworkServiceProvider&id=" + nspMap["f5"].id),
@ -1551,7 +1548,7 @@
});
},
messages: {
notification: function() { return 'Shutdown F5 provider'; }
notification: function() { return 'Provider is shutdown'; }
},
notification: { poll: pollAsyncJobResult }
}
@ -1766,7 +1763,7 @@
},
providerActions: {
enable: {
label: 'Enable',
label: 'Enable provider',
action: function(args) {
$.ajax({
url: createURL("updateNetworkServiceProvider&id=" + nspMap["srx"].id + "&state=Enabled"),
@ -1789,12 +1786,12 @@
});
},
messages: {
notification: function() { return 'Enabled SRX provider'; }
notification: function() { return 'Provider is enabled'; }
},
notification: { poll: pollAsyncJobResult }
},
disable: {
label: 'Disable',
label: 'Disable provider',
action: function(args) {
$.ajax({
url: createURL("updateNetworkServiceProvider&id=" + nspMap["srx"].id + "&state=Disabled"),
@ -1817,12 +1814,12 @@
});
},
messages: {
notification: function() { return 'Disabled SRX provider'; }
notification: function() { return 'Provider is disabled'; }
},
notification: { poll: pollAsyncJobResult }
},
shutdown: {
label: 'Shutdown',
label: 'Shutdown provider',
action: function(args) {
$.ajax({
url: createURL("deleteNetworkServiceProvider&id=" + nspMap["srx"].id),
@ -1844,7 +1841,7 @@
});
},
messages: {
notification: function() { return 'Shutdown SRX provider'; }
notification: function() { return 'Provider is shutdown'; }
},
notification: { poll: pollAsyncJobResult }
}
@ -2056,7 +2053,7 @@
},
providerActions: {
enable: {
label: 'Enable',
label: 'Enable provider',
action: function(args) {
$.ajax({
url: createURL("updateNetworkServiceProvider&id=" + nspMap["securityGroups"].id + "&state=Enabled"),
@ -2079,12 +2076,12 @@
});
},
messages: {
notification: function() { return 'Enabled Netscaler provider'; }
notification: function() { return 'Provider is enabled'; }
},
notification: { poll: pollAsyncJobResult }
},
disable: {
label: 'Disable',
label: 'Disable provider',
action: function(args) {
$.ajax({
url: createURL("updateNetworkServiceProvider&id=" + nspMap["securityGroups"].id + "&state=Disabled"),
@ -2107,7 +2104,7 @@
});
},
messages: {
notification: function() { return 'Disabled Netscaler provider'; }
notification: function() { return 'Provider is disabled'; }
},
notification: { poll: pollAsyncJobResult }
}
@ -5226,7 +5223,14 @@
var array1 = [];
array1.push("&zoneId=" + args.context.zones[0].id);
array1.push("&hypervisor=" + args.data.hypervisor);
array1.push("&clustertype=CloudManaged");
var clusterType;
if(args.data.hypervisor == "VMware")
clusterType="ExternalManaged";
else
clusterType="CloudManaged";
array1.push("&clustertype=" + clusterType);
array1.push("&podId=" + args.data.podId);
var clusterName = args.data.name;
@ -7986,36 +7990,27 @@
var hostActionfilter = function(args) {
var jsonObj = args.context.item;
var allowedActions = [];
if (jsonObj.state == 'Up' || jsonObj.state == "Connecting") {
if (jsonObj.resourcestate == "Enabled") {
allowedActions.push("edit");
allowedActions.push("enableMaintenanceMode");
allowedActions.push("forceReconnect");
}
else if(jsonObj.state == 'Down') {
allowedActions.push("edit");
allowedActions.push("enableMaintenanceMode");
allowedActions.push("delete");
}
else if(jsonObj.state == "Alert") {
allowedActions.push("edit");
allowedActions.push("delete");
}
else if (jsonObj.state == "ErrorInMaintenance") {
else if (jsonObj.resourcestate == "ErrorInMaintenance") {
allowedActions.push("edit");
allowedActions.push("enableMaintenanceMode");
allowedActions.push("cancelMaintenanceMode");
}
else if (jsonObj.state == "PrepareForMaintenance") {
else if (jsonObj.resourcestate == "PrepareForMaintenance") {
allowedActions.push("edit");
allowedActions.push("cancelMaintenanceMode");
}
else if (jsonObj.state == "Maintenance") {
else if (jsonObj.resourcestate == "Maintenance") {
allowedActions.push("edit");
allowedActions.push("cancelMaintenanceMode");
allowedActions.push("delete");
}
else if (jsonObj.state == "Disconnected"){
else if (jsonObj.resourcestate == "Disabled"){
allowedActions.push("edit");
allowedActions.push("delete");
}

View File

@ -70,7 +70,8 @@
success: function(json) {
var zoneObjs = json.listzonesresponse.zone;
var items = [];
if (isAdmin())
if (isAdmin() && !(cloudStack.context.projects &&
cloudStack.context.projects[0]))
items.push({id: -1, description: "All Zones"});
$(zoneObjs).each(function() {
items.push({id: this.id, description: this.name});
@ -775,7 +776,8 @@
success: function(json) {
var zoneObjs = json.listzonesresponse.zone;
var items = [];
if (isAdmin())
if (isAdmin() && !(cloudStack.context.projects &&
cloudStack.context.projects[0]))
items.push({id: -1, description: "All Zones"});
$(zoneObjs).each(function() {
items.push({id: this.id, description: this.name});

View File

@ -54,7 +54,7 @@
$('div.overlay').remove();
if (args.message) {
cloudStack.dialog.notice({ message: args.message });
//cloudStack.dialog.notice({ message: args.message });
}
}
}

View File

@ -46,48 +46,56 @@
var $chart = $('#template').find('.network-chart.static-nat').clone();
var $vmName = $chart.find('li.static-nat-enabled .vmname');
var $browser = $('#browser .container');
var vmID = context.ipAddresses[0].virtualmachineid;
var vmName = context.ipAddresses[0].virtualmachinename;
var vmDetails = args.vmDetails;
var vmDataProvider = args.vmDataProvider;
var vmDetails = args.vmDetails;
args.staticNATDataProvider({
context: context,
response: {
success: function(args) {
var vmID = args.data.virtualmachineid;
var vmName = args.data.virtualmachinename;
$vmName.append(
$('<span>').html('VM: ' + vmName)
);
$vmName.click(function() {
$browser.cloudBrowser('addPanel', {
title: 'Static NAT VM Details',
complete: function($newPanel) {
vmDataProvider({
context: context,
response: {
success: function(args) {
var instance = args.data;
var detailViewArgs = $.extend(true, {}, vmDetails, {
$browser: $browser,
context: $.extend(true, {}, context, {
instances: [instance]
}),
jsonObj: instance,
id: instance.id
});
// No actions available
detailViewArgs.actions = {};
$newPanel.detailView(detailViewArgs);
}
}
});
}
});
});
}
}
});
$chart.find('li.firewall .view-details').click(function() {
makeMultiEditPanel($(this), { title: 'NAT Port Range'});
});
$vmName.append(
$('<span>').html('VM: ' + vmName)
);
$vmName.click(function() {
$browser.cloudBrowser('addPanel', {
title: 'Static NAT VM Details',
complete: function($newPanel) {
vmDataProvider({
context: context,
response: {
success: function(args) {
var instance = args.data;
var detailViewArgs = $.extend(true, {}, vmDetails, {
$browser: $browser,
context: $.extend(true, {}, context, {
instances: [instance]
}),
jsonObj: instance,
id: instance.id
});
// No actions available
detailViewArgs.actions = {};
$newPanel.detailView(detailViewArgs);
}
}
});
}
});
});
return $chart;
};

View File

@ -61,7 +61,7 @@
});
},
error: function(args) {
cloudStack.dialog.notice({ message: 'Invalid username and/or password.' });
//cloudStack.dialog.notice({ message: 'Invalid username and/or password.' });
}
}
});

View File

@ -142,8 +142,8 @@
return false;
});
// Add button action
$chartView.find('.add').click(function() {
// Add Resource button action
$chartView.find('#add_resource_button').click(function() {
var completeAction = function() { return false; };
var $addResource = $('<div>').addClass('add-zone-resource');
var $header = $('<div>').addClass('head').appendTo($addResource)

View File

@ -42,7 +42,7 @@
$('div.overlay').remove();
if (args.message) {
cloudStack.dialog.notice({ message: args.message });
//cloudStack.dialog.notice({ message: args.message });
}
}
}

View File

@ -21,6 +21,7 @@
var $formContainer = $('<div>').addClass('form-container');
var $message = $('<span>').addClass('message').appendTo($formContainer).html(args.form.desc);
var $form = $('<form>').appendTo($formContainer);
var createLabel = args.form.createLabel;
// Render fields and events
$.each(args.form.fields, function(key, field) {
@ -297,7 +298,7 @@
},
buttons: [
{
text: 'Create',
text: createLabel ? createLabel : 'Create',
'class': 'ok',
click: function() {
if (!complete($formContainer)) { return false; }
@ -372,6 +373,7 @@
'class': 'close',
click: function() {
$(this).dialog('destroy');
if (args.clickAction) args.clickAction();
}
}
]

View File

@ -158,6 +158,8 @@
if (isDestroy) {
$loading.remove();
$dataItem.remove();
} else {
$(window).trigger('cloudStack.fullRefresh');
}
complete();
@ -385,7 +387,7 @@
error: function(args) { }
}
});
} else if (field.edit) {
} else if (field.edit && field.edit != 'ignore') {
if (field.range) {
var $range = $('<div>').addClass('range').appendTo($td);
@ -428,6 +430,7 @@
// from main instances list view
var $listView;
var instances = $.extend(true, {}, args.listView, {
context: context,
uiCustom: true
});
@ -482,7 +485,7 @@
// Loading appearance
var $loading = _medit.loadingItem($multi, 'Adding...');
$dataBody.append($loading);
$dataBody.prepend($loading);
// Clear out fields
$multi.find('input').val('');
@ -510,21 +513,7 @@
complete: function(completeArgs) {
complete(args);
$loading.remove();
_medit.addItem(
data,
args.fields,
$multi,
itemData,
args.actions,
{
multipleAdd: multipleAdd,
noSelect: noSelect,
context: context,
ignoreEmptyFields: ignoreEmptyFields,
preFilter: actionPreFilter
}
).appendTo($dataBody);
$(window).trigger('cloudStack.fullRefresh');
},
error: function(args) {
@ -537,8 +526,6 @@
}
});
}
_medit.refreshItemWidths($multi);
},
error: cloudStack.dialog.error(function() {
@ -599,34 +586,43 @@
return true;
});
// Get existing data
dataProvider({
context: context,
response: {
success: function(args) {
$(args.data).each(function() {
var data = this;
var itemData = this._itemData;
_medit.addItem(
data,
fields,
$multi,
itemData,
actions,
{
multipleAdd: multipleAdd,
noSelect: noSelect,
context: $.extend(true, {}, context, this._context),
ignoreEmptyFields: ignoreEmptyFields,
preFilter: actionPreFilter
}
).appendTo($dataBody);
});
var getData = function() {
dataProvider({
context: context,
response: {
success: function(args) {
$multi.find('.data-item').remove();
$(args.data).each(function() {
var data = this;
var itemData = this._itemData;
_medit.addItem(
data,
fields,
$multi,
itemData,
actions,
{
multipleAdd: multipleAdd,
noSelect: noSelect,
context: $.extend(true, {}, context, this._context),
ignoreEmptyFields: ignoreEmptyFields,
preFilter: actionPreFilter
}
).appendTo($dataBody);
});
_medit.refreshItemWidths($multi);
},
error: cloudStack.dialog.error
}
_medit.refreshItemWidths($multi);
},
error: cloudStack.dialog.error
}
});
};
// Get existing data
getData();
$(window).bind('cloudStack.fullRefresh', function(event) {
getData();
});
$multi.bind('change select', function() {

View File

@ -316,7 +316,7 @@
}
});
$(window).bind('click', cloudStack.ui.event.bind(
$('#breadcrumbs li').live('click', cloudStack.ui.event.bind(
'cloudBrowser',
{
'breadcrumb': function($target, $browser, data) {

View File

@ -52,7 +52,7 @@
var $row = $detailView.data('list-view-row');
if (!$row) return;
var $listView = $row.closest('.list-view');
var $newRow;
var jsonObj = $row.data('json-obj');
@ -62,7 +62,7 @@
data: $.extend(jsonObj, newData),
after: function($newRow) {
$detailView.data('list-view-row', $newRow);
setTimeout(function() {
$('.data-table').dataTable('selectRow', $newRow.index());
}, 100);
@ -100,7 +100,7 @@
var $detailViewElems = $detailView.find('ul.ui-tabs-nav, .detail-group').remove();
$detailView.tabs('destroy');
$detailView.data('view-args').jsonObj = newData;
makeTabs(
$detailView,
$detailView.data('view-args').tabs,
@ -199,8 +199,8 @@
);
},
error: function(args) {
if (args.message)
cloudStack.dialog.notice({ message: args.message });
// if (args.message)
// cloudStack.dialog.notice({ message: args.message });
}
}
});
@ -288,12 +288,10 @@
var $inputs = $detailView.find('input[type=text], select');
var action = args.actions[args.actionName];
var id = $detailView.data('view-args').id;
var $editButton = $('<div>').addClass('button done').html('Apply')
.hide()
var $editButton = $('<div>').addClass('button done').html('Apply').hide()
.appendTo(
$detailView.find('.ui-tabs-panel:visible')
)
.fadeIn('fast');
$detailView.find('.ui-tabs-panel .detail-group.actions')
).fadeIn();
var convertInputs = function($inputs) {
// Save and turn back into labels
@ -353,7 +351,7 @@
$.extend(true, {}, action.notification, notificationArgs),
function(args) {
replaceListViewItem($detailView, data);
convertInputs($inputs);
$loading.remove();
}, [],
@ -374,7 +372,7 @@
$value.html(originalValue);
});
if (args.message) cloudStack.dialog.notice({ message: args.message });
// if (args.message) cloudStack.dialog.notice({ message: args.message });
}
}
});
@ -807,7 +805,7 @@
options.newData
);
}
if (tabFilter) {
removedTabs = tabFilter({
context: context

View File

@ -221,8 +221,8 @@
);
},
error: function(data){
if (data.message)
cloudStack.dialog.notice({ message: data.message });
// if (data.message)
// cloudStack.dialog.notice({ message: data.message });
}
}
};
@ -343,7 +343,7 @@
},
error: function(args) {
if (args.message) {
cloudStack.dialog.notice({ message: args.message });
//cloudStack.dialog.notice({ message: args.message });
$edit.hide(),
$label.html(oldVal).fadeIn();
$instanceRow.closest('div.data-table').dataTable('refresh');
@ -723,6 +723,8 @@
}
});
$tr.find('td:first').addClass('first');
// Add reorder actions
if (reorder) {
$('<td>').addClass('actions reorder').appendTo($tr).append(function() {
@ -896,7 +898,7 @@
},
error: function(args) {
if (args.message) {
cloudStack.dialog.notice({ message: args.message });
//cloudStack.dialog.notice({ message: args.message });
}
}
}
@ -1090,16 +1092,7 @@
return true;
});
// Setup filter events
$listView.find('.button.search, select, input[type=text]').bind('click change', function(event) {
if ($(event.target).closest('.section-select').size()) return true;
if ((event.type == 'click' ||
event.type == 'mouseup') &&
($(event.target).is('select') ||
$(event.target).is('option') ||
$(event.target).is('input')))
return true;
var search = function() {
loadBody(
$table,
listViewData.dataProvider,
@ -1108,7 +1101,7 @@
{
page: 1,
filterBy: {
kind: $listView.find('select[id=filterBy]').val(),
kind: $listView.find('select[id=filterBy]').val(),
search: {
value: $listView.find('input[type=text]').val(),
by: 'name'
@ -1120,6 +1113,23 @@
context: $listView.data('view-args').context
}
);
};
$listView.find('.search-bar input[type=text]').change(function(event) {
search();
});
// Setup filter events
$listView.find('.button.search, select').bind('change', function(event) {
if ($(event.target).closest('.section-select').size()) return true;
if ((event.type == 'click' ||
event.type == 'mouseup') &&
($(event.target).is('select') ||
$(event.target).is('option') ||
$(event.target).is('input')))
return true;
search();
return true;
});

View File

@ -89,7 +89,7 @@
incomplete: function(args) {},
error: function(args) {
if (args.message) {
cloudStack.dialog.notice({ message: args.message });
//cloudStack.dialog.notice({ message: args.message });
}
clearInterval(pollTimer);