Merge branch '4.11'

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
This commit is contained in:
Rohit Yadav 2018-06-07 11:26:34 +05:30
commit 72e61bfa1d
8 changed files with 101 additions and 40 deletions

View File

@ -57,6 +57,10 @@ public interface NetworkOffering extends InfrastructureEntity, InternalIdentity,
public final static String DefaultIsolatedNetworkOfferingForVpcNetworks = "DefaultIsolatedNetworkOfferingForVpcNetworks"; public final static String DefaultIsolatedNetworkOfferingForVpcNetworks = "DefaultIsolatedNetworkOfferingForVpcNetworks";
public final static String DefaultIsolatedNetworkOfferingForVpcNetworksNoLB = "DefaultIsolatedNetworkOfferingForVpcNetworksNoLB"; public final static String DefaultIsolatedNetworkOfferingForVpcNetworksNoLB = "DefaultIsolatedNetworkOfferingForVpcNetworksNoLB";
public final static String DefaultIsolatedNetworkOfferingForVpcNetworksWithInternalLB = "DefaultIsolatedNetworkOfferingForVpcNetworksWithInternalLB"; 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. * @return name for the network offering.

View File

@ -561,6 +561,8 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
offering.setDedicatedLB(false); offering.setDedicatedLB(false);
_networkOfferingDao.update(offering.getId(), offering); _networkOfferingDao.update(offering.getId(), offering);
} }
_networkOfferingDao.persistDefaultL2NetworkOfferings();
} }
}); });

View File

@ -64,4 +64,9 @@ public interface NetworkOfferingDao extends GenericDao<NetworkOfferingVO, Long>
List<Long> listNetworkOfferingID(); List<Long> listNetworkOfferingID();
boolean isUsingServicePackage(String uuid); boolean isUsingServicePackage(String uuid);
/**
* Create default L2 network offerings
*/
void persistDefaultL2NetworkOfferings();
} }

View File

@ -23,6 +23,7 @@ import java.util.Map;
import javax.inject.Inject; import javax.inject.Inject;
import javax.persistence.EntityExistsException; import javax.persistence.EntityExistsException;
import com.cloud.offerings.NetworkOfferingServiceMapVO;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -52,6 +53,8 @@ public class NetworkOfferingDaoImpl extends GenericDaoBase<NetworkOfferingVO, Lo
private final GenericSearchBuilder<NetworkOfferingVO, Long> UpgradeSearch; private final GenericSearchBuilder<NetworkOfferingVO, Long> UpgradeSearch;
@Inject @Inject
NetworkOfferingDetailsDao _detailsDao; NetworkOfferingDetailsDao _detailsDao;
@Inject
private NetworkOfferingServiceMapDao networkOfferingServiceMapDao;
protected NetworkOfferingDaoImpl() { protected NetworkOfferingDaoImpl() {
super(); super();
@ -221,4 +224,49 @@ public class NetworkOfferingDaoImpl extends GenericDaoBase<NetworkOfferingVO, Lo
return false; 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);
}
} }

View File

@ -286,7 +286,7 @@ public class ConfigDriveBuilder {
if (!NetworkModel.METATDATA_DIR.equals(dataType)) { if (!NetworkModel.METATDATA_DIR.equals(dataType)) {
return; return;
} }
if (StringUtils.isNotBlank(content)) { if (StringUtils.isEmpty(content)) {
return; return;
} }
//keys are a special case in OpenStack format //keys are a special case in OpenStack format

View File

@ -1175,6 +1175,8 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio
_ntwkOfferingServiceMapDao.persist(offService); _ntwkOfferingServiceMapDao.persist(offService);
s_logger.trace("Added service for the network offering: " + offService); s_logger.trace("Added service for the network offering: " + offService);
} }
_networkOfferingDao.persistDefaultL2NetworkOfferings();
} }
}); });
} }

View File

@ -21,23 +21,28 @@ mountdir=$(mktemp -d)
filepath=$mountdir/cloudstack filepath=$mountdir/cloudstack
user_data=$filepath/userdata/user_data.txt 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 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 # If lable name is other than config, please change the below line as required
DefaultDisk=/dev/disk/by-label/config-2 DefaultDisk=/dev/disk/by-label/config-2
function usage function usage
{ {
keys=${!metadata[@]}
echo -e "USAGE: cloud-get-vm-data -options" echo -e "USAGE: cloud-get-vm-data -options"
echo -e " where options include:" 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-p | --password \\n\\t\\tprint vm password"
echo -e "\\t-u | --userdata \\n\\t\\tprint vm userdata" echo -e "\\t-u | --userdata \\n\\t\\tprint vm userdata"
} }
@ -52,7 +57,7 @@ function prepare_mount
if [ -e $DefaultDisk ]; then if [ -e $DefaultDisk ]; then
Disk=$DefaultDisk Disk=$DefaultDisk
else 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 if [ -n $BLOCK_DEVICE ]; then
Disk=$BLOCK_DEVICE Disk=$BLOCK_DEVICE
else else
@ -81,34 +86,21 @@ case $1 in
;; ;;
-m | --metadata ) shift -m | --metadata ) shift
if [ "$1" != "" ]; then if [ "$1" != "" ]; then
case $1 in if [ -n "${metadata[$1]}" ]; then
availability-zone ) echo -n "availability zone: "; filename=$availability_zone echo -n "$1: "
;; filename=${metadata[$1]}
cloud-identifier ) echo -n "cloud identifier: "; filename=$cloud_identifier else
;; usage
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 remove_mount
exit 1 exit 1
esac fi
else else
echo -e "METADATA\\n" echo -e "METADATA\\n"
[ -f $availability_zone ] && echo -e "availability zone:\t" "$(cat $availability_zone)" for entry in "${!metadata[@]}"
[ -f $cloud_identifier ] && echo -e "cloud identifier:\t" "$(cat $cloud_identifier)" do
[ -f $instance_id ] && echo -e "instance-id:\t\t" "$(cat $instance_id)" file=${metadata[$entry]}
[ -f $local_hostname ] && echo -e "local-hostname:\t\t" "$(cat $local_hostname)" [ -f $file ] && printf "%18s :\t%s\n" $entry "$(cat $file)"
[ -f $service_offering ] && echo -e "service-offering:\t" "$(cat $service_offering)" done
[ -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)"
fi fi
;; ;;
-p | --password ) echo -n "PASSWORD: " -p | --password ) echo -n "PASSWORD: "

View File

@ -2407,14 +2407,17 @@
if ($useVpcCb.is(':checked')) { //if useVpc is checked, if ($useVpcCb.is(':checked')) { //if useVpc is checked,
$useVpcCb.removeAttr("checked"); //remove "checked" attribute in useVpc $useVpcCb.removeAttr("checked"); //remove "checked" attribute in useVpc
} }
$conservemode.css('display', 'inline-block');
} else if ($guestTypeField.val() == 'Isolated') { //Isolated network offering } else if ($guestTypeField.val() == 'Isolated') { //Isolated network offering
$useVpc.css('display', 'inline-block'); $useVpc.css('display', 'inline-block');
$supportedServices.css('display', 'inline-block'); $supportedServices.css('display', 'inline-block');
$userDataL2.hide(); $userDataL2.hide();
$conservemode.css('display', 'inline-block');
} else if ($guestTypeField.val() == 'L2') { } else if ($guestTypeField.val() == 'L2') {
$useVpc.hide(); $useVpc.hide();
$supportedServices.hide(); $supportedServices.hide();
$userDataL2.css('display', 'inline-block'); $userDataL2.css('display', 'inline-block');
$conservemode.hide();
} }
var $providers = $useVpcCb.closest('form').find('.dynamic-input select[name!="service.Connectivity.provider"]'); var $providers = $useVpcCb.closest('form').find('.dynamic-input select[name!="service.Connectivity.provider"]');
var $optionsOfProviders = $providers.find('option'); var $optionsOfProviders = $providers.find('option');
@ -3398,6 +3401,9 @@
} else { } else {
delete inputData.serviceProviderList; 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') { if (inputData['forvpc'] == 'on') {
@ -3406,11 +3412,13 @@
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) 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['guestIpType'] == "Shared" || inputData['guestIpType'] == "Isolated") {
if (inputData['conservemode'] == 'on') { 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) 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 { } else {
inputData['conservemode'] = false; inputData['conservemode'] = false;
} }
}
// Make service provider map // Make service provider map
var serviceProviderIndex = 0; var serviceProviderIndex = 0;