This repository has been archived by the owner on Aug 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ec2: Create a script to initiate the complete process
Signed-off-by: Sayan Chowdhury <[email protected]>
- Loading branch information
1 parent
9528456
commit 13d13ee
Showing
7 changed files
with
141 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1 @@ | ||
# This file is part of fedimg. | ||
# Copyright (C) 2014-2017 Red Hat, Inc. | ||
# | ||
# fedimg is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU Affero General Public License as | ||
# published by the Free Software Foundation, either version 3 of the | ||
# License, or (at your option) any later version. | ||
# | ||
# fedimg is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
# Affero General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Affero General Public | ||
# License along with fedimg; if not, see http://www.gnu.org/licenses, | ||
# or write to the Free Software Foundation, Inc., | ||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
# | ||
# Authors: David Gay <[email protected]> | ||
# Sayan Chowdhury <[email protected]> | ||
|
||
import toml | ||
|
||
# Read in config file | ||
with open("/etc/fedimg/fedimg-conf.toml") as conffile: | ||
config = toml.loads(conffile.read()) | ||
|
||
# Fedimg Consumer configurations | ||
PROCESS_COUNT = 4 | ||
STATUS_FILTER = ('FINISHED_INCOMPLETE', 'FINISHED') | ||
|
||
CLEAN_UP_ON_FAILURE = config.get('general', 'clean_up_on_failure') | ||
DELETE_IMAGES_ON_FAILURE = config.get('general', 'delete_images_on_failure') | ||
|
||
# AMAZON WEB SERVICES (EC2) | ||
AWS_UTIL_USER = config.get('aws', 'util_username') | ||
AWS_TEST_USER = config.get('aws', 'test_username') | ||
AWS_ACCESS_ID = config.get('aws', 'access_id') | ||
AWS_SECRET_KEY = config.get('aws', 'secret_key') | ||
AWS_VOL_SIZE = config.get('aws', 'volume_size') | ||
AWS_IAM_PROFILE = config.get('aws', 'iam_profile') | ||
|
||
# RACKSPACE | ||
RACKSPACE_USER = config.get('rackspace', 'username') | ||
RACKSPACE_API_KEY = config.get('rackspace', 'api_key') | ||
|
||
# GCE | ||
GCE_EMAIL = config.get('gce', 'email') | ||
GCE_KEYPATH = config.get('gce', 'keypath') | ||
GCE_PROJECT_ID = config.get('gce', 'project_id') | ||
|
||
# HP | ||
HP_USER = config.get('hp', 'username') | ||
HP_PASSWORD = config.get('hp', 'password') | ||
HP_TENANT = config.get('hp', 'tenant') | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# This file is part of fedimg. | ||
# Copyright (C) 2014-2017 Red Hat, Inc. | ||
# | ||
# fedimg is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU Affero General Public License as | ||
# published by the Free Software Foundation, either version 3 of the | ||
# License, or (at your option) any later version. | ||
# | ||
# fedimg is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
# Affero General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Affero General Public | ||
# License along with fedimg; if not, see http://www.gnu.org/licenses, | ||
# or write to the Free Software Foundation, Inc., | ||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
# | ||
# Authors: David Gay <[email protected]> | ||
# Sayan Chowdhury <[email protected]> | ||
|
||
import toml | ||
|
||
# Read in config file | ||
with open("/etc/fedimg/fedimg-conf.toml") as conffile: | ||
config = toml.loads(conffile.read()) | ||
|
||
# Fedimg Consumer configurations | ||
PROCESS_COUNT = 4 | ||
STATUS_FILTER = ('FINISHED_INCOMPLETE', 'FINISHED') | ||
|
||
ACTIVE_SERVICES = config.get('general', 'active_services') | ||
CLEAN_UP_ON_FAILURE = config.get('general', 'clean_up_on_failure') | ||
DELETE_IMAGES_ON_FAILURE = config.get('general', 'delete_images_on_failure') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# This file is part of fedimg. | ||
# Copyright (C) 2014-2017 Red Hat, Inc. | ||
# | ||
# fedimg is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU Affero General Public License as | ||
# published by the Free Software Foundation, either version 3 of the | ||
# License, or (at your option) any later version. | ||
# | ||
# fedimg is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
# Affero General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Affero General Public | ||
# License along with fedimg; if not, see http://www.gnu.org/licenses, | ||
# or write to the Free Software Foundation, Inc., | ||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
# | ||
# Authors: David Gay <[email protected]> | ||
# Sayan Chowdhury <[email protected]> | ||
|
||
|
||
import toml | ||
|
||
# Read in config file | ||
with open("/etc/fedimg/fedimg-conf.toml") as conffile: | ||
config = toml.loads(conffile.read()) | ||
|
||
UTIL_USER = config.get('aws', 'util_username') | ||
TEST_USER = config.get('aws', 'test_username') | ||
ACCESS_ID = config.get('aws', 'access_id') | ||
SECRET_KEY = config.get('aws', 'secret_key') | ||
VOLUME_SIZE = config.get('aws', 'volume_size') | ||
VOLUME_TYPES = config.get('aws', 'volume_types') | ||
VOLUME_VIA_S3 = config.get('aws', 'volume_via_s3') | ||
IAM_PROFILE = config.get('aws', 'iam_profile') | ||
REGIONS = config.get('aws', 'regions') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# This file is part of fedimg. | ||
# Copyright (C) 2014-2017 Red Hat, Inc. | ||
# | ||
# fedimg is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU Affero General Public License as | ||
# published by the Free Software Foundation, either version 3 of the | ||
# License, or (at your option) any later version. | ||
# | ||
# fedimg is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
# Affero General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Affero General Public | ||
# License along with fedimg; if not, see http://www.gnu.org/licenses, | ||
# or write to the Free Software Foundation, Inc., | ||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
# | ||
# Authors: Sayan Chowdhury <[email protected]> | ||
# | ||
|
||
from itertools import product as itertools_product | ||
|
||
from fedimg.ec2.config import ACCESS_ID, SECRET_KEY, REGIONS | ||
from fedimg.ec2.config import VOLUME_TYPES, VOLUME_VIA_S3 | ||
from fedimg.services.ec2.ec2imageuploader import EC2ImageUploader | ||
from fedimg.services.ec2.ec2imagepublisher import EC2ImagePublisher | ||
from fedimg.utils import get_virt_types_from_url, get_source_for_image | ||
|
||
|
||
def main(image_url): | ||
access_id = ACCESS_ID | ||
secret_key = SECRET_KEY | ||
regions = REGIONS | ||
volume_types = VOLUME_TYPES | ||
volume_via_s3 = VOLUME_VIA_S3 | ||
virt_types = get_virt_types_from_url(image_url) | ||
|
||
source = get_source_for_image(image_url) | ||
|
||
uploader = EC2ImageUploader( | ||
access_key=access_id, | ||
secret_key=secret_key, | ||
volume_via_s3=volume_via_s3) | ||
|
||
publisher = EC2ImagePublisher( | ||
access_key=access_id, | ||
secret_key=secret_key) | ||
|
||
combinations = itertools_product(*[regions, virt_types, volume_types]) | ||
for region, virt_type, volume_type in combinations: | ||
uploader.set_region(region) | ||
uploader.set_image_virt_type(virt_type) | ||
uploader.set_image_volume_type(volume_type) | ||
|
||
publisher.set_region(region) | ||
|
||
image = uploader.create_image(source) | ||
|
||
publisher.publish_images(image_ids=[image.id]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters