mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Merge branch '4.11'
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
This commit is contained in:
commit
72e61bfa1d
@ -57,6 +57,10 @@ public interface NetworkOffering extends InfrastructureEntity, InternalIdentity,
|
||||
public final static String DefaultIsolatedNetworkOfferingForVpcNetworks = "DefaultIsolatedNetworkOfferingForVpcNetworks";
|
||||
public final static String DefaultIsolatedNetworkOfferingForVpcNetworksNoLB = "DefaultIsolatedNetworkOfferingForVpcNetworksNoLB";
|
||||
public final static String DefaultIsolatedNetworkOfferingForVpcNetworksWithInternalLB = "DefaultIsolatedNetworkOfferingForVpcNetworksWithInternalLB";
|
||||
public final static String DefaultL2NetworkOffering = "DefaultL2NetworkOffering";
|
||||
public final static String DefaultL2NetworkOfferingVlan = "DefaultL2NetworkOfferingVlan";
|
||||
public final static String DefaultL2NetworkOfferingConfigDrive = "DefaultL2NetworkOfferingConfigDrive";
|
||||
public final static String DefaultL2NetworkOfferingConfigDriveVlan = "DefaultL2NetworkOfferingConfigDriveVlan";
|
||||
|
||||
/**
|
||||
* @return name for the network offering.
|
||||
|
||||
@ -561,6 +561,8 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
|
||||
offering.setDedicatedLB(false);
|
||||
_networkOfferingDao.update(offering.getId(), offering);
|
||||
}
|
||||
|
||||
_networkOfferingDao.persistDefaultL2NetworkOfferings();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@ -64,4 +64,9 @@ public interface NetworkOfferingDao extends GenericDao<NetworkOfferingVO, Long>
|
||||
List<Long> listNetworkOfferingID();
|
||||
|
||||
boolean isUsingServicePackage(String uuid);
|
||||
|
||||
/**
|
||||
* Create default L2 network offerings
|
||||
*/
|
||||
void persistDefaultL2NetworkOfferings();
|
||||
}
|
||||
|
||||
@ -23,6 +23,7 @@ import java.util.Map;
|
||||
import javax.inject.Inject;
|
||||
import javax.persistence.EntityExistsException;
|
||||
|
||||
import com.cloud.offerings.NetworkOfferingServiceMapVO;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@ -52,6 +53,8 @@ public class NetworkOfferingDaoImpl extends GenericDaoBase<NetworkOfferingVO, Lo
|
||||
private final GenericSearchBuilder<NetworkOfferingVO, Long> UpgradeSearch;
|
||||
@Inject
|
||||
NetworkOfferingDetailsDao _detailsDao;
|
||||
@Inject
|
||||
private NetworkOfferingServiceMapDao networkOfferingServiceMapDao;
|
||||
|
||||
protected NetworkOfferingDaoImpl() {
|
||||
super();
|
||||
@ -221,4 +224,49 @@ public class NetworkOfferingDaoImpl extends GenericDaoBase<NetworkOfferingVO, Lo
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Persist L2 deafult Network offering
|
||||
*/
|
||||
private void persistL2DefaultNetworkOffering(String name, String displayText, boolean specifyVlan, boolean configDriveEnabled) {
|
||||
NetworkOfferingVO offering = new NetworkOfferingVO(name, displayText, TrafficType.Guest, false, specifyVlan,
|
||||
null, null, true, Availability.Optional, null, Network.GuestType.L2,
|
||||
true,false, false, false, false, false);
|
||||
offering.setState(NetworkOffering.State.Enabled);
|
||||
persistDefaultNetworkOffering(offering);
|
||||
|
||||
if (configDriveEnabled) {
|
||||
NetworkOfferingServiceMapVO offService = new NetworkOfferingServiceMapVO(offering.getId(),
|
||||
Network.Service.UserData, Network.Provider.ConfigDrive);
|
||||
networkOfferingServiceMapDao.persist(offService);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for default L2 Network Offerings, create them if they are not already created
|
||||
*/
|
||||
private void checkPersistL2NetworkOffering(String name, String displayText, boolean specifyVlan, boolean configDriveEnabled) {
|
||||
if (findByUniqueName(name) == null) {
|
||||
persistL2DefaultNetworkOffering(name, displayText, specifyVlan, configDriveEnabled);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void persistDefaultL2NetworkOfferings() {
|
||||
checkPersistL2NetworkOffering(NetworkOffering.DefaultL2NetworkOffering,
|
||||
"Offering for L2 networks",
|
||||
false, false);
|
||||
|
||||
checkPersistL2NetworkOffering(NetworkOffering.DefaultL2NetworkOfferingVlan,
|
||||
"Offering for L2 networks VLAN",
|
||||
true, false);
|
||||
|
||||
checkPersistL2NetworkOffering(NetworkOffering.DefaultL2NetworkOfferingConfigDrive,
|
||||
"Offering for L2 networks with config drive user data",
|
||||
false, true);
|
||||
|
||||
checkPersistL2NetworkOffering(NetworkOffering.DefaultL2NetworkOfferingConfigDriveVlan,
|
||||
"Offering for L2 networks with config drive user data VLAN",
|
||||
true, true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -286,7 +286,7 @@ public class ConfigDriveBuilder {
|
||||
if (!NetworkModel.METATDATA_DIR.equals(dataType)) {
|
||||
return;
|
||||
}
|
||||
if (StringUtils.isNotBlank(content)) {
|
||||
if (StringUtils.isEmpty(content)) {
|
||||
return;
|
||||
}
|
||||
//keys are a special case in OpenStack format
|
||||
|
||||
@ -1175,6 +1175,8 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio
|
||||
_ntwkOfferingServiceMapDao.persist(offService);
|
||||
s_logger.trace("Added service for the network offering: " + offService);
|
||||
}
|
||||
|
||||
_networkOfferingDao.persistDefaultL2NetworkOfferings();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -21,23 +21,28 @@ mountdir=$(mktemp -d)
|
||||
filepath=$mountdir/cloudstack
|
||||
|
||||
user_data=$filepath/userdata/user_data.txt
|
||||
availability_zone=$filepath/metadata/availability_zone.txt
|
||||
cloud_identifier=$filepath/metadata/cloud_identifier.txt
|
||||
instance_id=$filepath/metadata/instance_id.txt
|
||||
local_hostname=$filepath/metadata/local_hostname.txt
|
||||
service_offering=$filepath/metadata/service_offering.txt
|
||||
vm_id=$filepath/metadata/vm_id.txt
|
||||
public_key=$filepath/metadata/public_keys.txt
|
||||
vm_password=$filepath/password/vm_password.txt
|
||||
|
||||
declare -A metadata=(
|
||||
["availability-zone"]=$filepath/metadata/availability-zone.txt
|
||||
["cloud-identifier"]=$filepath/metadata/cloud-identifier.txt
|
||||
["instance-id"]=$filepath/metadata/instance-id.txt
|
||||
["local-hostname"]=$filepath/metadata/local-hostname.txt
|
||||
["local-ipv4"]=$filepath/metadata/local-ipv4.txt
|
||||
["public-ipv4"]=$filepath/metadata/public-ipv4.txt
|
||||
["service-offering"]=$filepath/metadata/service-offering.txt
|
||||
["vm-id"]=$filepath/metadata/vm-id.txt
|
||||
["public-key"]=$filepath/metadata/public-keys.txt
|
||||
)
|
||||
# If lable name is other than config, please change the below line as required
|
||||
DefaultDisk=/dev/disk/by-label/config-2
|
||||
|
||||
function usage
|
||||
{
|
||||
keys=${!metadata[@]}
|
||||
echo -e "USAGE: cloud-get-vm-data -options"
|
||||
echo -e " where options include:"
|
||||
echo -e "\\t-m | --metadata [availability-zone | cloud-identifier | instance-id | local-hostname | service-offering | vm-id | public-key] \\n\\t\\tprint vm metadata"
|
||||
echo -e "\\t-m | --metadata [${keys// / | }] \\n\\t\\tprint vm metadata"
|
||||
echo -e "\\t-p | --password \\n\\t\\tprint vm password"
|
||||
echo -e "\\t-u | --userdata \\n\\t\\tprint vm userdata"
|
||||
}
|
||||
@ -52,7 +57,7 @@ function prepare_mount
|
||||
if [ -e $DefaultDisk ]; then
|
||||
Disk=$DefaultDisk
|
||||
else
|
||||
BLOCK_DEVICE=$(blkid -t LABEL='config' /dev/hd? /dev/sd? /dev/xvd? -o device)
|
||||
BLOCK_DEVICE=$(blkid -t LABEL='config-2' /dev/sr? /dev/hd? /dev/sd? /dev/xvd? -o device)
|
||||
if [ -n $BLOCK_DEVICE ]; then
|
||||
Disk=$BLOCK_DEVICE
|
||||
else
|
||||
@ -81,34 +86,21 @@ case $1 in
|
||||
;;
|
||||
-m | --metadata ) shift
|
||||
if [ "$1" != "" ]; then
|
||||
case $1 in
|
||||
availability-zone ) echo -n "availability zone: "; filename=$availability_zone
|
||||
;;
|
||||
cloud-identifier ) echo -n "cloud identifier: "; filename=$cloud_identifier
|
||||
;;
|
||||
instance-id ) echo -n "instance-id: "; filename=$instance_id
|
||||
;;
|
||||
local-hostname ) echo -n "local-hostname: "; filename=$local_hostname
|
||||
;;
|
||||
service-offering ) echo -n "service-offering: "; filename=$service_offering
|
||||
;;
|
||||
vm-id ) echo -n "vm-id: "; filename=$vm_id
|
||||
;;
|
||||
public-key ) echo -n "public-key: "; filename=$public_key
|
||||
;;
|
||||
* ) usage
|
||||
remove_mount
|
||||
exit 1
|
||||
esac
|
||||
if [ -n "${metadata[$1]}" ]; then
|
||||
echo -n "$1: "
|
||||
filename=${metadata[$1]}
|
||||
else
|
||||
usage
|
||||
remove_mount
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo -e "METADATA\\n"
|
||||
[ -f $availability_zone ] && echo -e "availability zone:\t" "$(cat $availability_zone)"
|
||||
[ -f $cloud_identifier ] && echo -e "cloud identifier:\t" "$(cat $cloud_identifier)"
|
||||
[ -f $instance_id ] && echo -e "instance-id:\t\t" "$(cat $instance_id)"
|
||||
[ -f $local_hostname ] && echo -e "local-hostname:\t\t" "$(cat $local_hostname)"
|
||||
[ -f $service_offering ] && echo -e "service-offering:\t" "$(cat $service_offering)"
|
||||
[ -f $vm_id ] && echo -e "vm-id:\t\t\t" "$(cat $vm_id)"
|
||||
[ -f $public_key ] && echo -e "public-key:\t\t" "$(cat $public_key)"
|
||||
for entry in "${!metadata[@]}"
|
||||
do
|
||||
file=${metadata[$entry]}
|
||||
[ -f $file ] && printf "%18s :\t%s\n" $entry "$(cat $file)"
|
||||
done
|
||||
fi
|
||||
;;
|
||||
-p | --password ) echo -n "PASSWORD: "
|
||||
|
||||
@ -2407,14 +2407,17 @@
|
||||
if ($useVpcCb.is(':checked')) { //if useVpc is checked,
|
||||
$useVpcCb.removeAttr("checked"); //remove "checked" attribute in useVpc
|
||||
}
|
||||
$conservemode.css('display', 'inline-block');
|
||||
} else if ($guestTypeField.val() == 'Isolated') { //Isolated network offering
|
||||
$useVpc.css('display', 'inline-block');
|
||||
$supportedServices.css('display', 'inline-block');
|
||||
$userDataL2.hide();
|
||||
$conservemode.css('display', 'inline-block');
|
||||
} else if ($guestTypeField.val() == 'L2') {
|
||||
$useVpc.hide();
|
||||
$supportedServices.hide();
|
||||
$userDataL2.css('display', 'inline-block');
|
||||
$conservemode.hide();
|
||||
}
|
||||
var $providers = $useVpcCb.closest('form').find('.dynamic-input select[name!="service.Connectivity.provider"]');
|
||||
var $optionsOfProviders = $providers.find('option');
|
||||
@ -3398,6 +3401,9 @@
|
||||
} else {
|
||||
delete inputData.serviceProviderList;
|
||||
}
|
||||
|
||||
//Conserve mode is irrelevant on L2 network offerings as there are no resources to conserve, do not pass it, true by default on server side
|
||||
delete inputData.conservemode;
|
||||
}
|
||||
|
||||
if (inputData['forvpc'] == 'on') {
|
||||
@ -3406,10 +3412,12 @@
|
||||
delete inputData.forvpc; //if forVpc checkbox is unchecked, do not pass forVpc parameter to API call since we need to keep API call's size as small as possible (p.s. forVpc is defaulted as false at server-side)
|
||||
}
|
||||
|
||||
if (inputData['conservemode'] == 'on') {
|
||||
delete inputData.conservemode; //if ConserveMode checkbox is checked, do not pass conservemode parameter to API call since we need to keep API call's size as small as possible (p.s. conservemode is defaulted as true at server-side)
|
||||
} else {
|
||||
inputData['conservemode'] = false;
|
||||
if (inputData['guestIpType'] == "Shared" || inputData['guestIpType'] == "Isolated") {
|
||||
if (inputData['conservemode'] == 'on') {
|
||||
delete inputData.conservemode; //if ConserveMode checkbox is checked, do not pass conservemode parameter to API call since we need to keep API call's size as small as possible (p.s. conservemode is defaulted as true at server-side)
|
||||
} else {
|
||||
inputData['conservemode'] = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Make service provider map
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user