mirror of https://github.com/apache/cloudstack.git
Merge branch 'main' into cks-enhancements-upstream
This commit is contained in:
commit
94bcc3f230
|
|
@ -58,6 +58,7 @@ github:
|
|||
- gpordeus
|
||||
- hsato03
|
||||
- bernardodemarco
|
||||
- abh1sar
|
||||
|
||||
protected_branches: ~
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,100 @@
|
|||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
# MD001/heading-increment Heading levels should only increment by one level at a time
|
||||
MD001: false
|
||||
|
||||
# MD003/heading-style Heading style
|
||||
MD003: false
|
||||
|
||||
# MD004/ul-style Unordered list style
|
||||
MD004: false
|
||||
|
||||
# MD007/ul-indent Unordered list indentation
|
||||
MD007: false
|
||||
|
||||
# MD009/no-trailing-spaces Trailing spaces
|
||||
MD009: false
|
||||
|
||||
# MD010/no-hard-tabs Hard tabs
|
||||
MD010: false
|
||||
|
||||
# MD012/no-multiple-blanks Multiple consecutive blank lines
|
||||
MD012: false
|
||||
|
||||
# MD013/line-length Line length
|
||||
MD013: false
|
||||
|
||||
# MD014/commands-show-output Dollar signs used before commands without showing output
|
||||
MD014: false
|
||||
|
||||
# MD018/no-missing-space-atx No space after hash on atx style heading
|
||||
MD018: false
|
||||
|
||||
# MD019/no-multiple-space-atx Multiple spaces after hash on atx style heading
|
||||
MD019: false
|
||||
|
||||
# MD022/blanks-around-headings Headings should be surrounded by blank lines
|
||||
MD022: false
|
||||
|
||||
# MD023/heading-start-left Headings must start at the beginning of the line
|
||||
MD023: false
|
||||
|
||||
# MD024/no-duplicate-heading Multiple headings with the same content
|
||||
MD024: false
|
||||
|
||||
# MD025/single-title/single-h1 Multiple top-level headings in the same document
|
||||
MD025: false
|
||||
|
||||
# MD026/no-trailing-punctuation Trailing punctuation in heading
|
||||
MD026: false
|
||||
|
||||
# MD028/no-blanks-blockquote Blank line inside blockquote
|
||||
MD028: false
|
||||
|
||||
# MD029/ol-prefix Ordered list item prefix
|
||||
MD029: false
|
||||
|
||||
# MD031/blanks-around-fences Fenced code blocks should be surrounded by blank lines
|
||||
MD031: false
|
||||
|
||||
# MD032/blanks-around-lists Lists should be surrounded by blank lines
|
||||
MD032: false
|
||||
|
||||
# MD033/no-inline-html Inline HTML
|
||||
MD033: false
|
||||
|
||||
# MD034/no-bare-urls Bare URL used
|
||||
MD034: false
|
||||
|
||||
# MD036/no-emphasis-as-heading Emphasis used instead of a heading
|
||||
MD036: false
|
||||
|
||||
# MD037/no-space-in-emphasis Spaces inside emphasis markers
|
||||
MD037: false
|
||||
|
||||
# MD040/fenced-code-language Fenced code blocks should have a language specified
|
||||
MD040: false
|
||||
|
||||
# MD041/first-line-heading/first-line-h1 First line in a file should be a top-level heading
|
||||
MD041: false
|
||||
|
||||
# MD046/code-block-style Code block style
|
||||
MD046: false
|
||||
|
||||
# MD052/reference-links-images Reference links and images should use a label that is defined
|
||||
MD052: false
|
||||
|
|
@ -36,6 +36,8 @@ repos:
|
|||
- id: check-vcs-permalinks
|
||||
#- id: check-yaml
|
||||
- id: destroyed-symlinks
|
||||
- id: detect-aws-credentials
|
||||
args: [--allow-missing-credentials]
|
||||
- id: detect-private-key
|
||||
exclude: >
|
||||
(?x)
|
||||
|
|
@ -53,9 +55,12 @@ repos:
|
|||
- id: end-of-file-fixer
|
||||
exclude: \.vhd$
|
||||
#- id: fix-byte-order-marker
|
||||
- id: forbid-submodules
|
||||
- id: mixed-line-ending
|
||||
exclude: \.(cs|xml)$
|
||||
# - id: trailing-whitespace
|
||||
- id: trailing-whitespace
|
||||
files: \.(in|java|md|py|rb|sh|vue|yaml|yml)$
|
||||
args: [--markdown-linebreak-ext=md]
|
||||
- repo: https://github.com/pycqa/flake8
|
||||
rev: 7.0.0
|
||||
hooks:
|
||||
|
|
@ -72,3 +77,12 @@ repos:
|
|||
^scripts/vm/hypervisor/xenserver/vmopspremium$|
|
||||
^setup/bindir/cloud-setup-encryption\.in$|
|
||||
^venv/.*$
|
||||
- repo: https://github.com/igorshubovych/markdownlint-cli
|
||||
rev: v0.40.0
|
||||
hooks:
|
||||
- id: markdownlint
|
||||
name: run markdownlint
|
||||
description: check Markdown files with markdownlint
|
||||
args: [--config=.github/linters/.markdown-lint.yml]
|
||||
types: [markdown]
|
||||
files: \.(md|mdown|markdown)$
|
||||
|
|
|
|||
16
CHANGES.md
16
CHANGES.md
|
|
@ -430,11 +430,11 @@ Bug ID | Description
|
|||
[CLOUDSTACK-6099](https://issues.apache.org/jira/browse/CLOUDSTACK-6099) | live migration is failing for vm deployed using dynamic compute offerings with NPE
|
||||
[CLOUDSTACK-7528](https://issues.apache.org/jira/browse/CLOUDSTACK-7528) | More verbose logging when sending alert fails
|
||||
[CLOUDSTACK-6624](https://issues.apache.org/jira/browse/CLOUDSTACK-6624) | set specifyIpRanges to true if specifyVlan is set to true
|
||||
[CLOUDSTACK-7404](https://issues.apache.org/jira/browse/CLOUDSTACK-7404) | Failed to start an instance when originating template has been deleted
|
||||
[CLOUDSTACK-7404](https://issues.apache.org/jira/browse/CLOUDSTACK-7404) | Failed to start an instance when originating template has been deleted
|
||||
[CLOUDSTACK-6531](https://issues.apache.org/jira/browse/CLOUDSTACK-6531) | Stopping the router in case of command failures
|
||||
[CLOUDSTACK-6115](https://issues.apache.org/jira/browse/CLOUDSTACK-6115) | TravisCI configuration
|
||||
[CLOUDSTACK-7405](https://issues.apache.org/jira/browse/CLOUDSTACK-7405) | allowing VR meta-data to be accessed without trailing slash
|
||||
[CLOUDSTACK-7260](https://issues.apache.org/jira/browse/CLOUDSTACK-7260) | Management server not responding after some time for Vmware due to Oom
|
||||
[CLOUDSTACK-7260](https://issues.apache.org/jira/browse/CLOUDSTACK-7260) | Management server not responding after some time for Vmware due to Oom
|
||||
[CLOUDSTACK-7038](https://issues.apache.org/jira/browse/CLOUDSTACK-7038) | Add mysql client dependency for mgmt server pkg for debian
|
||||
[CLOUDSTACK-6892](https://issues.apache.org/jira/browse/CLOUDSTACK-6892) | Create separate package for the mysql HA component
|
||||
[CLOUDSTACK-7038](https://issues.apache.org/jira/browse/CLOUDSTACK-7038) | Add mysql client dependency for mgmt server/rpms
|
||||
|
|
@ -449,12 +449,12 @@ Bug ID | Description
|
|||
[CLOUDSTACK-7006](https://issues.apache.org/jira/browse/CLOUDSTACK-7006) | Restore template ID in ROOT volume usages
|
||||
[CLOUDSTACK-6747](https://issues.apache.org/jira/browse/CLOUDSTACK-6747) | test to allow all cidrs on other end of vpc
|
||||
[CLOUDSTACK-6272](https://issues.apache.org/jira/browse/CLOUDSTACK-6272) | Fix recover/restore VM actions
|
||||
[CLOUDSTACK-6927](https://issues.apache.org/jira/browse/CLOUDSTACK-6927) | store virsh list in list instead of querying libvirt
|
||||
[CLOUDSTACK-6927](https://issues.apache.org/jira/browse/CLOUDSTACK-6927) | store virsh list in list instead of querying libvirt
|
||||
[CLOUDSTACK-6317](https://issues.apache.org/jira/browse/CLOUDSTACK-6317) | [VMware] Tagged VLAN support broken for Management/Control/Storage traffic
|
||||
[CLOUDSTACK-5891](https://issues.apache.org/jira/browse/CLOUDSTACK-5891) | [VMware] If a template has been registered and "cpu.corespersocket=X" ,
|
||||
[CLOUDSTACK-6478](https://issues.apache.org/jira/browse/CLOUDSTACK-6478) | Failed to download Template when having 3 SSVM's in one
|
||||
[CLOUDSTACK-6464](https://issues.apache.org/jira/browse/CLOUDSTACK-6464) | if guest network type is vlan://untagged, and traffic label is used
|
||||
[CLOUDSTACK-6816](https://issues.apache.org/jira/browse/CLOUDSTACK-6816) | bugfix: cloudstack-setup-management make /root directory's permission 0777
|
||||
[CLOUDSTACK-6816](https://issues.apache.org/jira/browse/CLOUDSTACK-6816) | bugfix: cloudstack-setup-management make /root directory's permission 0777
|
||||
[CLOUDSTACK-6204](https://issues.apache.org/jira/browse/CLOUDSTACK-6204) | applying missed patch
|
||||
[CLOUDSTACK-6472](https://issues.apache.org/jira/browse/CLOUDSTACK-6472) | (4.3 specific) listUsageRecords: Pull information from removed items as well
|
||||
[CLOUDSTACK-5976](https://issues.apache.org/jira/browse/CLOUDSTACK-5976) | Typo in "ssh_keypairs" table's foreign key constraints on the Upgraded Setup
|
||||
|
|
@ -657,11 +657,11 @@ Version 4.1.0
|
|||
-------------
|
||||
|
||||
This is the second major release of CloudStack from within the Apache Software Foundation, and the
|
||||
first major release as a Top-Level Project (TLP).
|
||||
first major release as a Top-Level Project (TLP).
|
||||
|
||||
Build Tool Changes:
|
||||
|
||||
* The project now uses Maven 3 exclusively to build.
|
||||
* The project now uses Maven 3 exclusively to build.
|
||||
|
||||
New Features:
|
||||
* CLOUDSTACK-101: OVS support in KVM
|
||||
|
|
@ -976,14 +976,14 @@ Issues fixed in this release:
|
|||
* CLOUDSTACK-1845: KVM - storage migration often fails
|
||||
* CLOUDSTACK-1846: KVM - storage pools can silently fail to be unregistered, leading to failure to register later
|
||||
* CLOUDSTACK-2003: Deleting domain while deleted account is cleaning up leaves VMs expunging forever due to 'Failed to update resource count'
|
||||
* CLOUDSTACK-2090: Upgrade from version 4.0.1 to version 4.0.2 triggers the 4.0.0 to 4.0.1.
|
||||
* CLOUDSTACK-2090: Upgrade from version 4.0.1 to version 4.0.2 triggers the 4.0.0 to 4.0.1.
|
||||
* CLOUDSTACK-2091: Error in API documentation for 4.0.x.
|
||||
|
||||
|
||||
Version 4.0.1-incubating
|
||||
------------------------
|
||||
|
||||
This is a bugfix release for Apache CloudStack 4.0.0-incubating, with no new features.
|
||||
This is a bugfix release for Apache CloudStack 4.0.0-incubating, with no new features.
|
||||
|
||||
Security Fixes:
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ Contributing to Apache CloudStack (ACS)
|
|||
|
||||
Summary
|
||||
-------
|
||||
This document covers how to contribute to the ACS project. ACS uses GitHub PRs to manage code contributions.
|
||||
This document covers how to contribute to the ACS project. ACS uses GitHub PRs to manage code contributions.
|
||||
These instructions assume you have a GitHub.com account, so if you don't have one you will have to create one. Your proposed code changes will be published to your own fork of the ACS project and you will submit a Pull Request for your changes to be added.
|
||||
|
||||
_Lets get started!!!_
|
||||
|
|
@ -11,17 +11,17 @@ _Lets get started!!!_
|
|||
Bug fixes
|
||||
---------
|
||||
|
||||
It's very important that we can easily track bug fix commits, so their hashes should remain the same in all branches.
|
||||
Therefore, a pull request (PR) that fixes a bug, should be sent against a release branch.
|
||||
This can be either the "current release" or the "previous release", depending on which ones are maintained.
|
||||
It's very important that we can easily track bug fix commits, so their hashes should remain the same in all branches.
|
||||
Therefore, a pull request (PR) that fixes a bug, should be sent against a release branch.
|
||||
This can be either the "current release" or the "previous release", depending on which ones are maintained.
|
||||
Since the goal is a stable main, bug fixes should be "merged forward" to the next branch in order: "previous release" -> "current release" -> main (in other words: old to new)
|
||||
|
||||
Developing new features
|
||||
-----------------------
|
||||
|
||||
Development should be done in a feature branch, branched off of main.
|
||||
Send a PR(steps below) to get it into main (2x LGTM applies).
|
||||
PR will only be merged when main is open, will be held otherwise until main is open again.
|
||||
Development should be done in a feature branch, branched off of main.
|
||||
Send a PR(steps below) to get it into main (2x LGTM applies).
|
||||
PR will only be merged when main is open, will be held otherwise until main is open again.
|
||||
No back porting / cherry-picking features to existing branches!
|
||||
|
||||
PendingReleaseNotes file
|
||||
|
|
@ -33,7 +33,7 @@ When adding information to the PendingReleaseNotes file make sure that you write
|
|||
|
||||
Updating the PendingReleaseNotes file is preferably a part of the original Pull Request, but that is up to the developers' discretion.
|
||||
|
||||
Fork the code
|
||||
Fork the code
|
||||
-------------
|
||||
|
||||
In your browser, navigate to: [https://github.com/apache/cloudstack](https://github.com/apache/cloudstack)
|
||||
|
|
@ -136,4 +136,4 @@ $ git push origin :feature_x
|
|||
|
||||
Release Principles
|
||||
------------------
|
||||
Detailed information about ACS release principles is available at https://cwiki.apache.org/confluence/display/CLOUDSTACK/Release+principles+for+Apache+CloudStack+4.6+and+up
|
||||
Detailed information about ACS release principles is available at https://cwiki.apache.org/confluence/display/CLOUDSTACK/Release+principles+for+Apache+CloudStack+4.6+and+up
|
||||
|
|
|
|||
|
|
@ -142,7 +142,7 @@ This distribution includes cryptographic software. The country in which you curr
|
|||
reside may have restrictions on the import, possession, use, and/or re-export to another
|
||||
country, of encryption software. BEFORE using any encryption software, please check your
|
||||
country's laws, regulations and policies concerning the import, possession, or use, and
|
||||
re-export of encryption software, to see if this is permitted. See [The Wassenaar Arrangement](http://www.wassenaar.org/)
|
||||
re-export of encryption software, to see if this is permitted. See [The Wassenaar Arrangement](http://www.wassenaar.org/)
|
||||
for more information.
|
||||
|
||||
The U.S. Government Department of Commerce, Bureau of Industry and Security (BIS), has
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@
|
|||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@
|
|||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
|
|
|
|||
|
|
@ -430,3 +430,6 @@ iscsi.session.cleanup.enabled=false
|
|||
# If set to "true", the agent will register for libvirt domain events, allowing for immediate updates on crashed or
|
||||
# unexpectedly stopped. Experimental, requires agent restart.
|
||||
# libvirt.events.enabled=false
|
||||
|
||||
# Implicit host tags managed by agent.properties
|
||||
# host.tags=
|
||||
|
|
|
|||
|
|
@ -5,9 +5,9 @@
|
|||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
|
|
|
|||
|
|
@ -803,6 +803,13 @@ public class AgentProperties{
|
|||
*/
|
||||
public static final Property<String> KEYSTORE_PASSPHRASE = new Property<>(KeyStoreUtils.KS_PASSPHRASE_PROPERTY, null, String.class);
|
||||
|
||||
/**
|
||||
* Implicit host tags
|
||||
* Data type: String.<br>
|
||||
* Default value: <code>null</code>
|
||||
*/
|
||||
public static final Property<String> HOST_TAGS = new Property<>("host.tags", null, String.class);
|
||||
|
||||
public static class Property <T>{
|
||||
private String name;
|
||||
private T defaultValue;
|
||||
|
|
|
|||
|
|
@ -266,6 +266,7 @@ public class ApiConstants {
|
|||
public static final String IS_EDGE = "isedge";
|
||||
public static final String IS_EXTRACTABLE = "isextractable";
|
||||
public static final String IS_FEATURED = "isfeatured";
|
||||
public static final String IS_IMPLICIT = "isimplicit";
|
||||
public static final String IS_PORTABLE = "isportable";
|
||||
public static final String IS_PUBLIC = "ispublic";
|
||||
public static final String IS_PERSISTENT = "ispersistent";
|
||||
|
|
@ -458,6 +459,7 @@ public class ApiConstants {
|
|||
public static final String TEMPLATE_IDS = "templateids";
|
||||
public static final String TEMPLATE_NAME = "templatename";
|
||||
public static final String TEMPLATE_TYPE = "templatetype";
|
||||
public static final String TEMPLATE_FORMAT = "templateformat";
|
||||
public static final String TIMEOUT = "timeout";
|
||||
public static final String TIMEZONE = "timezone";
|
||||
public static final String TIMEZONEOFFSET = "timezoneoffset";
|
||||
|
|
@ -1158,6 +1160,14 @@ public class ApiConstants {
|
|||
}
|
||||
}
|
||||
|
||||
public static final String PARAMETER_DESCRIPTION_START_DATE_POSSIBLE_FORMATS = "The recommended format is \"yyyy-MM-dd'T'HH:mm:ssZ\" (e.g.: \"2023-01-01T12:00:00+0100\"); " +
|
||||
"however, the following formats are also accepted: \"yyyy-MM-dd HH:mm:ss\" (e.g.: \"2023-01-01 12:00:00\") and \"yyyy-MM-dd\" (e.g.: \"2023-01-01\" - if the time is not " +
|
||||
"added, it will be interpreted as \"00:00:00\"). If the recommended format is not used, the date will be considered in the server timezone.";
|
||||
|
||||
public static final String PARAMETER_DESCRIPTION_END_DATE_POSSIBLE_FORMATS = "The recommended format is \"yyyy-MM-dd'T'HH:mm:ssZ\" (e.g.: \"2023-01-01T12:00:00+0100\"); " +
|
||||
"however, the following formats are also accepted: \"yyyy-MM-dd HH:mm:ss\" (e.g.: \"2023-01-01 12:00:00\") and \"yyyy-MM-dd\" (e.g.: \"2023-01-01\" - if the time is not " +
|
||||
"added, it will be interpreted as \"23:59:59\"). If the recommended format is not used, the date will be considered in the server timezone.";
|
||||
|
||||
public enum BootType {
|
||||
UEFI, BIOS;
|
||||
|
||||
|
|
|
|||
|
|
@ -53,16 +53,12 @@ public class ListUsageRecordsCmd extends BaseListCmd {
|
|||
@Parameter(name = ApiConstants.DOMAIN_ID, type = CommandType.UUID, entityType = DomainResponse.class, description = "List usage records for the specified domain.")
|
||||
private Long domainId;
|
||||
|
||||
@Parameter(name = ApiConstants.END_DATE,
|
||||
type = CommandType.DATE,
|
||||
required = true,
|
||||
description = "End date range for usage record query (use format \"yyyy-MM-dd\" or the new format \"yyyy-MM-dd HH:mm:ss\", e.g. startDate=2015-01-01 or startdate=2015-01-01 10:30:00).")
|
||||
@Parameter(name = ApiConstants.END_DATE, type = CommandType.DATE, required = true, description = "End date range for usage record query. " +
|
||||
ApiConstants.PARAMETER_DESCRIPTION_END_DATE_POSSIBLE_FORMATS)
|
||||
private Date endDate;
|
||||
|
||||
@Parameter(name = ApiConstants.START_DATE,
|
||||
type = CommandType.DATE,
|
||||
required = true,
|
||||
description = "Start date range for usage record query (use format \"yyyy-MM-dd\" or the new format \"yyyy-MM-dd HH:mm:ss\", e.g. startDate=2015-01-01 or startdate=2015-01-01 11:00:00).")
|
||||
@Parameter(name = ApiConstants.START_DATE, type = CommandType.DATE, required = true, description = "Start date range for usage record query. " +
|
||||
ApiConstants.PARAMETER_DESCRIPTION_START_DATE_POSSIBLE_FORMATS)
|
||||
private Date startDate;
|
||||
|
||||
@Parameter(name = ApiConstants.ACCOUNT_ID, type = CommandType.UUID, entityType = AccountResponse.class, description = "List usage records for the specified account")
|
||||
|
|
@ -137,11 +133,11 @@ public class ListUsageRecordsCmd extends BaseListCmd {
|
|||
}
|
||||
|
||||
public void setEndDate(Date endDate) {
|
||||
this.endDate = endDate == null ? null : new Date(endDate.getTime());
|
||||
this.endDate = endDate;
|
||||
}
|
||||
|
||||
public void setStartDate(Date startDate) {
|
||||
this.startDate = startDate == null ? null : new Date(startDate.getTime());
|
||||
this.startDate = startDate;
|
||||
}
|
||||
|
||||
public void setAccountId(Long accountId) {
|
||||
|
|
@ -167,8 +163,8 @@ public class ListUsageRecordsCmd extends BaseListCmd {
|
|||
@Override
|
||||
public void execute() {
|
||||
Pair<List<? extends Usage>, Integer> usageRecords = _usageService.getUsageRecords(this);
|
||||
ListResponse<UsageRecordResponse> response = new ListResponse<UsageRecordResponse>();
|
||||
List<UsageRecordResponse> usageResponses = new ArrayList<UsageRecordResponse>();
|
||||
ListResponse<UsageRecordResponse> response = new ListResponse<>();
|
||||
List<UsageRecordResponse> usageResponses = new ArrayList<>();
|
||||
Map<String, Set<ResourceTagResponse>> resourceTagResponseMap = null;
|
||||
if (usageRecords != null) {
|
||||
//read the resource tags details for all the resources in usage data and store in Map
|
||||
|
|
|
|||
|
|
@ -208,6 +208,14 @@ public class HostForMigrationResponse extends BaseResponse {
|
|||
@Param(description = "comma-separated list of tags for the host")
|
||||
private String hostTags;
|
||||
|
||||
@SerializedName("explicithosttags")
|
||||
@Param(description = "comma-separated list of explicit host tags for the host", since = "4.20.0")
|
||||
private String explicitHostTags;
|
||||
|
||||
@SerializedName("implicithosttags")
|
||||
@Param(description = "comma-separated list of implicit host tags for the host", since = "4.20.0")
|
||||
private String implicitHostTags;
|
||||
|
||||
@SerializedName("hasenoughcapacity")
|
||||
@Param(description = "true if this host has enough CPU and RAM capacity to migrate a VM to it, false otherwise")
|
||||
private Boolean hasEnoughCapacity;
|
||||
|
|
@ -414,6 +422,14 @@ public class HostForMigrationResponse extends BaseResponse {
|
|||
this.hostTags = hostTags;
|
||||
}
|
||||
|
||||
public void setExplicitHostTags(String explicitHostTags) {
|
||||
this.explicitHostTags = explicitHostTags;
|
||||
}
|
||||
|
||||
public void setImplicitHostTags(String implicitHostTags) {
|
||||
this.implicitHostTags = implicitHostTags;
|
||||
}
|
||||
|
||||
public void setHasEnoughCapacity(Boolean hasEnoughCapacity) {
|
||||
this.hasEnoughCapacity = hasEnoughCapacity;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -221,6 +221,14 @@ public class HostResponse extends BaseResponseWithAnnotations {
|
|||
@Param(description = "comma-separated list of tags for the host")
|
||||
private String hostTags;
|
||||
|
||||
@SerializedName("explicithosttags")
|
||||
@Param(description = "comma-separated list of explicit host tags for the host", since = "4.20.0")
|
||||
private String explicitHostTags;
|
||||
|
||||
@SerializedName("implicithosttags")
|
||||
@Param(description = "comma-separated list of implicit host tags for the host", since = "4.20.0")
|
||||
private String implicitHostTags;
|
||||
|
||||
@SerializedName(ApiConstants.IS_TAG_A_RULE)
|
||||
@Param(description = ApiConstants.PARAMETER_DESCRIPTION_IS_TAG_A_RULE)
|
||||
private Boolean isTagARule;
|
||||
|
|
@ -458,6 +466,22 @@ public class HostResponse extends BaseResponseWithAnnotations {
|
|||
this.hostTags = hostTags;
|
||||
}
|
||||
|
||||
public String getExplicitHostTags() {
|
||||
return explicitHostTags;
|
||||
}
|
||||
|
||||
public void setExplicitHostTags(String explicitHostTags) {
|
||||
this.explicitHostTags = explicitHostTags;
|
||||
}
|
||||
|
||||
public String getImplicitHostTags() {
|
||||
return implicitHostTags;
|
||||
}
|
||||
|
||||
public void setImplicitHostTags(String implicitHostTags) {
|
||||
this.implicitHostTags = implicitHostTags;
|
||||
}
|
||||
|
||||
public void setHasEnoughCapacity(Boolean hasEnoughCapacity) {
|
||||
this.hasEnoughCapacity = hasEnoughCapacity;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ package org.apache.cloudstack.api.response;
|
|||
import com.google.gson.annotations.SerializedName;
|
||||
import com.cloud.serializer.Param;
|
||||
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.BaseResponse;
|
||||
|
||||
public class HostTagResponse extends BaseResponse {
|
||||
|
|
@ -34,6 +35,10 @@ public class HostTagResponse extends BaseResponse {
|
|||
@Param(description = "the name of the host tag")
|
||||
private String name;
|
||||
|
||||
@SerializedName(ApiConstants.IS_IMPLICIT)
|
||||
@Param(description = "true if the host tag is implicit", since = "4.20.0")
|
||||
private boolean isImplicit;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
|
@ -57,4 +62,12 @@ public class HostTagResponse extends BaseResponse {
|
|||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public boolean isImplicit() {
|
||||
return isImplicit;
|
||||
}
|
||||
|
||||
public void setImplicit(boolean implicit) {
|
||||
isImplicit = implicit;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@
|
|||
// under the License.
|
||||
package org.apache.cloudstack.api.response;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
|
||||
|
|
@ -133,11 +134,11 @@ public class UsageRecordResponse extends BaseResponseWithTagInformation implemen
|
|||
|
||||
@SerializedName(ApiConstants.START_DATE)
|
||||
@Param(description = "start date of the usage record")
|
||||
private String startDate;
|
||||
private Date startDate;
|
||||
|
||||
@SerializedName(ApiConstants.END_DATE)
|
||||
@Param(description = "end date of the usage record")
|
||||
private String endDate;
|
||||
private Date endDate;
|
||||
|
||||
@SerializedName("issourcenat")
|
||||
@Param(description = "True if the IPAddress is source NAT")
|
||||
|
|
@ -160,7 +161,7 @@ public class UsageRecordResponse extends BaseResponseWithTagInformation implemen
|
|||
private String vpcId;
|
||||
|
||||
public UsageRecordResponse() {
|
||||
tags = new LinkedHashSet<ResourceTagResponse>();
|
||||
tags = new LinkedHashSet<>();
|
||||
}
|
||||
|
||||
public void setTags(Set<ResourceTagResponse> tags) {
|
||||
|
|
@ -245,11 +246,11 @@ public class UsageRecordResponse extends BaseResponseWithTagInformation implemen
|
|||
this.size = size;
|
||||
}
|
||||
|
||||
public void setStartDate(String startDate) {
|
||||
public void setStartDate(Date startDate) {
|
||||
this.startDate = startDate;
|
||||
}
|
||||
|
||||
public void setEndDate(String endDate) {
|
||||
public void setEndDate(Date endDate) {
|
||||
this.endDate = endDate;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -137,6 +137,10 @@ public class UserVmResponse extends BaseResponseWithTagInformation implements Co
|
|||
@Param(description = "the type of the template for the virtual machine", since = "4.19.0")
|
||||
private String templateType;
|
||||
|
||||
@SerializedName(ApiConstants.TEMPLATE_FORMAT)
|
||||
@Param(description = "the format of the template for the virtual machine", since = "4.19.1")
|
||||
private String templateFormat;
|
||||
|
||||
@SerializedName("templatedisplaytext")
|
||||
@Param(description = " an alternate display text of the template for the virtual machine")
|
||||
private String templateDisplayText;
|
||||
|
|
@ -1076,6 +1080,14 @@ public class UserVmResponse extends BaseResponseWithTagInformation implements Co
|
|||
this.templateType = templateType;
|
||||
}
|
||||
|
||||
public String getTemplateFormat() {
|
||||
return templateFormat;
|
||||
}
|
||||
|
||||
public void setTemplateFormat(String templateFormat) {
|
||||
this.templateFormat = templateFormat;
|
||||
}
|
||||
|
||||
public List<VnfNicResponse> getVnfNics() {
|
||||
return vnfNics;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,9 +7,9 @@
|
|||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
|
|
@ -46,7 +46,7 @@ cfg = "@MSCONF@/db.properties"
|
|||
#---------------------- option parsing and command line checks ------------------------
|
||||
|
||||
|
||||
usage = """%prog <license file> <-a | host names / IP addresses...>
|
||||
usage = """%prog <license file> <-a | host names / IP addresses...>
|
||||
|
||||
This command deploys the license file specified in the command line into a specific XenServer host or all XenServer hosts known to the management server."""
|
||||
|
||||
|
|
@ -88,7 +88,7 @@ def parseuserpwfromhosts(hosts):
|
|||
return creds
|
||||
|
||||
class XenServerConfigurator(Thread):
|
||||
|
||||
|
||||
def __init__(self,host,user,password,keyfiledata):
|
||||
Thread.__init__(self)
|
||||
self.host = host
|
||||
|
|
@ -99,7 +99,7 @@ class XenServerConfigurator(Thread):
|
|||
self.stdout = ""
|
||||
self.stderr = ""
|
||||
self.state = 'initialized'
|
||||
|
||||
|
||||
def run(self):
|
||||
try:
|
||||
self.state = 'running'
|
||||
|
|
@ -120,18 +120,18 @@ class XenServerConfigurator(Thread):
|
|||
c.close()
|
||||
if self.retval != 0: self.state = 'failed'
|
||||
else: self.state = 'finished'
|
||||
|
||||
|
||||
except Exception as e:
|
||||
self.state = 'failed'
|
||||
self.retval = e
|
||||
#raise
|
||||
|
||||
|
||||
def __str__(self):
|
||||
if self.state == 'failed':
|
||||
return "<%s XenServerConfigurator on %s@%s: %s>"%(self.state,self.user,self.host,str(self.retval))
|
||||
else:
|
||||
return "<%s XenServerConfigurator on %s@%s>"%(self.state,self.user,self.host)
|
||||
|
||||
|
||||
#------------- actual code --------------------
|
||||
|
||||
(options, args) = parser.parse_args()
|
||||
|
|
@ -162,7 +162,7 @@ for host,(user,password) in list(creds.items()):
|
|||
|
||||
|
||||
for c in configurators: c.start()
|
||||
|
||||
|
||||
for c in configurators:
|
||||
print(c.host + "...", end=' ')
|
||||
c.join()
|
||||
|
|
|
|||
|
|
@ -174,6 +174,10 @@ public class StartupRoutingCommand extends StartupCommand {
|
|||
this.hostTags.add(hostTag);
|
||||
}
|
||||
|
||||
public void setHostTags(List<String> hostTags) {
|
||||
this.hostTags = hostTags;
|
||||
}
|
||||
|
||||
public HashMap<String, HashMap<String, VgpuTypesInfo>> getGpuGroupDetails() {
|
||||
return groupDetails;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.cloud.dc.VlanVO;
|
||||
import org.apache.cloudstack.framework.config.ConfigKey;
|
||||
import org.apache.cloudstack.framework.config.impl.ConfigurationSubGroupVO;
|
||||
|
||||
|
|
@ -189,7 +190,7 @@ public interface ConfigurationManager {
|
|||
* @param caller
|
||||
* @return success/failure
|
||||
*/
|
||||
boolean deleteVlanAndPublicIpRange(long userId, long vlanDbId, Account caller);
|
||||
VlanVO deleteVlanAndPublicIpRange(long userId, long vlanDbId, Account caller);
|
||||
|
||||
void checkZoneAccess(Account caller, DataCenter zone);
|
||||
|
||||
|
|
|
|||
|
|
@ -259,6 +259,8 @@ import com.cloud.vm.dao.VMInstanceDao;
|
|||
import com.googlecode.ipv6.IPv6Address;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static com.cloud.configuration.ConfigurationManager.MESSAGE_DELETE_VLAN_IP_RANGE_EVENT;
|
||||
|
||||
/**
|
||||
* NetworkManagerImpl implements NetworkManager.
|
||||
*/
|
||||
|
|
@ -3324,17 +3326,17 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
|
|||
|
||||
final NetworkVO networkFinal = network;
|
||||
try {
|
||||
Transaction.execute(new TransactionCallbackNoReturn() {
|
||||
final List<VlanVO> deletedVlanRangeToPublish = Transaction.execute(new TransactionCallback<List<VlanVO>>() {
|
||||
@Override
|
||||
public void doInTransactionWithoutResult(final TransactionStatus status) {
|
||||
public List<VlanVO> doInTransaction(TransactionStatus status) {
|
||||
final NetworkGuru guru = AdapterBase.getAdapterByName(networkGurus, networkFinal.getGuruName());
|
||||
|
||||
if (!guru.trash(networkFinal, _networkOfferingDao.findById(networkFinal.getNetworkOfferingId()))) {
|
||||
throw new CloudRuntimeException("Failed to trash network.");
|
||||
}
|
||||
|
||||
if (!deleteVlansInNetwork(networkFinal, context.getCaller().getId(), callerAccount)) {
|
||||
logger.warn("Failed to delete network {}; was unable to cleanup corresponding ip ranges", networkFinal);
|
||||
Pair<Boolean, List<VlanVO>> deletedVlans = deleteVlansInNetwork(networkFinal, context.getCaller().getId(), callerAccount);
|
||||
if (!deletedVlans.first()) {
|
||||
logger.warn("Failed to delete network " + networkFinal + "; was unable to cleanup corresponding ip ranges");
|
||||
throw new CloudRuntimeException("Failed to delete network " + networkFinal + "; was unable to cleanup corresponding ip ranges");
|
||||
} else {
|
||||
// commit transaction only when ips and vlans for the network are released successfully
|
||||
|
|
@ -3367,8 +3369,10 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
|
|||
_resourceLimitMgr.decrementResourceCount(networkFinal.getAccountId(), ResourceType.network, networkFinal.getDisplayNetwork());
|
||||
}
|
||||
}
|
||||
return deletedVlans.second();
|
||||
}
|
||||
});
|
||||
publishDeletedVlanRanges(deletedVlanRangeToPublish);
|
||||
if (_networksDao.findById(network.getId()) == null) {
|
||||
// remove its related ACL permission
|
||||
final Pair<Class<?>, Long> networkMsg = new Pair<Class<?>, Long>(Network.class, networkFinal.getId());
|
||||
|
|
@ -3386,6 +3390,14 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
|
|||
return success;
|
||||
}
|
||||
|
||||
private void publishDeletedVlanRanges(List<VlanVO> deletedVlanRangeToPublish) {
|
||||
if (CollectionUtils.isNotEmpty(deletedVlanRangeToPublish)) {
|
||||
for (VlanVO vlan : deletedVlanRangeToPublish) {
|
||||
_messageBus.publish(_name, MESSAGE_DELETE_VLAN_IP_RANGE_EVENT, PublishScope.LOCAL, vlan);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean resourceCountNeedsUpdate(final NetworkOffering ntwkOff, final ACLType aclType) {
|
||||
//Update resource count only for Isolated account specific non-system networks
|
||||
|
|
@ -3393,15 +3405,19 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
|
|||
return updateResourceCount;
|
||||
}
|
||||
|
||||
protected boolean deleteVlansInNetwork(final NetworkVO network, final long userId, final Account callerAccount) {
|
||||
protected Pair<Boolean, List<VlanVO>> deleteVlansInNetwork(final NetworkVO network, final long userId, final Account callerAccount) {
|
||||
final long networkId = network.getId();
|
||||
//cleanup Public vlans
|
||||
final List<VlanVO> publicVlans = _vlanDao.listVlansByNetworkId(networkId);
|
||||
List<VlanVO> deletedPublicVlanRange = new ArrayList<>();
|
||||
boolean result = true;
|
||||
for (final VlanVO vlan : publicVlans) {
|
||||
if (!_configMgr.deleteVlanAndPublicIpRange(userId, vlan.getId(), callerAccount)) {
|
||||
logger.warn("Failed to delete vlan {});", vlan.getId());
|
||||
VlanVO vlanRange = _configMgr.deleteVlanAndPublicIpRange(userId, vlan.getId(), callerAccount);
|
||||
if (vlanRange == null) {
|
||||
logger.warn("Failed to delete vlan " + vlan.getId() + ");");
|
||||
result = false;
|
||||
} else {
|
||||
deletedPublicVlanRange.add(vlanRange);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -3421,7 +3437,7 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
|
|||
_dcDao.releaseVnet(BroadcastDomainType.getValue(network.getBroadcastUri()), network.getDataCenterId(),
|
||||
network.getPhysicalNetworkId(), network.getAccountId(), network.getReservationId());
|
||||
}
|
||||
return result;
|
||||
return new Pair<>(result, deletedPublicVlanRange);
|
||||
}
|
||||
|
||||
public class NetworkGarbageCollector extends ManagedContextRunnable {
|
||||
|
|
|
|||
|
|
@ -40,6 +40,9 @@ public class HostTagVO implements InternalIdentity {
|
|||
@Column(name = "tag")
|
||||
private String tag;
|
||||
|
||||
@Column(name = "is_implicit")
|
||||
private boolean isImplicit = false;
|
||||
|
||||
@Column(name = "is_tag_a_rule")
|
||||
private boolean isTagARule;
|
||||
|
||||
|
|
@ -74,6 +77,13 @@ public class HostTagVO implements InternalIdentity {
|
|||
return isTagARule;
|
||||
}
|
||||
|
||||
public void setIsImplicit(boolean isImplicit) {
|
||||
this.isImplicit = isImplicit;
|
||||
}
|
||||
|
||||
public boolean getIsImplicit() {
|
||||
return isImplicit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getId() {
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ import java.util.List;
|
|||
|
||||
import com.cloud.host.HostTagVO;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
import org.apache.cloudstack.api.response.HostTagResponse;
|
||||
import org.apache.cloudstack.framework.config.ConfigKey;
|
||||
|
||||
public interface HostTagsDao extends GenericDao<HostTagVO, Long> {
|
||||
|
|
@ -35,6 +36,13 @@ public interface HostTagsDao extends GenericDao<HostTagVO, Long> {
|
|||
|
||||
void deleteTags(long hostId);
|
||||
|
||||
boolean updateImplicitTags(long hostId, List<String> hostTags);
|
||||
|
||||
List<HostTagVO> getExplicitHostTags(long hostId);
|
||||
|
||||
List<HostTagVO> findHostRuleTags();
|
||||
|
||||
HostTagResponse newHostTagResponse(HostTagVO hostTag);
|
||||
|
||||
List<HostTagVO> searchByIds(Long... hostTagIds);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,10 +16,14 @@
|
|||
// under the License.
|
||||
package com.cloud.host.dao;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.cloudstack.api.response.HostTagResponse;
|
||||
import org.apache.cloudstack.framework.config.ConfigKey;
|
||||
import org.apache.cloudstack.framework.config.Configurable;
|
||||
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.host.HostTagVO;
|
||||
|
|
@ -30,14 +34,23 @@ import com.cloud.utils.db.SearchCriteria;
|
|||
import com.cloud.utils.db.TransactionLegacy;
|
||||
import com.cloud.utils.db.SearchCriteria.Func;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
@Component
|
||||
public class HostTagsDaoImpl extends GenericDaoBase<HostTagVO, Long> implements HostTagsDao, Configurable {
|
||||
protected final SearchBuilder<HostTagVO> HostSearch;
|
||||
protected final GenericSearchBuilder<HostTagVO, String> DistinctImplictTagsSearch;
|
||||
private final SearchBuilder<HostTagVO> stSearch;
|
||||
private final SearchBuilder<HostTagVO> tagIdsearch;
|
||||
private final SearchBuilder<HostTagVO> ImplicitTagsSearch;
|
||||
|
||||
@Inject
|
||||
private ConfigurationDao _configDao;
|
||||
|
||||
public HostTagsDaoImpl() {
|
||||
HostSearch = createSearchBuilder();
|
||||
HostSearch.and("hostId", HostSearch.entity().getHostId(), SearchCriteria.Op.EQ);
|
||||
HostSearch.and("isImplicit", HostSearch.entity().getIsImplicit(), SearchCriteria.Op.EQ);
|
||||
HostSearch.and("isTagARule", HostSearch.entity().getIsTagARule(), SearchCriteria.Op.EQ);
|
||||
HostSearch.done();
|
||||
|
||||
|
|
@ -46,6 +59,19 @@ public class HostTagsDaoImpl extends GenericDaoBase<HostTagVO, Long> implements
|
|||
DistinctImplictTagsSearch.and("hostIds", DistinctImplictTagsSearch.entity().getHostId(), SearchCriteria.Op.IN);
|
||||
DistinctImplictTagsSearch.and("implicitTags", DistinctImplictTagsSearch.entity().getTag(), SearchCriteria.Op.IN);
|
||||
DistinctImplictTagsSearch.done();
|
||||
|
||||
stSearch = createSearchBuilder();
|
||||
stSearch.and("idIN", stSearch.entity().getId(), SearchCriteria.Op.IN);
|
||||
stSearch.done();
|
||||
|
||||
tagIdsearch = createSearchBuilder();
|
||||
tagIdsearch.and("id", tagIdsearch.entity().getId(), SearchCriteria.Op.EQ);
|
||||
tagIdsearch.done();
|
||||
|
||||
ImplicitTagsSearch = createSearchBuilder();
|
||||
ImplicitTagsSearch.and("hostId", ImplicitTagsSearch.entity().getHostId(), SearchCriteria.Op.EQ);
|
||||
ImplicitTagsSearch.and("isImplicit", ImplicitTagsSearch.entity().getIsImplicit(), SearchCriteria.Op.EQ);
|
||||
ImplicitTagsSearch.done();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -74,6 +100,36 @@ public class HostTagsDaoImpl extends GenericDaoBase<HostTagVO, Long> implements
|
|||
txn.commit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateImplicitTags(long hostId, List<String> hostTags) {
|
||||
TransactionLegacy txn = TransactionLegacy.currentTxn();
|
||||
txn.start();
|
||||
SearchCriteria<HostTagVO> sc = ImplicitTagsSearch.create();
|
||||
sc.setParameters("hostId", hostId);
|
||||
sc.setParameters("isImplicit", true);
|
||||
boolean expunged = expunge(sc) > 0;
|
||||
boolean persisted = false;
|
||||
for (String tag : hostTags) {
|
||||
if (StringUtils.isNotBlank(tag)) {
|
||||
HostTagVO vo = new HostTagVO(hostId, tag.trim());
|
||||
vo.setIsImplicit(true);
|
||||
persist(vo);
|
||||
persisted = true;
|
||||
}
|
||||
}
|
||||
txn.commit();
|
||||
return expunged || persisted;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<HostTagVO> getExplicitHostTags(long hostId) {
|
||||
SearchCriteria<HostTagVO> sc = ImplicitTagsSearch.create();
|
||||
sc.setParameters("hostId", hostId);
|
||||
sc.setParameters("isImplicit", false);
|
||||
|
||||
return search(sc, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<HostTagVO> findHostRuleTags() {
|
||||
SearchCriteria<HostTagVO> sc = HostSearch.create();
|
||||
|
|
@ -89,6 +145,7 @@ public class HostTagsDaoImpl extends GenericDaoBase<HostTagVO, Long> implements
|
|||
txn.start();
|
||||
SearchCriteria<HostTagVO> sc = HostSearch.create();
|
||||
sc.setParameters("hostId", hostId);
|
||||
sc.setParameters("isImplicit", false);
|
||||
expunge(sc);
|
||||
|
||||
for (String tag : hostTags) {
|
||||
|
|
@ -110,4 +167,72 @@ public class HostTagsDaoImpl extends GenericDaoBase<HostTagVO, Long> implements
|
|||
public String getConfigComponentName() {
|
||||
return HostTagsDaoImpl.class.getSimpleName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public HostTagResponse newHostTagResponse(HostTagVO tag) {
|
||||
HostTagResponse tagResponse = new HostTagResponse();
|
||||
|
||||
tagResponse.setName(tag.getTag());
|
||||
tagResponse.setHostId(tag.getHostId());
|
||||
tagResponse.setImplicit(tag.getIsImplicit());
|
||||
|
||||
tagResponse.setObjectName("hosttag");
|
||||
|
||||
return tagResponse;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<HostTagVO> searchByIds(Long... tagIds) {
|
||||
String batchCfg = _configDao.getValue("detail.batch.query.size");
|
||||
|
||||
final int detailsBatchSize = batchCfg != null ? Integer.parseInt(batchCfg) : 2000;
|
||||
|
||||
// query details by batches
|
||||
List<HostTagVO> tagList = new ArrayList<>();
|
||||
int curr_index = 0;
|
||||
|
||||
if (tagIds.length > detailsBatchSize) {
|
||||
while ((curr_index + detailsBatchSize) <= tagIds.length) {
|
||||
Long[] ids = new Long[detailsBatchSize];
|
||||
|
||||
for (int k = 0, j = curr_index; j < curr_index + detailsBatchSize; j++, k++) {
|
||||
ids[k] = tagIds[j];
|
||||
}
|
||||
|
||||
SearchCriteria<HostTagVO> sc = stSearch.create();
|
||||
|
||||
sc.setParameters("idIN", (Object[])ids);
|
||||
|
||||
List<HostTagVO> vms = searchIncludingRemoved(sc, null, null, false);
|
||||
|
||||
if (vms != null) {
|
||||
tagList.addAll(vms);
|
||||
}
|
||||
|
||||
curr_index += detailsBatchSize;
|
||||
}
|
||||
}
|
||||
|
||||
if (curr_index < tagIds.length) {
|
||||
int batch_size = (tagIds.length - curr_index);
|
||||
// set the ids value
|
||||
Long[] ids = new Long[batch_size];
|
||||
|
||||
for (int k = 0, j = curr_index; j < curr_index + batch_size; j++, k++) {
|
||||
ids[k] = tagIds[j];
|
||||
}
|
||||
|
||||
SearchCriteria<HostTagVO> sc = stSearch.create();
|
||||
|
||||
sc.setParameters("idIN", (Object[])ids);
|
||||
|
||||
List<HostTagVO> tags = searchIncludingRemoved(sc, null, null, false);
|
||||
|
||||
if (tags != null) {
|
||||
tagList.addAll(tags);
|
||||
}
|
||||
}
|
||||
|
||||
return tagList;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,7 +33,6 @@ import java.util.List;
|
|||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import com.cloud.upgrade.dao.Upgrade41900to42000;
|
||||
import com.cloud.utils.FileUtil;
|
||||
import org.apache.cloudstack.utils.CloudStackVersion;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
|
@ -87,6 +86,8 @@ import com.cloud.upgrade.dao.Upgrade41710to41720;
|
|||
import com.cloud.upgrade.dao.Upgrade41720to41800;
|
||||
import com.cloud.upgrade.dao.Upgrade41800to41810;
|
||||
import com.cloud.upgrade.dao.Upgrade41810to41900;
|
||||
import com.cloud.upgrade.dao.Upgrade41900to41910;
|
||||
import com.cloud.upgrade.dao.Upgrade41910to42000;
|
||||
import com.cloud.upgrade.dao.Upgrade420to421;
|
||||
import com.cloud.upgrade.dao.Upgrade421to430;
|
||||
import com.cloud.upgrade.dao.Upgrade430to440;
|
||||
|
|
@ -226,7 +227,8 @@ public class DatabaseUpgradeChecker implements SystemIntegrityChecker {
|
|||
.next("4.17.2.0", new Upgrade41720to41800())
|
||||
.next("4.18.0.0", new Upgrade41800to41810())
|
||||
.next("4.18.1.0", new Upgrade41810to41900())
|
||||
.next("4.19.0.0", new Upgrade41900to42000())
|
||||
.next("4.19.0.0", new Upgrade41900to41910())
|
||||
.next("4.19.1.0", new Upgrade41910to42000())
|
||||
.build();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -29,12 +29,12 @@ import java.util.Map;
|
|||
import com.cloud.upgrade.SystemVmTemplateRegistration;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
|
||||
public class Upgrade41900to42000 extends DbUpgradeAbstractImpl implements DbUpgrade, DbUpgradeSystemVmTemplate {
|
||||
public class Upgrade41910to42000 extends DbUpgradeAbstractImpl implements DbUpgrade, DbUpgradeSystemVmTemplate {
|
||||
private SystemVmTemplateRegistration systemVmTemplateRegistration;
|
||||
|
||||
@Override
|
||||
public String[] getUpgradableVersionRange() {
|
||||
return new String[] {"4.19.0.0", "4.20.0.0"};
|
||||
return new String[] {"4.19.1.0", "4.20.0.0"};
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -49,7 +49,7 @@ public class Upgrade41900to42000 extends DbUpgradeAbstractImpl implements DbUpgr
|
|||
|
||||
@Override
|
||||
public InputStream[] getPrepareScripts() {
|
||||
final String scriptFile = "META-INF/db/schema-41900to42000.sql";
|
||||
final String scriptFile = "META-INF/db/schema-41910to42000.sql";
|
||||
final InputStream script = Thread.currentThread().getContextClassLoader().getResourceAsStream(scriptFile);
|
||||
if (script == null) {
|
||||
throw new CloudRuntimeException("Unable to find " + scriptFile);
|
||||
|
|
@ -65,7 +65,7 @@ public class Upgrade41900to42000 extends DbUpgradeAbstractImpl implements DbUpgr
|
|||
|
||||
@Override
|
||||
public InputStream[] getCleanupScripts() {
|
||||
final String scriptFile = "META-INF/db/schema-41900to42000-cleanup.sql";
|
||||
final String scriptFile = "META-INF/db/schema-41910to42000-cleanup.sql";
|
||||
final InputStream script = Thread.currentThread().getContextClassLoader().getResourceAsStream(scriptFile);
|
||||
if (script == null) {
|
||||
throw new CloudRuntimeException("Unable to find " + scriptFile);
|
||||
|
|
@ -24,8 +24,12 @@ import javax.persistence.GeneratedValue;
|
|||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
|
||||
@Entity
|
||||
@Table(name = "user_data")
|
||||
public class UserDataVO implements UserData {
|
||||
|
|
@ -58,6 +62,9 @@ public class UserDataVO implements UserData {
|
|||
@Column(name = "params", length = 4096)
|
||||
private String params;
|
||||
|
||||
@Column(name = GenericDao.REMOVED_COLUMN)
|
||||
private Date removed;
|
||||
|
||||
@Override
|
||||
public long getDomainId() {
|
||||
return domainId;
|
||||
|
|
@ -117,4 +124,12 @@ public class UserDataVO implements UserData {
|
|||
public void setParams(String params) {
|
||||
this.params = params;
|
||||
}
|
||||
|
||||
public void setRemoved(Date removed) {
|
||||
this.removed = removed;
|
||||
}
|
||||
|
||||
public Date getRemoved() {
|
||||
return removed;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -187,7 +187,6 @@
|
|||
<bean id="storageNetworkIpAddressDaoImpl" class="com.cloud.dc.dao.StorageNetworkIpAddressDaoImpl" />
|
||||
<bean id="storageNetworkIpRangeDaoImpl" class="com.cloud.dc.dao.StorageNetworkIpRangeDaoImpl" />
|
||||
<bean id="storagePoolJoinDaoImpl" class="com.cloud.api.query.dao.StoragePoolJoinDaoImpl" />
|
||||
<bean id="hostTagDaoImpl" class="com.cloud.api.query.dao.HostTagDaoImpl" />
|
||||
<bean id="storagePoolWorkDaoImpl" class="com.cloud.storage.dao.StoragePoolWorkDaoImpl" />
|
||||
<bean id="uploadDaoImpl" class="com.cloud.storage.dao.UploadDaoImpl" />
|
||||
<bean id="usageDaoImpl" class="com.cloud.usage.dao.UsageDaoImpl" />
|
||||
|
|
|
|||
|
|
@ -63,3 +63,5 @@ CREATE TABLE IF NOT EXISTS `cloud_usage`.`usage_vpc` (
|
|||
) ENGINE=InnoDB CHARSET=utf8;
|
||||
|
||||
CALL `cloud_usage`.`IDEMPOTENT_ADD_COLUMN`('cloud_usage.cloud_usage', 'state', 'VARCHAR(100) DEFAULT NULL');
|
||||
|
||||
CALL `cloud`.`IDEMPOTENT_ADD_COLUMN`('cloud.user_data', 'removed', 'datetime COMMENT "date removed or null, if still present"');
|
||||
|
|
|
|||
|
|
@ -80,6 +80,9 @@ CREATE TABLE IF NOT EXISTS `cloud_usage`.`quota_email_configuration`(
|
|||
CONSTRAINT `FK_quota_email_configuration_account_id` FOREIGN KEY (`account_id`) REFERENCES `cloud_usage`.`quota_account`(`account_id`),
|
||||
CONSTRAINT `FK_quota_email_configuration_email_template_id` FOREIGN KEY (`email_template_id`) REFERENCES `cloud_usage`.`quota_email_templates`(`id`));
|
||||
|
||||
-- Add `is_implicit` column to `host_tags` table
|
||||
CALL `cloud`.`IDEMPOTENT_ADD_COLUMN`('cloud.host_tags', 'is_implicit', 'int(1) UNSIGNED NOT NULL DEFAULT 0 COMMENT "If host tag is implicit or explicit" ');
|
||||
|
||||
-- Add for_cks column to the vm_template table
|
||||
CALL `cloud`.`IDEMPOTENT_ADD_COLUMN`('cloud.vm_template','for_cks', 'int(1) unsigned DEFAULT "0" COMMENT "if true, the template can be used for CKS cluster deployment"');
|
||||
|
||||
|
|
@ -53,7 +53,9 @@ SELECT
|
|||
host_pod_ref.uuid pod_uuid,
|
||||
host_pod_ref.name pod_name,
|
||||
GROUP_CONCAT(DISTINCT(host_tags.tag)) AS tag,
|
||||
`host_tags`.`is_tag_a_rule` AS `is_tag_a_rule`,
|
||||
GROUP_CONCAT(DISTINCT(explicit_host_tags.tag)) AS explicit_tag,
|
||||
GROUP_CONCAT(DISTINCT(implicit_host_tags.tag)) AS implicit_tag,
|
||||
`explicit_host_tags`.`is_tag_a_rule` AS `is_tag_a_rule`,
|
||||
guest_os_category.id guest_os_category_id,
|
||||
guest_os_category.uuid guest_os_category_uuid,
|
||||
guest_os_category.name guest_os_category_name,
|
||||
|
|
@ -89,6 +91,10 @@ FROM
|
|||
LEFT JOIN
|
||||
`cloud`.`host_tags` ON host_tags.host_id = host.id
|
||||
LEFT JOIN
|
||||
`cloud`.`host_tags` AS explicit_host_tags ON explicit_host_tags.host_id = host.id AND explicit_host_tags.is_implicit = 0
|
||||
LEFT JOIN
|
||||
`cloud`.`host_tags` AS implicit_host_tags ON implicit_host_tags.host_id = host.id AND implicit_host_tags.is_implicit = 1
|
||||
LEFT JOIN
|
||||
`cloud`.`op_host_capacity` mem_caps ON host.id = mem_caps.host_id
|
||||
AND mem_caps.capacity_type = 0
|
||||
LEFT JOIN
|
||||
|
|
|
|||
|
|
@ -74,6 +74,7 @@ SELECT
|
|||
`vm_template`.`uuid` AS `template_uuid`,
|
||||
`vm_template`.`name` AS `template_name`,
|
||||
`vm_template`.`type` AS `template_type`,
|
||||
`vm_template`.`format` AS `template_format`,
|
||||
`vm_template`.`display_text` AS `template_display_text`,
|
||||
`vm_template`.`enable_password` AS `password_enabled`,
|
||||
`iso`.`id` AS `iso_id`,
|
||||
|
|
|
|||
|
|
@ -43,10 +43,12 @@ public class QuotaBalanceCmd extends BaseCmd {
|
|||
@Parameter(name = ApiConstants.DOMAIN_ID, type = CommandType.UUID, required = true, entityType = DomainResponse.class, description = "If domain Id is given and the caller is domain admin then the statement is generated for domain.")
|
||||
private Long domainId;
|
||||
|
||||
@Parameter(name = ApiConstants.END_DATE, type = CommandType.DATE, description = "End date range for quota query. Use yyyy-MM-dd as the date format, e.g. startDate=2009-06-03.")
|
||||
@Parameter(name = ApiConstants.END_DATE, type = CommandType.DATE, description = "End of the period of the Quota balance." +
|
||||
ApiConstants.PARAMETER_DESCRIPTION_END_DATE_POSSIBLE_FORMATS)
|
||||
private Date endDate;
|
||||
|
||||
@Parameter(name = ApiConstants.START_DATE, type = CommandType.DATE, description = "Start date range quota query. Use yyyy-MM-dd as the date format, e.g. startDate=2009-06-01.")
|
||||
@Parameter(name = ApiConstants.START_DATE, type = CommandType.DATE, description = "Start of the period of the Quota balance. " +
|
||||
ApiConstants.PARAMETER_DESCRIPTION_START_DATE_POSSIBLE_FORMATS)
|
||||
private Date startDate;
|
||||
|
||||
@Parameter(name = ApiConstants.ACCOUNT_ID, type = CommandType.UUID, entityType = AccountResponse.class, description = "List usage records for the specified account")
|
||||
|
|
|
|||
|
|
@ -45,10 +45,12 @@ public class QuotaStatementCmd extends BaseCmd {
|
|||
@Parameter(name = ApiConstants.DOMAIN_ID, type = CommandType.UUID, required = true, entityType = DomainResponse.class, description = "Optional, If domain Id is given and the caller is domain admin then the statement is generated for domain.")
|
||||
private Long domainId;
|
||||
|
||||
@Parameter(name = ApiConstants.END_DATE, type = CommandType.DATE, required = true, description = "End date range for quota query. Use yyyy-MM-dd as the date format, e.g. startDate=2009-06-03.")
|
||||
@Parameter(name = ApiConstants.END_DATE, type = CommandType.DATE, required = true, description = "End of the period of the Quota statement. " +
|
||||
ApiConstants.PARAMETER_DESCRIPTION_END_DATE_POSSIBLE_FORMATS)
|
||||
private Date endDate;
|
||||
|
||||
@Parameter(name = ApiConstants.START_DATE, type = CommandType.DATE, required = true, description = "Start date range quota query. Use yyyy-MM-dd as the date format, e.g. startDate=2009-06-01.")
|
||||
@Parameter(name = ApiConstants.START_DATE, type = CommandType.DATE, required = true, description = "Start of the period of the Quota statement. " +
|
||||
ApiConstants.PARAMETER_DESCRIPTION_START_DATE_POSSIBLE_FORMATS)
|
||||
private Date startDate;
|
||||
|
||||
@Parameter(name = ApiConstants.TYPE, type = CommandType.INTEGER, description = "List quota usage records for the specified usage type")
|
||||
|
|
|
|||
|
|
@ -60,12 +60,12 @@ public class QuotaTariffCreateCmd extends BaseCmd {
|
|||
"value will be applied.", length = 65535)
|
||||
private String activationRule;
|
||||
|
||||
@Parameter(name = ApiConstants.START_DATE, type = CommandType.DATE, description = "The effective start date on/after which the quota tariff is effective. Use yyyy-MM-dd as"
|
||||
+ " the date format, e.g. startDate=2009-06-03. Inform null to use the current date.")
|
||||
@Parameter(name = ApiConstants.START_DATE, type = CommandType.DATE, description = "The effective start date on/after which the quota tariff is effective. Inform null to " +
|
||||
"use the current date. " + ApiConstants.PARAMETER_DESCRIPTION_START_DATE_POSSIBLE_FORMATS)
|
||||
private Date startDate;
|
||||
|
||||
@Parameter(name = ApiConstants.END_DATE, type = CommandType.DATE, description = "The end date of the quota tariff. Use yyyy-MM-dd as the date format, e.g."
|
||||
+ " endDate=2009-06-03.")
|
||||
@Parameter(name = ApiConstants.END_DATE, type = CommandType.DATE, description = "The end date of the quota tariff. If not informed, the tariff will be valid indefinitely. " +
|
||||
ApiConstants.PARAMETER_DESCRIPTION_END_DATE_POSSIBLE_FORMATS)
|
||||
private Date endDate;
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -44,18 +44,18 @@ public class QuotaTariffListCmd extends BaseListCmd {
|
|||
@Parameter(name = ApiConstants.USAGE_TYPE, type = CommandType.INTEGER, description = "Usage type of the resource")
|
||||
private Integer usageType;
|
||||
|
||||
@Parameter(name = ApiConstants.START_DATE, type = CommandType.DATE, description = "The start date of the quota tariff. Use yyyy-MM-dd as the date format, "
|
||||
+ "e.g. startDate=2009-06-03.")
|
||||
@Parameter(name = ApiConstants.START_DATE, type = CommandType.DATE, description = "The start date of the quota tariff. " +
|
||||
ApiConstants.PARAMETER_DESCRIPTION_START_DATE_POSSIBLE_FORMATS)
|
||||
private Date effectiveDate;
|
||||
|
||||
@Parameter(name = ApiConstants.END_DATE, type = CommandType.DATE, description = "The end date of the quota tariff. Use yyyy-MM-dd as the date format, e.g. "
|
||||
+ "endDate=2021-11-03.", since = "4.18.0.0")
|
||||
@Parameter(name = ApiConstants.END_DATE, type = CommandType.DATE, description = "The end date of the quota tariff. " +
|
||||
ApiConstants.PARAMETER_DESCRIPTION_END_DATE_POSSIBLE_FORMATS, since = "4.18.0.0")
|
||||
private Date endDate;
|
||||
|
||||
@Parameter(name = ApiConstants.NAME, type = CommandType.STRING, description = "The name of the quota tariff.", since = "4.18.0.0")
|
||||
private String name;
|
||||
|
||||
@Parameter(name = ApiConstants.LIST_ALL, type = CommandType.BOOLEAN, description = "False will list only not removed quota tariffs. If set to True, we will "
|
||||
@Parameter(name = ApiConstants.LIST_ALL, type = CommandType.BOOLEAN, description = "False will list only not removed quota tariffs. If set to true, we will "
|
||||
+ "list all, including the removed ones. The default is false.", since = "4.18.0.0")
|
||||
private boolean listAll = false;
|
||||
|
||||
|
|
|
|||
|
|
@ -52,8 +52,8 @@ public class QuotaTariffUpdateCmd extends BaseCmd {
|
|||
"Use yyyy-MM-dd as the date format, e.g. startDate=2009-06-03.")
|
||||
private Date startDate;
|
||||
|
||||
@Parameter(name = ApiConstants.END_DATE, type = CommandType.DATE, description = "The end date of the quota tariff. Use yyyy-MM-dd as the date format, e.g."
|
||||
+ " endDate=2009-06-03.", since = "4.18.0.0")
|
||||
@Parameter(name = ApiConstants.END_DATE, type = CommandType.DATE, description = "The end date of the quota tariff. " +
|
||||
ApiConstants.PARAMETER_DESCRIPTION_END_DATE_POSSIBLE_FORMATS, since = "4.18.0.0")
|
||||
private Date endDate;
|
||||
|
||||
@Parameter(name = ApiConstants.NAME, type = CommandType.STRING, required = true, description = "Quota tariff's name", length = 65535, since = "4.18.0.0")
|
||||
|
|
|
|||
|
|
@ -134,7 +134,7 @@ public class QuotaResponseBuilderImpl implements QuotaResponseBuilder {
|
|||
response.setName(tariff.getName());
|
||||
response.setEndDate(tariff.getEndDate());
|
||||
response.setDescription(tariff.getDescription());
|
||||
response.setUuid(tariff.getUuid());
|
||||
response.setId(tariff.getUuid());
|
||||
response.setRemoved(tariff.getRemoved());
|
||||
return response;
|
||||
}
|
||||
|
|
@ -376,8 +376,8 @@ public class QuotaResponseBuilderImpl implements QuotaResponseBuilder {
|
|||
|
||||
@Override
|
||||
public Pair<List<QuotaTariffVO>, Integer> listQuotaTariffPlans(final QuotaTariffListCmd cmd) {
|
||||
Date startDate = _quotaService.computeAdjustedTime(cmd.getEffectiveDate());
|
||||
Date endDate = _quotaService.computeAdjustedTime(cmd.getEndDate());
|
||||
Date startDate = cmd.getEffectiveDate();
|
||||
Date endDate = cmd.getEndDate();
|
||||
Integer usageType = cmd.getUsageType();
|
||||
String name = cmd.getName();
|
||||
boolean listAll = cmd.isListAll();
|
||||
|
|
@ -395,10 +395,10 @@ public class QuotaResponseBuilderImpl implements QuotaResponseBuilder {
|
|||
public QuotaTariffVO updateQuotaTariffPlan(QuotaTariffUpdateCmd cmd) {
|
||||
String name = cmd.getName();
|
||||
Double value = cmd.getValue();
|
||||
Date endDate = _quotaService.computeAdjustedTime(cmd.getEndDate());
|
||||
Date endDate = cmd.getEndDate();
|
||||
String description = cmd.getDescription();
|
||||
String activationRule = cmd.getActivationRule();
|
||||
Date now = _quotaService.computeAdjustedTime(new Date());
|
||||
Date now = new Date();
|
||||
|
||||
warnQuotaTariffUpdateDeprecatedFields(cmd);
|
||||
|
||||
|
|
@ -488,7 +488,7 @@ public class QuotaResponseBuilderImpl implements QuotaResponseBuilder {
|
|||
endDate, startDate));
|
||||
}
|
||||
|
||||
Date now = _quotaService.computeAdjustedTime(new Date());
|
||||
Date now = new Date();
|
||||
if (endDate.compareTo(now) < 0) {
|
||||
throw new InvalidParameterValueException(String.format("The quota tariff's end date [%s] cannot be less than now [%s].",
|
||||
endDate, now));
|
||||
|
|
@ -499,7 +499,7 @@ public class QuotaResponseBuilderImpl implements QuotaResponseBuilder {
|
|||
|
||||
@Override
|
||||
public QuotaCreditsResponse addQuotaCredits(Long accountId, Long domainId, Double amount, Long updatedBy, Boolean enforce) {
|
||||
Date despositedOn = _quotaService.computeAdjustedTime(new Date());
|
||||
Date despositedOn = new Date();
|
||||
QuotaBalanceVO qb = _quotaBalanceDao.findLaterBalanceEntry(accountId, domainId, despositedOn);
|
||||
|
||||
if (qb != null) {
|
||||
|
|
@ -643,8 +643,8 @@ public class QuotaResponseBuilderImpl implements QuotaResponseBuilder {
|
|||
int usageType = cmd.getUsageType();
|
||||
Date startDate = cmd.getStartDate();
|
||||
Date now = new Date();
|
||||
startDate = _quotaService.computeAdjustedTime(startDate == null ? now : startDate);
|
||||
Date endDate = _quotaService.computeAdjustedTime(cmd.getEndDate());
|
||||
startDate = startDate == null ? now : startDate;
|
||||
Date endDate = cmd.getEndDate();
|
||||
Double value = cmd.getValue();
|
||||
String description = cmd.getDescription();
|
||||
String activationRule = cmd.getActivationRule();
|
||||
|
|
@ -675,10 +675,8 @@ public class QuotaResponseBuilderImpl implements QuotaResponseBuilder {
|
|||
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Quota tariff with the provided UUID does not exist.");
|
||||
}
|
||||
|
||||
quotaTariff.setRemoved(_quotaService.computeAdjustedTime(new Date()));
|
||||
|
||||
quotaTariff.setRemoved(new Date());
|
||||
CallContext.current().setEventResourceId(quotaTariff.getId());
|
||||
|
||||
return _quotaTariffDao.updateQuotaTariff(quotaTariff);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ package org.apache.cloudstack.api.response;
|
|||
import com.cloud.serializer.Param;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.BaseResponse;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
|
@ -74,9 +75,9 @@ public class QuotaTariffResponse extends BaseResponse {
|
|||
@Param(description = "description")
|
||||
private String description;
|
||||
|
||||
@SerializedName("uuid")
|
||||
@Param(description = "uuid")
|
||||
private String uuid;
|
||||
@SerializedName(ApiConstants.ID)
|
||||
@Param(description = "the ID of the tariff")
|
||||
private String id;
|
||||
|
||||
@SerializedName("removed")
|
||||
@Param(description = "when the quota tariff was removed")
|
||||
|
|
@ -87,15 +88,6 @@ public class QuotaTariffResponse extends BaseResponse {
|
|||
this.setObjectName("quotatariff");
|
||||
}
|
||||
|
||||
public QuotaTariffResponse(final int usageType) {
|
||||
super();
|
||||
this.usageType = usageType;
|
||||
}
|
||||
|
||||
public String getUsageName() {
|
||||
return usageName;
|
||||
}
|
||||
|
||||
public void setUsageName(String usageName) {
|
||||
this.usageName = usageName;
|
||||
}
|
||||
|
|
@ -108,18 +100,10 @@ public class QuotaTariffResponse extends BaseResponse {
|
|||
this.usageType = usageType;
|
||||
}
|
||||
|
||||
public String getUsageUnit() {
|
||||
return usageUnit;
|
||||
}
|
||||
|
||||
public void setUsageUnit(String usageUnit) {
|
||||
this.usageUnit = usageUnit;
|
||||
}
|
||||
|
||||
public String getUsageDiscriminator() {
|
||||
return usageDiscriminator;
|
||||
}
|
||||
|
||||
public void setUsageDiscriminator(String usageDiscriminator) {
|
||||
this.usageDiscriminator = usageDiscriminator;
|
||||
}
|
||||
|
|
@ -132,26 +116,14 @@ public class QuotaTariffResponse extends BaseResponse {
|
|||
this.tariffValue = tariffValue;
|
||||
}
|
||||
|
||||
public String getUsageTypeDescription() {
|
||||
return usageTypeDescription;
|
||||
}
|
||||
|
||||
public void setUsageTypeDescription(String usageTypeDescription) {
|
||||
this.usageTypeDescription = usageTypeDescription;
|
||||
}
|
||||
|
||||
public Date getEffectiveOn() {
|
||||
return effectiveOn;
|
||||
}
|
||||
|
||||
public void setEffectiveOn(Date effectiveOn) {
|
||||
this.effectiveOn = effectiveOn;
|
||||
}
|
||||
|
||||
public String getCurrency() {
|
||||
return currency;
|
||||
}
|
||||
|
||||
public void setCurrency(String currency) {
|
||||
this.currency = currency;
|
||||
}
|
||||
|
|
@ -188,16 +160,12 @@ public class QuotaTariffResponse extends BaseResponse {
|
|||
this.description = description;
|
||||
}
|
||||
|
||||
public String getUuid() {
|
||||
return uuid;
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setUuid(String uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
public Date getRemoved() {
|
||||
return removed;
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public void setRemoved(Date removed) {
|
||||
|
|
|
|||
|
|
@ -32,8 +32,6 @@ public interface QuotaService extends PluggableService {
|
|||
|
||||
List<QuotaBalanceVO> findQuotaBalanceVO(Long accountId, String accountName, Long domainId, Date startDate, Date endDate);
|
||||
|
||||
Date computeAdjustedTime(Date date);
|
||||
|
||||
void setLockAccount(Long accountId, Boolean state);
|
||||
|
||||
void setMinBalance(Long accountId, Double balance);
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ package org.apache.cloudstack.quota;
|
|||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
|
@ -165,36 +164,32 @@ public class QuotaServiceImpl extends ManagerBase implements QuotaService, Confi
|
|||
|
||||
if (endDate == null) {
|
||||
// adjust start date to end of day as there is no end date
|
||||
Date adjustedStartDate = computeAdjustedTime(_respBldr.startOfNextDay(startDate));
|
||||
startDate = _respBldr.startOfNextDay(startDate);
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("getQuotaBalance1: Getting quota balance records for account: " + accountId + ", domainId: " + domainId + ", on or before " + adjustedStartDate);
|
||||
logger.debug("getQuotaBalance1: Getting quota balance records for account: " + accountId + ", domainId: " + domainId + ", on or before " + startDate);
|
||||
}
|
||||
List<QuotaBalanceVO> qbrecords = _quotaBalanceDao.lastQuotaBalanceVO(accountId, domainId, adjustedStartDate);
|
||||
List<QuotaBalanceVO> qbrecords = _quotaBalanceDao.lastQuotaBalanceVO(accountId, domainId, startDate);
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Found records size=" + qbrecords.size());
|
||||
}
|
||||
if (qbrecords.isEmpty()) {
|
||||
logger.info("Incorrect Date there are no quota records before this date " + adjustedStartDate);
|
||||
logger.info("Incorrect Date there are no quota records before this date " + startDate);
|
||||
return qbrecords;
|
||||
} else {
|
||||
return qbrecords;
|
||||
}
|
||||
} else {
|
||||
Date adjustedStartDate = computeAdjustedTime(startDate);
|
||||
if (endDate.after(_respBldr.startOfNextDay())) {
|
||||
throw new InvalidParameterValueException("Incorrect Date Range. End date:" + endDate + " should not be in future. ");
|
||||
} else if (startDate.before(endDate)) {
|
||||
Date adjustedEndDate = computeAdjustedTime(endDate);
|
||||
if (startDate.before(endDate)) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("getQuotaBalance2: Getting quota balance records for account: " + accountId + ", domainId: " + domainId + ", between " + adjustedStartDate
|
||||
+ " and " + adjustedEndDate);
|
||||
logger.debug("getQuotaBalance2: Getting quota balance records for account: " + accountId + ", domainId: " + domainId + ", between " + startDate
|
||||
+ " and " + endDate);
|
||||
}
|
||||
List<QuotaBalanceVO> qbrecords = _quotaBalanceDao.findQuotaBalance(accountId, domainId, adjustedStartDate, adjustedEndDate);
|
||||
List<QuotaBalanceVO> qbrecords = _quotaBalanceDao.findQuotaBalance(accountId, domainId, startDate, endDate);
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("getQuotaBalance3: Found records size=" + qbrecords.size());
|
||||
}
|
||||
if (qbrecords.isEmpty()) {
|
||||
logger.info("There are no quota records between these dates start date " + adjustedStartDate + " and end date:" + endDate);
|
||||
logger.info("There are no quota records between these dates start date " + startDate + " and end date:" + endDate);
|
||||
return qbrecords;
|
||||
} else {
|
||||
return qbrecords;
|
||||
|
|
@ -230,44 +225,11 @@ public class QuotaServiceImpl extends ManagerBase implements QuotaService, Confi
|
|||
if (startDate.after(endDate)) {
|
||||
throw new InvalidParameterValueException("Incorrect Date Range. Start date: " + startDate + " is after end date:" + endDate);
|
||||
}
|
||||
if (endDate.after(_respBldr.startOfNextDay())) {
|
||||
throw new InvalidParameterValueException("Incorrect Date Range. End date:" + endDate + " should not be in future. ");
|
||||
}
|
||||
Date adjustedEndDate = computeAdjustedTime(endDate);
|
||||
Date adjustedStartDate = computeAdjustedTime(startDate);
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Getting quota records for account: " + accountId + ", domainId: " + domainId + ", between " + adjustedStartDate + " and " + adjustedEndDate);
|
||||
}
|
||||
return _quotaUsageDao.findQuotaUsage(accountId, domainId, usageType, adjustedStartDate, adjustedEndDate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Date computeAdjustedTime(final Date date) {
|
||||
if (date == null) {
|
||||
return null;
|
||||
}
|
||||
logger.debug("Getting quota records of type [{}] for account [{}] in domain [{}], between [{}] and [{}].",
|
||||
usageType, accountId, domainId, startDate, endDate);
|
||||
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTime(date);
|
||||
TimeZone localTZ = cal.getTimeZone();
|
||||
int timezoneOffset = cal.get(Calendar.ZONE_OFFSET);
|
||||
if (localTZ.inDaylightTime(date)) {
|
||||
timezoneOffset += (60 * 60 * 1000);
|
||||
}
|
||||
cal.add(Calendar.MILLISECOND, timezoneOffset);
|
||||
|
||||
Date newTime = cal.getTime();
|
||||
|
||||
Calendar calTS = Calendar.getInstance(_usageTimezone);
|
||||
calTS.setTime(newTime);
|
||||
timezoneOffset = calTS.get(Calendar.ZONE_OFFSET);
|
||||
if (_usageTimezone.inDaylightTime(date)) {
|
||||
timezoneOffset += (60 * 60 * 1000);
|
||||
}
|
||||
|
||||
calTS.add(Calendar.MILLISECOND, -1 * timezoneOffset);
|
||||
|
||||
return calTS.getTime();
|
||||
return _quotaUsageDao.findQuotaUsage(accountId, domainId, usageType, startDate, endDate);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -177,7 +177,6 @@ public class QuotaResponseBuilderImplTest extends TestCase {
|
|||
|
||||
Mockito.when(quotaCreditsDaoMock.saveCredits(Mockito.any(QuotaCreditsVO.class))).thenReturn(credit);
|
||||
Mockito.when(quotaBalanceDaoMock.lastQuotaBalance(Mockito.anyLong(), Mockito.anyLong(), Mockito.any(Date.class))).thenReturn(new BigDecimal(111));
|
||||
Mockito.when(quotaServiceMock.computeAdjustedTime(Mockito.any(Date.class))).thenReturn(new Date());
|
||||
|
||||
AccountVO account = new AccountVO();
|
||||
account.setState(Account.State.LOCKED);
|
||||
|
|
@ -245,7 +244,6 @@ public class QuotaResponseBuilderImplTest extends TestCase {
|
|||
entry.setCreditBalance(new BigDecimal(100));
|
||||
quotaBalance.add(entry);
|
||||
quotaBalance.add(entry);
|
||||
Mockito.lenient().when(quotaServiceMock.computeAdjustedTime(Mockito.any(Date.class))).thenReturn(new Date());
|
||||
QuotaBalanceResponse resp = quotaResponseBuilderSpy.createQuotaLastBalanceResponse(quotaBalance, null);
|
||||
assertTrue(resp.getStartQuota().compareTo(new BigDecimal(200)) == 0);
|
||||
}
|
||||
|
|
@ -326,16 +324,14 @@ public class QuotaResponseBuilderImplTest extends TestCase {
|
|||
Date startDate = DateUtils.addDays(date, -100);
|
||||
Date endDate = DateUtils.addDays(new Date(), -1);
|
||||
|
||||
Mockito.doReturn(date).when(quotaServiceMock).computeAdjustedTime(Mockito.any(Date.class));
|
||||
quotaResponseBuilderSpy.validateEndDateOnCreatingNewQuotaTariff(quotaTariffVoMock, startDate, endDate);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void validateEndDateOnCreatingNewQuotaTariffTestSetValidEndDate() {
|
||||
Date startDate = DateUtils.addDays(date, -100);
|
||||
Date endDate = date;
|
||||
Date endDate = DateUtils.addMilliseconds(new Date(), 1);
|
||||
|
||||
Mockito.doReturn(DateUtils.addDays(date, -10)).when(quotaServiceMock).computeAdjustedTime(Mockito.any(Date.class));
|
||||
quotaResponseBuilderSpy.validateEndDateOnCreatingNewQuotaTariff(quotaTariffVoMock, startDate, endDate);
|
||||
Mockito.verify(quotaTariffVoMock).setEndDate(Mockito.any(Date.class));
|
||||
}
|
||||
|
|
@ -387,7 +383,6 @@ public class QuotaResponseBuilderImplTest extends TestCase {
|
|||
public void deleteQuotaTariffTestUpdateRemoved() {
|
||||
Mockito.doReturn(quotaTariffVoMock).when(quotaTariffDaoMock).findByUuid(Mockito.anyString());
|
||||
Mockito.doReturn(true).when(quotaTariffDaoMock).updateQuotaTariff(Mockito.any(QuotaTariffVO.class));
|
||||
Mockito.doReturn(new Date()).when(quotaServiceMock).computeAdjustedTime(Mockito.any(Date.class));
|
||||
|
||||
Assert.assertTrue(quotaResponseBuilderSpy.deleteQuotaTariff(""));
|
||||
|
||||
|
|
|
|||
|
|
@ -30,7 +30,6 @@ import org.apache.cloudstack.quota.dao.QuotaUsageDao;
|
|||
import org.apache.cloudstack.quota.vo.QuotaAccountVO;
|
||||
import org.apache.cloudstack.quota.vo.QuotaBalanceVO;
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.DateTimeZone;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
|
@ -102,13 +101,6 @@ public class QuotaServiceImplTest extends TestCase {
|
|||
quotaService.configure("randomName", null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testComputeAdjustedTime() {
|
||||
DateTime now = new DateTime(DateTimeZone.UTC);
|
||||
DateTime result = new DateTime(quotaService.computeAdjustedTime(now.toDate()));
|
||||
// FIXME: fix this test
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFindQuotaBalanceVO() {
|
||||
final long accountId = 2L;
|
||||
|
|
@ -123,7 +115,6 @@ public class QuotaServiceImplTest extends TestCase {
|
|||
qb.setAccountId(accountId);
|
||||
records.add(qb);
|
||||
|
||||
Mockito.when(respBldr.startOfNextDay()).thenReturn(endDate);
|
||||
Mockito.when(respBldr.startOfNextDay(Mockito.any(Date.class))).thenReturn(startDate);
|
||||
Mockito.when(quotaBalanceDao.findQuotaBalance(Mockito.eq(accountId), Mockito.eq(domainId), Mockito.any(Date.class), Mockito.any(Date.class))).thenReturn(records);
|
||||
Mockito.when(quotaBalanceDao.lastQuotaBalanceVO(Mockito.eq(accountId), Mockito.eq(domainId), Mockito.any(Date.class))).thenReturn(records);
|
||||
|
|
@ -142,7 +133,6 @@ public class QuotaServiceImplTest extends TestCase {
|
|||
final Date startDate = new DateTime().minusDays(2).toDate();
|
||||
final Date endDate = new Date();
|
||||
|
||||
Mockito.when(respBldr.startOfNextDay()).thenReturn(endDate);
|
||||
quotaService.getQuotaUsage(accountId, accountName, domainId, QuotaTypes.IP_ADDRESS, startDate, endDate);
|
||||
Mockito.verify(quotaUsageDao, Mockito.times(1)).findQuotaUsage(Mockito.eq(accountId), Mockito.eq(domainId), Mockito.eq(QuotaTypes.IP_ADDRESS), Mockito.any(Date.class), Mockito.any(Date.class));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3646,6 +3646,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
|
|||
cmd.setGatewayIpAddress(localGateway);
|
||||
cmd.setIqn(getIqn());
|
||||
cmd.getHostDetails().put(HOST_VOLUME_ENCRYPTION, String.valueOf(hostSupportsVolumeEncryption()));
|
||||
cmd.setHostTags(getHostTags());
|
||||
HealthCheckResult healthCheckResult = getHostHealthCheckResult();
|
||||
if (healthCheckResult != HealthCheckResult.IGNORE) {
|
||||
cmd.setHostHealthCheckResult(healthCheckResult == HealthCheckResult.SUCCESS);
|
||||
|
|
@ -3674,6 +3675,19 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
|
|||
return startupCommandsArray;
|
||||
}
|
||||
|
||||
protected List<String> getHostTags() {
|
||||
List<String> hostTagsList = new ArrayList<>();
|
||||
String hostTags = AgentPropertiesFileHandler.getPropertyValue(AgentProperties.HOST_TAGS);
|
||||
if (StringUtils.isNotBlank(hostTags)) {
|
||||
for (String hostTag : hostTags.split(",")) {
|
||||
if (!hostTagsList.contains(hostTag.trim())) {
|
||||
hostTagsList.add(hostTag.trim());
|
||||
}
|
||||
}
|
||||
}
|
||||
return hostTagsList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates and sets the host CPU max capacity according to the cgroup version of the host.
|
||||
* <ul>
|
||||
|
|
|
|||
|
|
@ -6295,4 +6295,40 @@ public class LibvirtComputingResourceTest {
|
|||
Assert.assertEquals(expectedShares, libvirtComputingResourceSpy.getHostCpuMaxCapacity());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetHostTags() throws ConfigurationException {
|
||||
try (MockedStatic<AgentPropertiesFileHandler> ignored = Mockito.mockStatic(AgentPropertiesFileHandler.class)) {
|
||||
Mockito.when(AgentPropertiesFileHandler.getPropertyValue(Mockito.eq(AgentProperties.HOST_TAGS)))
|
||||
.thenReturn("aa,bb,cc,dd");
|
||||
|
||||
List<String> hostTagsList = libvirtComputingResourceSpy.getHostTags();
|
||||
Assert.assertEquals(4, hostTagsList.size());
|
||||
Assert.assertEquals("aa,bb,cc,dd", StringUtils.join(hostTagsList, ","));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetHostTagsWithSpace() throws ConfigurationException {
|
||||
try (MockedStatic<AgentPropertiesFileHandler> ignored = Mockito.mockStatic(AgentPropertiesFileHandler.class)) {
|
||||
Mockito.when(AgentPropertiesFileHandler.getPropertyValue(Mockito.eq(AgentProperties.HOST_TAGS)))
|
||||
.thenReturn(" aa, bb , cc , dd ");
|
||||
|
||||
List<String> hostTagsList = libvirtComputingResourceSpy.getHostTags();
|
||||
Assert.assertEquals(4, hostTagsList.size());
|
||||
Assert.assertEquals("aa,bb,cc,dd", StringUtils.join(hostTagsList, ","));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetHostTagsWithEmptyPropertyValue() throws ConfigurationException {
|
||||
try (MockedStatic<AgentPropertiesFileHandler> ignored = Mockito.mockStatic(AgentPropertiesFileHandler.class)) {
|
||||
Mockito.when(AgentPropertiesFileHandler.getPropertyValue(Mockito.eq(AgentProperties.HOST_TAGS)))
|
||||
.thenReturn(" ");
|
||||
|
||||
List<String> hostTagsList = libvirtComputingResourceSpy.getHostTags();
|
||||
Assert.assertEquals(0, hostTagsList.size());
|
||||
Assert.assertEquals("", StringUtils.join(hostTagsList, ","));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@
|
|||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
|
|
|
|||
|
|
@ -47,5 +47,5 @@ echo "new mysql server is started on port "$PORT
|
|||
echo $db
|
||||
|
||||
echo "commands ...."
|
||||
echo "to connect(from local host): mysql -h 127.0.0.1 -P "$PORT
|
||||
echo "to connect(from local host): mysql -h 127.0.0.1 -P "$PORT
|
||||
echo "to stop: mysqladmin -S /tmp/mysql"$PORT"/mysqld.sock shutdown -u root"
|
||||
|
|
|
|||
|
|
@ -294,7 +294,7 @@ This is independent of StorPool as snapshots exist on secondary.
|
|||
### Creating ROOT volume from templates
|
||||
|
||||
When creating the first volume based on the given template, if snapshot of the template does not exists on StorPool it will be first downloaded (cached) to PRIMARY storage.
|
||||
This is mapped to a StorPool snapshot so, creating succecutive volumes from the same template does not incur additional
|
||||
This is mapped to a StorPool snapshot so, creating succecutive volumes from the same template does not incur additional
|
||||
copying of data to PRIMARY storage.
|
||||
|
||||
This cached snapshot is garbage collected when the original template is deleted from CloudStack. This cleanup is done
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@
|
|||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@
|
|||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@
|
|||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@
|
|||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@
|
|||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@
|
|||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
|
|
@ -52,7 +52,7 @@ start() {
|
|||
log_end_msg 1
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
if start-stop-daemon --start --quiet \
|
||||
--pidfile "$PIDFILE" \
|
||||
--exec "$DAEMONIZE" -- -n "$SHORTNAME" -p "$PIDFILE" -l "$LOGFILE" "$PROG" $OPTIONS
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@
|
|||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
|
|
@ -51,7 +51,7 @@ verify_cksum() {
|
|||
esac
|
||||
echo "$1 $2" | $digestalgo -c --status
|
||||
#printf "$1\t$2" | $digestalgo -c --status
|
||||
if [ $? -gt 0 ]
|
||||
if [ $? -gt 0 ]
|
||||
then
|
||||
printf "Checksum failed, not proceeding with install\n"
|
||||
exit 3
|
||||
|
|
@ -92,12 +92,12 @@ uncompress() {
|
|||
;;
|
||||
esac
|
||||
|
||||
if [ $? -gt 0 ]
|
||||
if [ $? -gt 0 ]
|
||||
then
|
||||
printf "Failed to uncompress file, exiting "
|
||||
exit 1
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
mv $tmpfile $imgfile
|
||||
printf "$imgfile"
|
||||
|
||||
|
|
@ -184,10 +184,10 @@ then
|
|||
tmpltfs=${tmpltfs:1}
|
||||
fi
|
||||
|
||||
if [ ! -d /$tmpltfs ]
|
||||
if [ ! -d /$tmpltfs ]
|
||||
then
|
||||
zfs create -p $tmpltfs
|
||||
if [ $? -gt 0 ]
|
||||
if [ $? -gt 0 ]
|
||||
then
|
||||
printf "Failed to create user fs $tmpltfs\n" >&2
|
||||
exit 1
|
||||
|
|
@ -203,7 +203,7 @@ fi
|
|||
tmpltimg2=$(uncompress $tmpltimg)
|
||||
tmpltimg2=$(untar $tmpltimg2 /$tmpltfs vmi-root)
|
||||
|
||||
if [ ! -f $tmpltimg2 ]
|
||||
if [ ! -f $tmpltimg2 ]
|
||||
then
|
||||
rollback_if_needed $tmpltfs 2 "root disk file $tmpltimg doesn't exist\n"
|
||||
exit 3
|
||||
|
|
@ -217,15 +217,15 @@ fi
|
|||
|
||||
#determine source file size -- it needs to be less than or equal to volsize
|
||||
imgsize=$(ls -lh $tmpltimg2| awk -F" " '{print $5}')
|
||||
if [ ${imgsize:(-1)} == G ]
|
||||
if [ ${imgsize:(-1)} == G ]
|
||||
then
|
||||
imgsize=${imgsize%G} #strip out the G
|
||||
imgsize=${imgsize%G} #strip out the G
|
||||
imgsize=${imgsize%.*} #...and any decimal part
|
||||
let imgsize=imgsize+1 # add 1 to compensate for decimal part
|
||||
volsizetmp=${volsize%G}
|
||||
if [ $volsizetmp -lt $imgsize ]
|
||||
then
|
||||
volsize=${imgsize}G
|
||||
volsize=${imgsize}G
|
||||
fi
|
||||
fi
|
||||
|
||||
|
|
@ -234,11 +234,11 @@ tgtfile=${tmpltfs}/vmi-root-${tmpltname}
|
|||
create_from_file $tmpltfs $tmpltimg2 $tgtfile $volsize $cleanup
|
||||
|
||||
tmpltswap=$(ls -lh /$tmpltfs | grep swap)
|
||||
if [ $? -eq 0 ]
|
||||
if [ $? -eq 0 ]
|
||||
then
|
||||
swapsize=$(echo $tmpltswap | awk '{print $5}')
|
||||
tmpltswap=$(echo $tmpltswap | awk '{print $NF}')
|
||||
tmpltswap=/${tmpltfs}/${tmpltswap}
|
||||
tmpltswap=/${tmpltfs}/${tmpltswap}
|
||||
tgtfile=${tmpltfs}/vmi-swap-${tmpltname}
|
||||
create_from_file $tmpltfs $tmpltswap $tgtfile $swapsize $cleanup
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@
|
|||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
|
|
@ -93,12 +93,12 @@ uncompress() {
|
|||
;;
|
||||
esac
|
||||
|
||||
if [ $? -gt 0 ]
|
||||
if [ $? -gt 0 ]
|
||||
then
|
||||
printf "Failed to uncompress file, exiting "
|
||||
exit 1
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
mv $tmpfile $imgfile
|
||||
printf "$imgfile"
|
||||
|
||||
|
|
@ -185,10 +185,10 @@ then
|
|||
volfs=${volfs:1}
|
||||
fi
|
||||
|
||||
if [ ! -d /$volfs ]
|
||||
if [ ! -d /$volfs ]
|
||||
then
|
||||
zfs create -p $volfs
|
||||
if [ $? -gt 0 ]
|
||||
if [ $? -gt 0 ]
|
||||
then
|
||||
printf "Failed to create user fs $volfs\n" >&2
|
||||
exit 1
|
||||
|
|
@ -204,7 +204,7 @@ fi
|
|||
volimg2=$(uncompress $volimg)
|
||||
volimg2=$(untar $volimg2 /$volfs vmi-root)
|
||||
|
||||
if [ ! -f $volimg2 ]
|
||||
if [ ! -f $volimg2 ]
|
||||
then
|
||||
rollback_if_needed $volfs 2 "root disk file $volimg doesn't exist\n"
|
||||
exit 3
|
||||
|
|
@ -218,15 +218,15 @@ fi
|
|||
|
||||
#determine source file size -- it needs to be less than or equal to volsize
|
||||
imgsize=$(ls -lh $volimg2| awk -F" " '{print $5}')
|
||||
if [ ${imgsize:(-1)} == G ]
|
||||
if [ ${imgsize:(-1)} == G ]
|
||||
then
|
||||
imgsize=${imgsize%G} #strip out the G
|
||||
imgsize=${imgsize%G} #strip out the G
|
||||
imgsize=${imgsize%.*} #...and any decimal part
|
||||
let imgsize=imgsize+1 # add 1 to compensate for decimal part
|
||||
volsizetmp=${volsize%G}
|
||||
if [ $volsizetmp -lt $imgsize ]
|
||||
then
|
||||
volsize=${imgsize}G
|
||||
volsize=${imgsize}G
|
||||
fi
|
||||
fi
|
||||
|
||||
|
|
@ -235,11 +235,11 @@ tgtfile=${volfs}/vmi-root-${volname}
|
|||
create_from_file $volfs $volimg2 $tgtfile $volsize $cleanup
|
||||
|
||||
volswap=$(ls -lh /$volfs | grep swap)
|
||||
if [ $? -eq 0 ]
|
||||
if [ $? -eq 0 ]
|
||||
then
|
||||
swapsize=$(echo $volswap | awk '{print $5}')
|
||||
volswap=$(echo $volswap | awk '{print $NF}')
|
||||
volswap=/${volfs}/${volswap}
|
||||
volswap=/${volfs}/${volswap}
|
||||
tgtfile=${volfs}/vmi-swap-${volname}
|
||||
create_from_file $volfs $volswap $tgtfile $swapsize $cleanup
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@
|
|||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
|
|
@ -38,7 +38,7 @@ do
|
|||
;;
|
||||
c) cflag=1
|
||||
create_tmplt_path="$OPTARG"
|
||||
;;
|
||||
;;
|
||||
?) usage
|
||||
exit 2
|
||||
;;
|
||||
|
|
@ -47,14 +47,14 @@ done
|
|||
|
||||
shift $(($OPTIND - 1))
|
||||
|
||||
if [ "$tflag" != "1" ] || [ "$cflag" != "1" ]
|
||||
if [ "$tflag" != "1" ] || [ "$cflag" != "1" ]
|
||||
then
|
||||
usage
|
||||
exit 2
|
||||
fi
|
||||
|
||||
tmpltfs=$template_location/public/os/centos53-x86_64
|
||||
if [ "$fflag" == "1" ]
|
||||
if [ "$fflag" == "1" ]
|
||||
then
|
||||
zfs destroy -Rr $tmpltfs 2> /dev/null
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@
|
|||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
|
|
@ -47,7 +47,7 @@ then
|
|||
fi
|
||||
|
||||
tmpltfs=$1/private/u000000/os/consoleproxy
|
||||
if [ "$fflag" == "1" ]
|
||||
if [ "$fflag" == "1" ]
|
||||
then
|
||||
zfs destroy -r $tmpltfs 2> /dev/null
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@
|
|||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
|
|
@ -32,7 +32,7 @@ then
|
|||
fi
|
||||
|
||||
if [ "$VMOPS_HOME" == "" ]
|
||||
then
|
||||
then
|
||||
VMOPS_HOME="/usr/local/vmops"
|
||||
fi
|
||||
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@
|
|||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
|
|
@ -16,7 +16,7 @@
|
|||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
# used as a proxy to call script inside virtual router
|
||||
# used as a proxy to call script inside virtual router
|
||||
|
||||
#set -x
|
||||
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@
|
|||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
|
|
@ -41,9 +41,9 @@ no_dhcp_release=$?
|
|||
[ ! -f /etc/dhcphosts.txt ] && touch /etc/dhcphosts.txt
|
||||
[ ! -f /var/lib/misc/dnsmasq.leases ] && touch /var/lib/misc/dnsmasq.leases
|
||||
|
||||
sed -i /$1/d /etc/dhcphosts.txt
|
||||
sed -i /$2,/d /etc/dhcphosts.txt
|
||||
sed -i /$3,/d /etc/dhcphosts.txt
|
||||
sed -i /$1/d /etc/dhcphosts.txt
|
||||
sed -i /$2,/d /etc/dhcphosts.txt
|
||||
sed -i /$3,/d /etc/dhcphosts.txt
|
||||
|
||||
echo "$1,$2,$3,infinite" >>/etc/dhcphosts.txt
|
||||
|
||||
|
|
@ -54,9 +54,9 @@ then
|
|||
fi
|
||||
|
||||
#delete leases to supplied mac and ip addresses
|
||||
sed -i /$1/d /var/lib/misc/dnsmasq.leases
|
||||
sed -i /"$2 "/d /var/lib/misc/dnsmasq.leases
|
||||
sed -i /"$3 "/d /var/lib/misc/dnsmasq.leases
|
||||
sed -i /$1/d /var/lib/misc/dnsmasq.leases
|
||||
sed -i /"$2 "/d /var/lib/misc/dnsmasq.leases
|
||||
sed -i /"$3 "/d /var/lib/misc/dnsmasq.leases
|
||||
|
||||
#put in the new entry
|
||||
echo "0 $1 $2 $3 *" >> /var/lib/misc/dnsmasq.leases
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@
|
|||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@
|
|||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
|
|
@ -129,11 +129,11 @@ config_dnsmasq domain=cloudnine.internal
|
|||
config_dnsmasq "
|
||||
# Send options to hosts which ask for a DHCP lease.
|
||||
# See RFC 2132 for details of available options.
|
||||
# Common options can be given to dnsmasq by name:
|
||||
# Common options can be given to dnsmasq by name:
|
||||
# run \"dnsmasq --help dhcp\" to get a list.
|
||||
# Note that all the common settings, such as netmask and
|
||||
# broadcast address, DNS server and default route, are given
|
||||
# sane defaults by dnsmasq. You very likely will not need
|
||||
# sane defaults by dnsmasq. You very likely will not need
|
||||
# any dhcp-options. If you use Windows clients and Samba, there
|
||||
# are some options which are recommended, they are detailed at the
|
||||
# end of this section.
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@
|
|||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@
|
|||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
|
|
@ -29,7 +29,7 @@ usage() {
|
|||
|
||||
verify_cksum() {
|
||||
echo "$1 $2" | md5sum -c --status
|
||||
if [ $? -gt 0 ]
|
||||
if [ $? -gt 0 ]
|
||||
then
|
||||
printf "Checksum failed, not proceeding with install\n"
|
||||
exit 3
|
||||
|
|
@ -44,7 +44,7 @@ install_file() {
|
|||
|
||||
mv $isofile /$isofs/$tmpltname
|
||||
|
||||
if [ $? -gt 0 ]
|
||||
if [ $? -gt 0 ]
|
||||
then
|
||||
printf "Move operation failed, iso $isofile not installed\n"
|
||||
exit 4
|
||||
|
|
@ -55,7 +55,7 @@ install_file() {
|
|||
isofs=$isofs/$file
|
||||
mp=${isofs%/iso/*}
|
||||
mp=/$mp/iso
|
||||
path=${isofs:${#mp}}
|
||||
path=${isofs:${#mp}}
|
||||
pushd $mp
|
||||
ln -s $path $file
|
||||
popd
|
||||
|
|
@ -108,10 +108,10 @@ then
|
|||
isofs=${isofs:1}
|
||||
fi
|
||||
|
||||
if [ ! -d /$isofs ]
|
||||
if [ ! -d /$isofs ]
|
||||
then
|
||||
mkdir -p /$isofs
|
||||
if [ $? -gt 0 ]
|
||||
if [ $? -gt 0 ]
|
||||
then
|
||||
printf "Failed to create iso fs $isofs\n" >&2
|
||||
exit 1
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@
|
|||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
|
|
@ -16,7 +16,7 @@
|
|||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
|
||||
|
||||
|
||||
# $Id: create_private_template.sh 9804 2010-06-22 18:36:49Z alex $ $HeadURL: svn://svn.lab.vmops.com/repos/vmdev/java/scripts/storage/qcow2/create_private_template.sh $
|
||||
# create_private_template.sh -- create a private template from a snapshot
|
||||
|
|
@ -31,7 +31,7 @@ create_template() {
|
|||
local fspath=$1
|
||||
local destpath=$2
|
||||
|
||||
# if backing image exists, we need to combine them, otherwise
|
||||
# if backing image exists, we need to combine them, otherwise
|
||||
# copy the image to preserve snapshots/compression
|
||||
if $qemu_img info "$tmpltimg" | grep -q backing; then
|
||||
qemu-img convert -O qcow2 /$fspath $destpath
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@
|
|||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
|
|
@ -70,12 +70,12 @@ uncompress() {
|
|||
;;
|
||||
esac
|
||||
|
||||
if [ $? -gt 0 ]
|
||||
if [ $? -gt 0 ]
|
||||
then
|
||||
printf "Failed to uncompress file, exiting "
|
||||
exit 1
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
mv $tmpfile $imgfile
|
||||
printf "$imgfile"
|
||||
|
||||
|
|
@ -89,7 +89,7 @@ create_from_file() {
|
|||
if [ -b $tmpltimg ]; then
|
||||
$qemu_img convert -f raw -O qcow2 "$tmpltimg" /$tmpltfs/$tmpltname
|
||||
else
|
||||
# if backing image exists, we need to combine them, otherwise
|
||||
# if backing image exists, we need to combine them, otherwise
|
||||
# copy the image to preserve snapshots/compression
|
||||
if $qemu_img info "$tmpltimg" | grep -q backing; then
|
||||
$qemu_img convert -f qcow2 -O qcow2 "$tmpltimg" /$tmpltfs/$tmpltname >& /dev/null
|
||||
|
|
@ -97,7 +97,7 @@ create_from_file() {
|
|||
cp -f $tmpltimg /$tmpltfs/$tmpltname
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
if [ "$cleanup" == "true" ]
|
||||
then
|
||||
rm -f "$tmpltimg"
|
||||
|
|
@ -161,17 +161,17 @@ do
|
|||
done
|
||||
|
||||
|
||||
if [ ! -d /$tmpltfs ]
|
||||
if [ ! -d /$tmpltfs ]
|
||||
then
|
||||
mkdir -p /$tmpltfs
|
||||
if [ $? -gt 0 ]
|
||||
if [ $? -gt 0 ]
|
||||
then
|
||||
printf "Failed to create user fs $tmpltfs\n" >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ ! -f $tmpltimg -a ! -b $tmpltimg ]
|
||||
if [ ! -f $tmpltimg -a ! -b $tmpltimg ]
|
||||
then
|
||||
printf "root disk file $tmpltimg doesn't exist\n"
|
||||
exit 3
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@
|
|||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
|
|
@ -18,11 +18,11 @@
|
|||
|
||||
|
||||
# $Id: createvm.sh 10292 2010-07-07 00:24:04Z edison $ $HeadURL: svn://svn.lab.vmops.com/repos/vmdev/java/scripts/storage/qcow2/createvm.sh $
|
||||
# createvm.sh -- create a vm image
|
||||
# createvm.sh -- create a vm image
|
||||
|
||||
usage() {
|
||||
echo "Usage (clone VM from template): createvm.sh -t <template dir> -i <rootdisk dir> -f <datadisk folder> -n <datadisk name> -s <datadisk size in GB>\n\
|
||||
Usage (create blank rootdisk): createvm.sh -i <rootdisk dir> -S <rootdisk size in GB> \n"
|
||||
Usage (create blank rootdisk): createvm.sh -i <rootdisk dir> -S <rootdisk size in GB> \n"
|
||||
}
|
||||
|
||||
check_params() {
|
||||
|
|
@ -43,7 +43,7 @@ check_params() {
|
|||
return 1
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
|
|
@ -53,7 +53,7 @@ cleanup_and_exit_if_error() {
|
|||
local rootdiskfolder=$3
|
||||
local datadiskfolder=$4
|
||||
local datadiskname=$5
|
||||
|
||||
|
||||
if [ $return_code -gt 0 ]
|
||||
then
|
||||
cleanup_disks $rootdiskfolder $datadiskfolder $datadiskname
|
||||
|
|
@ -71,24 +71,24 @@ cleanup_disks() {
|
|||
then
|
||||
datadiskpath="${datadiskfolder}/${datadiskname}"
|
||||
fi
|
||||
|
||||
|
||||
if [ "$rootdiskfolder" != "" ] && [ -d $rootdiskfolder ]
|
||||
then
|
||||
rm -rf $rootdiskfolder
|
||||
fi
|
||||
|
||||
|
||||
if [ "$datadiskpath" != "" ] && [ -f $datadiskpath ]
|
||||
then
|
||||
rm $datadiskpath
|
||||
fi
|
||||
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
exit_if_error() {
|
||||
local return_code=$1
|
||||
local msg=$2
|
||||
|
||||
|
||||
if [ $return_code -gt 0 ]
|
||||
then
|
||||
printf "${msg}\n"
|
||||
|
|
@ -98,7 +98,7 @@ exit_if_error() {
|
|||
|
||||
make_folder() {
|
||||
local folder=$1
|
||||
|
||||
|
||||
if [ ! -d ${folder} ]
|
||||
then
|
||||
mkdir -p ${folder}
|
||||
|
|
@ -121,9 +121,9 @@ check_rootdisk() {
|
|||
check_datadisk() {
|
||||
local datadiskfolder=$1
|
||||
local datadiskname=$2
|
||||
|
||||
|
||||
make_folder $datadiskfolder
|
||||
|
||||
|
||||
if [ -f ${datadiskfolder}/${datadiskname} ]
|
||||
then
|
||||
return 1
|
||||
|
|
@ -134,12 +134,12 @@ check_datadisk() {
|
|||
|
||||
strip_leading_slash() {
|
||||
local folder=$1
|
||||
|
||||
|
||||
if [ ${folder:0:1} != / ]
|
||||
then
|
||||
folder=/$folder
|
||||
fi
|
||||
|
||||
|
||||
echo $folder
|
||||
}
|
||||
|
||||
|
|
@ -149,7 +149,7 @@ clone_template_to_rootdisk() {
|
|||
|
||||
curDir=$(pwd)
|
||||
cd $rootdiskfolder
|
||||
qemu-img create -f qcow2 -b $templatepath ${rootdiskfolder}/rootdisk
|
||||
qemu-img create -f qcow2 -b $templatepath ${rootdiskfolder}/rootdisk
|
||||
cd $curDir
|
||||
|
||||
return $?
|
||||
|
|
@ -158,9 +158,9 @@ clone_template_to_rootdisk() {
|
|||
create_blank_rootdisk() {
|
||||
local rootdiskfolder=$1
|
||||
local rootdisksize=$2
|
||||
|
||||
|
||||
rootdisksize=$(convert_size_to_gb $rootdisksize)
|
||||
|
||||
|
||||
if [ $? -gt 0 ]
|
||||
then
|
||||
return 1
|
||||
|
|
@ -176,27 +176,27 @@ create_datadisk() {
|
|||
local datadiskname=$2
|
||||
local datadisksize=$3
|
||||
local diskfmt=$4
|
||||
|
||||
|
||||
datadisksize=$(convert_size_to_gb $datadisksize)
|
||||
|
||||
|
||||
if [ $? -gt 0 ]
|
||||
then
|
||||
return 1
|
||||
fi
|
||||
|
||||
qemu-img create -f $diskfmt ${datadiskfolder}/${datadiskname} $datadisksize
|
||||
|
||||
|
||||
return $?
|
||||
}
|
||||
|
||||
convert_size_to_gb() {
|
||||
local size=$1
|
||||
|
||||
|
||||
suffix=${size:(-1)}
|
||||
case $suffix in
|
||||
M)
|
||||
;;
|
||||
G)
|
||||
G)
|
||||
;;
|
||||
[0-9]) size=${size}G
|
||||
;;
|
||||
|
|
@ -204,7 +204,7 @@ convert_size_to_gb() {
|
|||
return 1
|
||||
;;
|
||||
esac
|
||||
|
||||
|
||||
echo $size
|
||||
return 0
|
||||
}
|
||||
|
|
@ -262,7 +262,7 @@ then
|
|||
exit_if_error $? "Failed to clone template $templatepath to $rootdiskfolder/rootdisk."
|
||||
else
|
||||
# A template path was not passed in, so create a blank rootdisk at the rootdisk folder
|
||||
create_blank_rootdisk $rootdiskfolder $rootdisksize
|
||||
create_blank_rootdisk $rootdiskfolder $rootdisksize
|
||||
exit_if_error $? "Failed to create a blank rootdisk at $rootdiskfolder/rootdisk."
|
||||
fi
|
||||
fi
|
||||
|
|
@ -270,8 +270,8 @@ fi
|
|||
if [ -n "$datadisksize" ]
|
||||
then
|
||||
# Create the datadisk folder if necessary, and make sure there is no existing datadisk there
|
||||
check_datadisk $datadiskfolder $datadiskname
|
||||
cleanup_and_exit_if_error $? "Failed to create datadisk in $datadiskfolder; datadisk with $datadiskname already exists." $rootdiskfolder
|
||||
check_datadisk $datadiskfolder $datadiskname
|
||||
cleanup_and_exit_if_error $? "Failed to create datadisk in $datadiskfolder; datadisk with $datadiskname already exists." $rootdiskfolder
|
||||
|
||||
# Create the datadisk
|
||||
create_datadisk $datadiskfolder $datadiskname $datadisksize qcow2
|
||||
|
|
@ -285,7 +285,7 @@ else
|
|||
retry=10
|
||||
while [ $retry -gt 0 ]
|
||||
do
|
||||
success=$(losetup -a |grep $loopdev)
|
||||
success=$(losetup -a |grep $loopdev)
|
||||
if [ $? -eq 0 ]
|
||||
then
|
||||
break
|
||||
|
|
@ -300,7 +300,7 @@ else
|
|||
losetup -d $loopdev
|
||||
if [ $? -eq 0 ]
|
||||
then
|
||||
break
|
||||
break
|
||||
fi
|
||||
retry=$(($retry-1))
|
||||
sleep 1
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@
|
|||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
|
|
@ -16,7 +16,7 @@
|
|||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
|
||||
|
||||
|
||||
# $Id: createvol.sh 11601 2010-08-11 17:26:15Z kris $ $HeadURL: svn://svn.lab.vmops.com/repos/branches/2.1.refactor/java/scripts/storage/qcow2/createvol.sh $
|
||||
# createvol.sh -- install a volume
|
||||
|
|
@ -71,12 +71,12 @@ uncompress() {
|
|||
;;
|
||||
esac
|
||||
|
||||
if [ $? -gt 0 ]
|
||||
if [ $? -gt 0 ]
|
||||
then
|
||||
printf "Failed to uncompress file, exiting "
|
||||
exit 1
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
mv $tmpfile $imgfile
|
||||
printf "$imgfile"
|
||||
|
||||
|
|
@ -98,7 +98,7 @@ create_from_file() {
|
|||
cp -f $volimg /$volfs/$volname
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
if [ "$cleanup" == "true" ]
|
||||
then
|
||||
rm -f "$volimg"
|
||||
|
|
@ -162,17 +162,17 @@ do
|
|||
done
|
||||
|
||||
|
||||
if [ ! -d /$volfs ]
|
||||
if [ ! -d /$volfs ]
|
||||
then
|
||||
mkdir -p /$volfs
|
||||
if [ $? -gt 0 ]
|
||||
if [ $? -gt 0 ]
|
||||
then
|
||||
printf "Failed to create user fs $volfs\n" >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ ! -f $volimg -a ! -b $volimg ]
|
||||
if [ ! -f $volimg -a ! -b $volimg ]
|
||||
then
|
||||
printf "root disk file $volimg doesn't exist\n"
|
||||
exit 3
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@
|
|||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
|
|
@ -54,20 +54,20 @@ then
|
|||
fi
|
||||
|
||||
|
||||
if [ "$iflag" == 1 ]
|
||||
if [ "$iflag" == 1 ]
|
||||
then
|
||||
rm -rf $instancefs
|
||||
if [ $? -gt 0 ]
|
||||
if [ $? -gt 0 ]
|
||||
then
|
||||
printf "Failed to destroy instance fs\n" >&2
|
||||
exit 5
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$uflag" == 1 ]
|
||||
if [ "$uflag" == 1 ]
|
||||
then
|
||||
rm -rf $userfs
|
||||
if [ $? -gt 0 ]
|
||||
rm -rf $userfs
|
||||
if [ $? -gt 0 ]
|
||||
then
|
||||
printf "Failed to destroy user fs\n" >&2
|
||||
exit 5
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@
|
|||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
|
|
@ -29,18 +29,18 @@ mount_local() {
|
|||
local nbd_loaded=$?
|
||||
if [ $nbd_loaded -ne 0 ]
|
||||
then
|
||||
modprobe nbd max_part=8 &> /dev/null
|
||||
modprobe nbd max_part=8 &> /dev/null
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
printf "No nbd module installed, failed to mount qcow2 image\n"
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
qemu-nbd -c /dev/nbd0 $disk &> /dev/null
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
printf "failed to create /dev/nbd0\n"
|
||||
printf "failed to create /dev/nbd0\n"
|
||||
return 2
|
||||
fi
|
||||
|
||||
|
|
@ -56,7 +56,7 @@ mount_local() {
|
|||
fi
|
||||
retry=$(($retry-1))
|
||||
done
|
||||
|
||||
|
||||
|
||||
if [ $retry -eq 0 ]
|
||||
then
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@
|
|||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@
|
|||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
|
|
@ -49,7 +49,7 @@ setTmplMetaFile() {
|
|||
local fileName=$5
|
||||
virtualsize=$(qemu-img info $tmplfile|grep virtual |awk '{print $4}'|cut -d \( -f 2)
|
||||
disksize=$(ls -l $tmplfile|awk '{print $5}')
|
||||
|
||||
|
||||
echo "qcow2=true" >> $metaFile
|
||||
echo "id=$id" >> $metaFile
|
||||
echo "public=true" >> $metaFile
|
||||
|
|
@ -91,31 +91,31 @@ then
|
|||
exit 2
|
||||
fi
|
||||
|
||||
if [[ "$uflag" != "1" && "$rflag" == "1" && ! -f $rttmplt ]]
|
||||
if [[ "$uflag" != "1" && "$rflag" == "1" && ! -f $rttmplt ]]
|
||||
then
|
||||
echo "template image file $rttmplt doesn't exist"
|
||||
exit 3
|
||||
fi
|
||||
|
||||
if [[ "$uflag" != "1" && "$vflag" == "1" && ! -f $vmtmplt ]]
|
||||
if [[ "$uflag" != "1" && "$vflag" == "1" && ! -f $vmtmplt ]]
|
||||
then
|
||||
echo "template image file $vmtmplt doesn't exist"
|
||||
exit 3
|
||||
fi
|
||||
|
||||
if [[ "$uflag" == "1" && "$rflag" != "1" ]]
|
||||
if [[ "$uflag" == "1" && "$rflag" != "1" ]]
|
||||
then
|
||||
rttmplt=http://download.cloudstack.org/templates/builtin/a88232bf-6a18-38e7-aeee-c1702725079f.qcow2.bz2
|
||||
echo "download routing template from $rttmplt"
|
||||
fi
|
||||
|
||||
if [[ "$uflag" == "1" && "$vflag" != "1" ]]
|
||||
if [[ "$uflag" == "1" && "$vflag" != "1" ]]
|
||||
then
|
||||
vmtmplt=http://download.cloudstack.org/templates/builtin/eec2209b-9875-3c8d-92be-c001bd8a0faf.qcow2.bz2
|
||||
echo "download cnetos template from $vmtmplt"
|
||||
fi
|
||||
|
||||
if [ ! -d $mntpoint ]
|
||||
if [ ! -d $mntpoint ]
|
||||
then
|
||||
echo "mount point $mntpoint doesn't exist\n"
|
||||
exit 4
|
||||
|
|
@ -182,7 +182,7 @@ fi
|
|||
tmpfilert=$(dirname $0)/$localfilert
|
||||
tmpfilevm=$(dirname $0)/$localfilevm
|
||||
if [ "$uflag" == "1" ]
|
||||
then
|
||||
then
|
||||
downloadImage $tmpfilert $rttmplt
|
||||
downloadImage $tmpfilevm $vmtmplt
|
||||
fi
|
||||
|
|
@ -195,7 +195,7 @@ then
|
|||
printf "Failed to create temporary file in directory $(dirname $0) -- is it read-only or full?\n"
|
||||
exit 6
|
||||
fi
|
||||
cp $vmtmplt $tmpfilevm
|
||||
cp $vmtmplt $tmpfilevm
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
printf "Failed to create temporary file in directory $(dirname $0) -- is it read-only or full?\n"
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@
|
|||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
|
|
@ -58,25 +58,25 @@ fi
|
|||
|
||||
|
||||
|
||||
if [ "$rflag" == 1 ]
|
||||
if [ "$rflag" == 1 ]
|
||||
then
|
||||
find $instancefs -name rootdisk
|
||||
if [ $? -gt 0 ]
|
||||
if [ $? -gt 0 ]
|
||||
then
|
||||
exit 5
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$dflag" == 1 ]
|
||||
if [ "$dflag" == 1 ]
|
||||
then
|
||||
if [[ $disknum -eq 0 ]]
|
||||
then
|
||||
then
|
||||
find $instancefs -name datadisk
|
||||
else
|
||||
else
|
||||
find $instancefs -name datadisk${disknum}
|
||||
fi
|
||||
if [ $? -gt 0 ]
|
||||
if [ $? -gt 0 ]
|
||||
then
|
||||
exit 6
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@
|
|||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
|
|
@ -16,7 +16,7 @@
|
|||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
|
||||
|
||||
|
||||
# $Id: listvmdisksize.sh 9132 2010-06-04 20:17:43Z manuel $ $HeadURL: svn://svn.lab.vmops.com/repos/vmdev/java/scripts/storage/qcow2/listvmdisksize.sh $
|
||||
# listvmdisksize.sh -- list disk sizes of a VM
|
||||
|
|
@ -56,7 +56,7 @@ do
|
|||
;;
|
||||
t) tflag=1
|
||||
;;
|
||||
a) aflag=1
|
||||
a) aflag=1
|
||||
;;
|
||||
?) usage
|
||||
exit 2
|
||||
|
|
@ -71,11 +71,11 @@ then
|
|||
fi
|
||||
|
||||
|
||||
if [ "$tflag" == 1 ]
|
||||
if [ "$tflag" == 1 ]
|
||||
then
|
||||
# Find the virtual size of the disk image
|
||||
size_in_bytes=$(qemu-img info /$diskfs | grep "virtual size" | awk '{print $4}')
|
||||
|
||||
|
||||
# Strip off the leading '('
|
||||
size_in_bytes=${size_in_bytes:1}
|
||||
else
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@
|
|||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
|
|
@ -16,7 +16,7 @@
|
|||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
|
||||
|
||||
|
||||
# $Id: listvmtmplt.sh 9132 2010-06-04 20:17:43Z manuel $ $HeadURL: svn://svn.lab.vmops.com/repos/vmdev/java/scripts/storage/qcow2/listvmtmplt.sh $
|
||||
# listtmplt.sh -- list templates under a directory
|
||||
|
|
@ -51,7 +51,7 @@ fi
|
|||
|
||||
|
||||
for i in $(find /$rootdir -name template.properties );
|
||||
do
|
||||
do
|
||||
d=$(dirname $i)
|
||||
filename=$(grep "filename" $i | awk -F"=" '{print $NF}')
|
||||
size=$(grep "virtualsize" $i | awk -F"=" '{print $NF}')
|
||||
|
|
@ -59,7 +59,7 @@ do
|
|||
then
|
||||
d=$d/$filename/$size
|
||||
fi
|
||||
echo ${d#/} #remove leading slash
|
||||
echo ${d#/} #remove leading slash
|
||||
done
|
||||
|
||||
exit 0
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@
|
|||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
|
|
@ -16,7 +16,7 @@
|
|||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
|
||||
|
||||
|
||||
# $Id: listvmtmplt.sh 9132 2010-06-04 20:17:43Z manuel $ $HeadURL: svn://svn.lab.vmops.com/repos/vmdev/java/scripts/storage/qcow2/listvmtmplt.sh $
|
||||
# listtmplt.sh -- list volumes under a directory
|
||||
|
|
@ -51,7 +51,7 @@ fi
|
|||
|
||||
|
||||
for i in $(find /$rootdir -name volume.properties );
|
||||
do
|
||||
do
|
||||
d=$(dirname $i)
|
||||
filename=$(grep "filename" $i | awk -F"=" '{print $NF}')
|
||||
size=$(grep "virtualsize" $i | awk -F"=" '{print $NF}')
|
||||
|
|
@ -59,7 +59,7 @@ do
|
|||
then
|
||||
d=$d/$filename/$size
|
||||
fi
|
||||
echo ${d#/} #remove leading slash
|
||||
echo ${d#/} #remove leading slash
|
||||
done
|
||||
|
||||
exit 0
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@
|
|||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
|
|
@ -16,10 +16,10 @@
|
|||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
|
||||
|
||||
|
||||
# $Id: managevolume.sh 9132 2010-06-04 20:17:43Z manuel $ $HeadURL: svn://svn.lab.vmops.com/repos/vmdev/java/scripts/storage/qcow2/managevolume.sh $
|
||||
# modifyvolume.sh -- add or delete a disk volume
|
||||
# modifyvolume.sh -- add or delete a disk volume
|
||||
|
||||
usage() {
|
||||
echo "Usage: modifydisk.sh -f <folder of volume> -p <path of volume> -s <size of volume> [-d <delete>] \n"
|
||||
|
|
@ -38,7 +38,7 @@ cleanup_and_exit_if_error() {
|
|||
local return_code=$1
|
||||
local msg=$2
|
||||
local path=$3
|
||||
|
||||
|
||||
if [ $return_code -gt 0 ]
|
||||
then
|
||||
delete_disk $path
|
||||
|
|
@ -49,7 +49,7 @@ cleanup_and_exit_if_error() {
|
|||
exit_if_error() {
|
||||
local return_code=$1
|
||||
local msg=$2
|
||||
|
||||
|
||||
if [ $return_code -gt 0 ]
|
||||
then
|
||||
printf "${msg}\n"
|
||||
|
|
@ -59,7 +59,7 @@ exit_if_error() {
|
|||
|
||||
make_folder() {
|
||||
local folder=$1
|
||||
|
||||
|
||||
if [ ! -d ${folder} ]
|
||||
then
|
||||
mkdir -p ${folder}
|
||||
|
|
@ -69,9 +69,9 @@ make_folder() {
|
|||
check_disk() {
|
||||
local folder=$1
|
||||
local path=$2
|
||||
|
||||
|
||||
make_folder $folder
|
||||
|
||||
|
||||
if [ -f $path ]
|
||||
then
|
||||
return 1
|
||||
|
|
@ -82,37 +82,37 @@ check_disk() {
|
|||
|
||||
delete_disk() {
|
||||
local path=$1
|
||||
|
||||
|
||||
if [ -f $path ]
|
||||
then
|
||||
rm $path
|
||||
fi
|
||||
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
create_disk() {
|
||||
local path=$1
|
||||
local size=$2
|
||||
|
||||
|
||||
size=$(convert_size_to_gb $size)
|
||||
|
||||
|
||||
if [ $? -gt 0 ]
|
||||
then
|
||||
return 1
|
||||
fi
|
||||
|
||||
qemu-img create -f qcow2 $path $size
|
||||
|
||||
|
||||
return $?
|
||||
}
|
||||
|
||||
convert_size_to_gb() {
|
||||
local size=$1
|
||||
|
||||
|
||||
suffix=${size:(-1)}
|
||||
case $suffix in
|
||||
G)
|
||||
G)
|
||||
;;
|
||||
[0-9]) size=${size}G
|
||||
;;
|
||||
|
|
@ -120,7 +120,7 @@ convert_size_to_gb() {
|
|||
return 1
|
||||
;;
|
||||
esac
|
||||
|
||||
|
||||
echo $size
|
||||
return 0
|
||||
}
|
||||
|
|
@ -159,20 +159,20 @@ exit_if_error $? "$(usage)"
|
|||
if [ "$dflag" == "0" ]
|
||||
then
|
||||
# Add the volume
|
||||
|
||||
|
||||
# Create the folder if necessary, and make sure there is no existing disk there
|
||||
check_disk $folder $path
|
||||
cleanup_and_exit_if_error $? "Failed to create disk at $path; path already exists." $path
|
||||
|
||||
|
||||
# Create the disk
|
||||
create_disk $path $size
|
||||
cleanup_and_exit_if_error $? "Failed to create disk at $path of size $datadisksize." $path
|
||||
|
||||
|
||||
else
|
||||
# Delete the volume
|
||||
|
||||
|
||||
delete_disk $path
|
||||
|
||||
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@
|
|||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
|
|
@ -17,9 +17,9 @@
|
|||
# under the License.
|
||||
|
||||
#set -x
|
||||
|
||||
|
||||
usage() {
|
||||
printf "Usage: %s -t [template path] -n [template name] -s [snapshot name] -p [snapshot path] \n" $(basename $0)
|
||||
printf "Usage: %s -t [template path] -n [template name] -s [snapshot name] -p [snapshot path] \n" $(basename $0)
|
||||
}
|
||||
|
||||
snapshotPath=
|
||||
|
|
@ -68,7 +68,7 @@ copyvhd()
|
|||
exit 2
|
||||
fi
|
||||
if [[ "${parent}" =~ " no parent" ]]; then
|
||||
dd if=$srcvhd of=$desvhd bs=2M
|
||||
dd if=$srcvhd of=$desvhd bs=2M
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "31#failed to dd $srcvhd to $desvhd"
|
||||
rm -rf $desvhd > /dev/null
|
||||
|
|
|
|||
|
|
@ -6,16 +6,16 @@
|
|||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
|
||||
|
||||
# $Id: createtmplt.sh 9132 2010-06-04 20:17:43Z manuel $ $HeadURL: svn://svn.lab.vmops.com/repos/vmdev/java/scripts/storage/secondary/createtmplt.sh $
|
||||
# createtmplt.sh -- install a template
|
||||
|
|
@ -41,7 +41,7 @@ fi
|
|||
untar() {
|
||||
local ft=$(file $1| awk -F" " '{print $2}')
|
||||
case $ft in
|
||||
USTAR)
|
||||
USTAR)
|
||||
printf "tar archives not supported\n" >&2
|
||||
return 1
|
||||
;;
|
||||
|
|
@ -87,12 +87,12 @@ uncompress() {
|
|||
;;
|
||||
esac
|
||||
|
||||
if [ $? -gt 0 ]
|
||||
if [ $? -gt 0 ]
|
||||
then
|
||||
printf "Failed to uncompress file (filetype=$ft), exiting "
|
||||
return 1
|
||||
return 1
|
||||
fi
|
||||
|
||||
|
||||
rm -f $1
|
||||
printf $tmpfile
|
||||
|
||||
|
|
@ -167,7 +167,7 @@ do
|
|||
done
|
||||
|
||||
isCifs() {
|
||||
#TO:DO incase of multiple zone where cifs and nfs exists,
|
||||
#TO:DO incase of multiple zone where cifs and nfs exists,
|
||||
#then check if the template file is from cifs using df -P filename
|
||||
#Currently only cifs is supported in hyperv zone.
|
||||
mount | grep "type cifs" > /dev/null
|
||||
|
|
@ -182,7 +182,7 @@ fi
|
|||
|
||||
mkdir -p $tmpltfs
|
||||
|
||||
if [ ! -f $tmpltimg ]
|
||||
if [ ! -f $tmpltimg ]
|
||||
then
|
||||
printf "root disk file $tmpltimg doesn't exist\n"
|
||||
exit 3
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@
|
|||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
|
|
@ -16,7 +16,7 @@
|
|||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
|
||||
|
||||
|
||||
# $Id: createvolume.sh 9132 2010-06-04 20:17:43Z manuel $ $HeadURL: svn://svn.lab.vmops.com/repos/vmdev/java/scripts/storage/secondary/createvolume.sh $
|
||||
# createvolume.sh -- install a volume
|
||||
|
|
@ -53,7 +53,7 @@ verify_cksum() {
|
|||
esac
|
||||
echo "$1 $2" | $digestalgo -c --status
|
||||
#printf "$1\t$2" | $digestalgo -c --status
|
||||
if [ $? -gt 0 ]
|
||||
if [ $? -gt 0 ]
|
||||
then
|
||||
printf "Checksum failed, not proceeding with install\n"
|
||||
exit 3
|
||||
|
|
@ -63,7 +63,7 @@ verify_cksum() {
|
|||
untar() {
|
||||
local ft=$(file $1| awk -F" " '{print $2}')
|
||||
case $ft in
|
||||
USTAR)
|
||||
USTAR)
|
||||
printf "tar archives not supported\n" >&2
|
||||
return 1
|
||||
;;
|
||||
|
|
@ -109,12 +109,12 @@ uncompress() {
|
|||
;;
|
||||
esac
|
||||
|
||||
if [ $? -gt 0 ]
|
||||
if [ $? -gt 0 ]
|
||||
then
|
||||
printf "Failed to uncompress file (filetype=$ft), exiting "
|
||||
return 1
|
||||
return 1
|
||||
fi
|
||||
|
||||
|
||||
rm -f $1
|
||||
printf $tmpfile
|
||||
|
||||
|
|
@ -205,7 +205,7 @@ fi
|
|||
|
||||
mkdir -p $tmpltfs
|
||||
|
||||
if [ ! -f $tmpltimg ]
|
||||
if [ ! -f $tmpltimg ]
|
||||
then
|
||||
printf "root disk file $tmpltimg doesn't exist\n"
|
||||
exit 3
|
||||
|
|
@ -227,7 +227,7 @@ then
|
|||
if [ isCifs -ne 0 ] ;
|
||||
then
|
||||
if which vhd-util &>/dev/null
|
||||
then
|
||||
then
|
||||
vhd-util check -n ${tmpltimg2} > /dev/null
|
||||
rollback_if_needed $tmpltfs $? "vhd check of $tmpltimg2 failed\n"
|
||||
vhd-util set -n ${tmpltimg2} -f "hidden" -v "0" > /dev/null
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@
|
|||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
|
|
@ -29,7 +29,7 @@ usage() {
|
|||
|
||||
verify_cksum() {
|
||||
echo "$1 $2" | md5sum -c --status
|
||||
if [ $? -gt 0 ]
|
||||
if [ $? -gt 0 ]
|
||||
then
|
||||
printf "Checksum failed, not proceeding with install\n"
|
||||
exit 3
|
||||
|
|
@ -44,7 +44,7 @@ install_file() {
|
|||
|
||||
mv $isofile /$isofs/$tmpltname
|
||||
|
||||
if [ $? -gt 0 ]
|
||||
if [ $? -gt 0 ]
|
||||
then
|
||||
printf "Move operation failed, iso $isofile not installed\n"
|
||||
exit 4
|
||||
|
|
@ -55,7 +55,7 @@ install_file() {
|
|||
isofs=$isofs/$file
|
||||
mp=${isofs%/iso/*}
|
||||
mp=/$mp/iso
|
||||
path=${isofs:${#mp}}
|
||||
path=${isofs:${#mp}}
|
||||
pushd $mp
|
||||
ln -s $path $file
|
||||
popd
|
||||
|
|
@ -108,10 +108,10 @@ then
|
|||
isofs=${isofs:1}
|
||||
fi
|
||||
|
||||
if [ ! -d /$isofs ]
|
||||
if [ ! -d /$isofs ]
|
||||
then
|
||||
mkdir -p /$isofs
|
||||
if [ $? -gt 0 ]
|
||||
if [ $? -gt 0 ]
|
||||
then
|
||||
printf "Failed to create iso fs $isofs\n" >&2
|
||||
exit 1
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@
|
|||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
|
|
@ -50,7 +50,7 @@ fi
|
|||
|
||||
|
||||
for i in $(find /$rootdir -name template.properties );
|
||||
do
|
||||
do
|
||||
d=$(dirname $i)
|
||||
filename=$(grep "^filename" $i | awk -F"=" '{print $NF}')
|
||||
# size=$(grep "virtualsize" $i | awk -F"=" '{print $NF}')
|
||||
|
|
@ -58,7 +58,7 @@ do
|
|||
# then
|
||||
# d=$d/$filename/$size
|
||||
# fi
|
||||
echo ${d#/}/$filename #remove leading slash
|
||||
echo ${d#/}/$filename #remove leading slash
|
||||
done
|
||||
|
||||
exit 0
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@
|
|||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
|
|
@ -50,7 +50,7 @@ fi
|
|||
|
||||
|
||||
for i in $(find /$rootdir -name volume.properties );
|
||||
do
|
||||
do
|
||||
d=$(dirname $i)
|
||||
filename=$(grep "^filename" $i | awk -F"=" '{print $NF}')
|
||||
# size=$(grep "virtualsize" $i | awk -F"=" '{print $NF}')
|
||||
|
|
@ -58,7 +58,7 @@ do
|
|||
# then
|
||||
# d=$d/$filename/$size
|
||||
# fi
|
||||
echo ${d#/}/$filename #remove leading slash
|
||||
echo ${d#/}/$filename #remove leading slash
|
||||
done
|
||||
|
||||
exit 0
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@
|
|||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@
|
|||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
|
|
@ -17,12 +17,12 @@
|
|||
# under the License.
|
||||
|
||||
help() {
|
||||
printf "Usage: $0
|
||||
-i nfs server ip
|
||||
printf "Usage: $0
|
||||
-i nfs server ip
|
||||
-p nfs server path
|
||||
-m mount point
|
||||
-h host
|
||||
-r write/read hb log
|
||||
-m mount point
|
||||
-h host
|
||||
-r write/read hb log
|
||||
-c cleanup
|
||||
-t interval between read hb log\n"
|
||||
exit 1
|
||||
|
|
@ -52,7 +52,7 @@ do
|
|||
HostIP="$OPTARG"
|
||||
;;
|
||||
r)
|
||||
rflag=1
|
||||
rflag=1
|
||||
;;
|
||||
t)
|
||||
interval="$OPTARG"
|
||||
|
|
@ -75,7 +75,7 @@ fi
|
|||
#delete VMs on this mountpoint
|
||||
deleteVMs() {
|
||||
local mountPoint=$1
|
||||
vmPids=$(ps aux| grep qemu | grep "$mountPoint" | awk '{print $2}' 2> /dev/null)
|
||||
vmPids=$(ps aux| grep qemu | grep "$mountPoint" | awk '{print $2}' 2> /dev/null)
|
||||
if [ $? -gt 0 ]
|
||||
then
|
||||
return
|
||||
|
|
@ -100,7 +100,7 @@ then
|
|||
mount $NfsSvrIP:$NfsSvrPath $MountPoint -o sync,soft,proto=tcp,acregmin=0,acregmax=0,acdirmin=0,acdirmax=0,noac &> /dev/null
|
||||
if [ $? -gt 0 ]
|
||||
then
|
||||
printf "Failed to remount $NfsSvrIP:$NfsSvrPath under $MountPoint"
|
||||
printf "Failed to remount $NfsSvrIP:$NfsSvrPath under $MountPoint"
|
||||
exit 1
|
||||
fi
|
||||
if [ "$rflag" == "0" ]
|
||||
|
|
@ -162,6 +162,6 @@ then
|
|||
echo b > /proc/sysrq-trigger
|
||||
exit $?
|
||||
else
|
||||
write_hbLog
|
||||
write_hbLog
|
||||
exit $?
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@
|
|||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
|
|
@ -17,7 +17,7 @@
|
|||
# under the License.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Did cloudstack-agent installed
|
||||
#set -x
|
||||
|
|
@ -26,7 +26,7 @@ install_cloud_agent() {
|
|||
local retry=10
|
||||
which cloudstack-setup-agent
|
||||
if [ $? -gt 0 ]
|
||||
then
|
||||
then
|
||||
# download the repo
|
||||
which wget
|
||||
if [ $? -gt 0 ]
|
||||
|
|
@ -36,7 +36,7 @@ install_cloud_agent() {
|
|||
then
|
||||
printf "failed to install wget"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
wget -N -P /etc/yum.repos.d/ http://download.cloudstack.org/foss/fedora/cloud.repo
|
||||
if [ $? -gt 0 ]
|
||||
|
|
@ -46,7 +46,7 @@ install_cloud_agent() {
|
|||
fi
|
||||
if [ "$dev" == "1" ]
|
||||
then
|
||||
sed -i 's/\(baseurl\)\(.*\)/\1=http:\/\/yumrepo.lab.vmops.com\/repositories\/fedora\/vmdev\/oss\//' /etc/yum.repos.d/cloud.repo
|
||||
sed -i 's/\(baseurl\)\(.*\)/\1=http:\/\/yumrepo.lab.vmops.com\/repositories\/fedora\/vmdev\/oss\//' /etc/yum.repos.d/cloud.repo
|
||||
fi
|
||||
while [ "$retry" -gt "0" ]
|
||||
do
|
||||
|
|
@ -74,7 +74,7 @@ install_cloud_agent() {
|
|||
|
||||
done
|
||||
fi
|
||||
|
||||
|
||||
if [ $? -gt 0 ]
|
||||
then
|
||||
printf "Failed to install agent"
|
||||
|
|
@ -87,7 +87,7 @@ install_cloud_consoleP() {
|
|||
local retry=10
|
||||
which cloud-setup-console-proxy
|
||||
if [ $? -gt 0 ]
|
||||
then
|
||||
then
|
||||
# download the repo
|
||||
which wget
|
||||
if [ $? -gt 0 ]
|
||||
|
|
@ -97,7 +97,7 @@ install_cloud_consoleP() {
|
|||
then
|
||||
printf "failed to install wget"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
wget -N -P=/etc/yum.repos.d/ http://download.cloudstack.org/foss/fedora/cloud.repo
|
||||
if [ $? -gt 0 ]
|
||||
|
|
@ -107,7 +107,7 @@ install_cloud_consoleP() {
|
|||
fi
|
||||
if [ "$dev" == "1" ]
|
||||
then
|
||||
sed -i 's/\(baseurl\)\(.*\)/\1=http:\/\/yumrepo.lab.vmops.com\/repositories\/fedora\/vmdev\/oss\//' /etc/yum.repos.d/cloud.repo
|
||||
sed -i 's/\(baseurl\)\(.*\)/\1=http:\/\/yumrepo.lab.vmops.com\/repositories\/fedora\/vmdev\/oss\//' /etc/yum.repos.d/cloud.repo
|
||||
fi
|
||||
while [ "$retry" -gt "0" ]
|
||||
do
|
||||
|
|
@ -135,7 +135,7 @@ install_cloud_consoleP() {
|
|||
|
||||
done
|
||||
fi
|
||||
|
||||
|
||||
if [ $? -gt 0 ]
|
||||
then
|
||||
printf "Failed to install console"
|
||||
|
|
@ -176,28 +176,28 @@ prvNic=
|
|||
while getopts 'h:z:p:u:c:P:N:d' OPTION
|
||||
do
|
||||
case $OPTION in
|
||||
h)
|
||||
h)
|
||||
host="$OPTARG"
|
||||
;;
|
||||
z)
|
||||
z)
|
||||
zone="$OPTARG"
|
||||
;;
|
||||
p)
|
||||
p)
|
||||
pod="$OPTARG"
|
||||
;;
|
||||
c)
|
||||
c)
|
||||
cluster="$OPTARG"
|
||||
;;
|
||||
u)
|
||||
u)
|
||||
guid="$OPTARG"
|
||||
;;
|
||||
d)
|
||||
d)
|
||||
dflag=1
|
||||
;;
|
||||
P)
|
||||
P)
|
||||
pubNic="$OPTARG"
|
||||
;;
|
||||
N)
|
||||
N)
|
||||
prvNic="$OPTARG"
|
||||
;;
|
||||
*) ;;
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@
|
|||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
|
|
@ -17,7 +17,7 @@
|
|||
# under the License.
|
||||
|
||||
#set -x
|
||||
|
||||
|
||||
usage() {
|
||||
printf "Usage: %s [uuid of this host] [interval in seconds]\n" $(basename $0) >&2
|
||||
|
||||
|
|
@ -53,7 +53,7 @@ do
|
|||
diff=`expr $date - $ping`
|
||||
if [ $diff -lt $2 ]; then
|
||||
echo "=====> ALIVE <====="
|
||||
exit 0;
|
||||
exit 0;
|
||||
fi
|
||||
done
|
||||
|
||||
|
|
@ -67,7 +67,7 @@ do
|
|||
diff=`expr $date - $ping`
|
||||
if [ $diff -lt $2 ]; then
|
||||
echo "=====> ALIVE <====="
|
||||
exit 0;
|
||||
exit 0;
|
||||
fi
|
||||
done
|
||||
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@
|
|||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@
|
|||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
|
|
@ -88,7 +88,7 @@ fake_pv_driver() {
|
|||
|
||||
vms=$(xe vm-list is-control-domain=false| grep ^uuid | awk '{print $NF}')
|
||||
for vm in $vms
|
||||
do
|
||||
do
|
||||
state=$(xe vm-param-get uuid=$vm param-name=power-state)
|
||||
if [ $state = "running" ]; then
|
||||
fake_pv_driver $vm
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@
|
|||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@
|
|||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
|
|
@ -17,7 +17,7 @@
|
|||
# under the License.
|
||||
|
||||
#set -x
|
||||
|
||||
|
||||
usage() {
|
||||
printf "Usage: %s \n" $(basename $0) >&2
|
||||
|
||||
|
|
@ -33,7 +33,7 @@ moveConfigToBond() {
|
|||
if [ -n "$bondSlaveIp" ]; then
|
||||
mode=$(xe pif-param-get param-name=IP-configuration-mode uuid=$bondSlave)
|
||||
netmask=$(xe pif-param-get param-name=netmask uuid=$bondSlave)
|
||||
gateway=$(xe pif-param-get param-name=gateway uuid=$bondSlave)
|
||||
gateway=$(xe pif-param-get param-name=gateway uuid=$bondSlave)
|
||||
DNS=$(xe pif-param-get param-name=DNS uuid=$bondSlave)
|
||||
management=$(xe pif-param-get param-name=management uuid=$bondSlave)
|
||||
slavedevice=$(xe pif-param-get param-name=device uuid=$bondSlave)
|
||||
|
|
@ -47,7 +47,7 @@ moveConfigToBond() {
|
|||
echo " --Succeeded"
|
||||
if [ "$management" = "true" ]; then
|
||||
echo " --move management interface from $slavedevice($bondSlave) to $masterdevice($bondMaster)"
|
||||
xe host-management-reconfigure pif-uuid=$bondMaster
|
||||
xe host-management-reconfigure pif-uuid=$bondMaster
|
||||
if [ $? -ne 0 ]; then
|
||||
echo " --Failed to move management interface from $bondSlave to $bondMaster, please run xe host-management-reconfigure pif-uuid=$bondMaster manually"
|
||||
exit 1
|
||||
|
|
@ -62,7 +62,7 @@ moveConfigToBond() {
|
|||
xe pif-plug uuid=$bondMaster
|
||||
done
|
||||
fi
|
||||
}
|
||||
}
|
||||
|
||||
poolUuid=$(xe pool-list | grep ^uuid | awk '{print $NF}')
|
||||
hostMaster=$(xe pool-param-get uuid=$poolUuid param-name=master)
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@
|
|||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
|
|
@ -17,14 +17,14 @@
|
|||
# under the License.
|
||||
|
||||
#set -x
|
||||
|
||||
|
||||
usage() {
|
||||
printf "Usage: %s [vhd file in secondary storage] [uuid of the source sr] [name label] \n" $(basename $0)
|
||||
printf "Usage: %s [vhd file in secondary storage] [uuid of the source sr] [name label] \n" $(basename $0)
|
||||
}
|
||||
|
||||
cleanup()
|
||||
{
|
||||
if [ ! -z $localmp ]; then
|
||||
if [ ! -z $localmp ]; then
|
||||
umount -fl $localmp
|
||||
if [ $? -eq 0 ]; then
|
||||
rmdir $localmp
|
||||
|
|
@ -158,7 +158,7 @@ elif [ $type == "lvmoiscsi" -o $type == "lvm" -o $type == "lvmohba" ]; then
|
|||
exit 0
|
||||
fi
|
||||
copyvhd $desvhd $vhdfile $lvsize $type
|
||||
else
|
||||
else
|
||||
echo "15#doesn't support sr type $type"
|
||||
cleanup
|
||||
exit 0
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@
|
|||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
|
|
@ -17,14 +17,14 @@
|
|||
# under the License.
|
||||
|
||||
#set -x
|
||||
|
||||
|
||||
usage() {
|
||||
printf "Usage: %s [mountpoint in secondary storage] [uuid of the source vdi] [uuid of the source sr]\n" $(basename $0)
|
||||
printf "Usage: %s [mountpoint in secondary storage] [uuid of the source vdi] [uuid of the source sr]\n" $(basename $0)
|
||||
}
|
||||
|
||||
cleanup()
|
||||
{
|
||||
if [ ! -z $localmp ]; then
|
||||
if [ ! -z $localmp ]; then
|
||||
umount $localmp
|
||||
if [ $? -eq 0 ]; then
|
||||
rmdir $localmp
|
||||
|
|
@ -120,7 +120,7 @@ elif [ $type == "lvmoiscsi" -o $type == "lvm" -o $type == "lvmohba" ]; then
|
|||
cleanup
|
||||
exit 0
|
||||
fi
|
||||
else
|
||||
else
|
||||
echo "15#doesn't support sr type $type"
|
||||
cleanup
|
||||
exit 0
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@
|
|||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
|
|
@ -17,20 +17,20 @@
|
|||
# under the License.
|
||||
|
||||
#set -x
|
||||
|
||||
|
||||
usage() {
|
||||
printf "Usage: %s [vhd file in secondary storage] [template directory in secondary storage] [template local dir] \n" $(basename $0)
|
||||
printf "Usage: %s [vhd file in secondary storage] [template directory in secondary storage] [template local dir] \n" $(basename $0)
|
||||
}
|
||||
options='tcp,soft,timeo=133,retrans=1'
|
||||
cleanup()
|
||||
{
|
||||
if [ ! -z $snapshotdir ]; then
|
||||
if [ ! -z $snapshotdir ]; then
|
||||
umount $snapshotdir
|
||||
if [ $? -eq 0 ]; then
|
||||
rmdir $snapshotdir
|
||||
fi
|
||||
fi
|
||||
if [ ! -z $templatedir ]; then
|
||||
if [ ! -z $templatedir ]; then
|
||||
umount $templatedir
|
||||
if [ $? -eq 0 ]; then
|
||||
rmdir $templatedir
|
||||
|
|
@ -110,7 +110,7 @@ copyvhd()
|
|||
exit 0
|
||||
fi
|
||||
if [[ "${parent}" =~ " no parent" ]]; then
|
||||
dd if=$srcvhd of=$desvhd bs=2M
|
||||
dd if=$srcvhd of=$desvhd bs=2M
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "31#failed to dd $srcvhd to $desvhd"
|
||||
cleanup
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@
|
|||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
|
|
@ -17,9 +17,9 @@
|
|||
# under the License.
|
||||
|
||||
#set -x
|
||||
|
||||
|
||||
usage() {
|
||||
printf "Usage: %s [name label] \n" $(basename $0)
|
||||
printf "Usage: %s [name label] \n" $(basename $0)
|
||||
}
|
||||
|
||||
if [ -z $1 ]; then
|
||||
|
|
@ -34,7 +34,7 @@ pid=`ps -ef | grep "dd" | grep $namelabel | grep -v "grep" | awk '{print $2}'`
|
|||
if [ -z $pid ]; then
|
||||
echo "true"
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
kill -9 $pid
|
||||
if [ $? -ne 0 ]; then
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@
|
|||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
|
|
@ -17,7 +17,7 @@
|
|||
# under the License.
|
||||
|
||||
#set -x
|
||||
|
||||
|
||||
usage() {
|
||||
printf "Usage: %s [uuid of this host] [interval in seconds]\n" $(basename $0)
|
||||
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue