Skip to content

Add config_drive and user_data to replace_launch_config #588

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions pyrax/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@
import six.moves.configparser as ConfigParser
import warnings

# Ignore UserWarnings. Currently we're getting warnings about novaclient.v1_1
# deprecations as UserWarning instead of DeprecationWarning (why?).
warnings.filterwarnings("ignore", ".*novaclient.v1_1 is deprecated.*")

# keyring is an optional import
try:
import keyring
Expand Down
5 changes: 3 additions & 2 deletions pyrax/autoscale.py
Original file line number Diff line number Diff line change
Expand Up @@ -1077,7 +1077,7 @@ def get_launch_config(self, scaling_group):
def replace_launch_config(self, scaling_group, launch_config_type,
server_name, image, flavor, disk_config=None, metadata=None,
personality=None, networks=None, load_balancers=None,
key_name=None):
key_name=None, config_drive=False, user_data=None)):
"""
Replace an existing launch configuration. All of the attributes must be
specified. If you wish to delete any of the optional attributes, pass
Expand All @@ -1087,7 +1087,8 @@ def replace_launch_config(self, scaling_group, launch_config_type,
launch_config_type, server_name, image, flavor,
disk_config=disk_config, metadata=metadata,
personality=personality, networks=networks,
load_balancers=load_balancers, key_name=key_name)
load_balancers=load_balancers, key_name=key_name,
config_drive=config_drive, user_data=user_data)


def update_launch_config(self, scaling_group, server_name=None, image=None,
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def run(self):
"Operating System :: OS Independent",
],
install_requires=[
"python-novaclient>=2.13.0",
"python-novaclient>=2.13.0,<=2.27.0",
"rackspace-novaclient",
"keyring",
"requests>=2.2.1",
Expand Down
18 changes: 14 additions & 4 deletions tests/unit/test_autoscale.py
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,8 @@ def test_mgr_replace_launch_config(self):
metadata = utils.random_unicode()
personality = utils.random_unicode()
networks = utils.random_unicode()

userdata = utils.random_unicode()
config_drive = utils.random_unicode()
sg.launchConfiguration = {
"type": typ,
"args": {
Expand All @@ -683,6 +684,8 @@ def test_mgr_replace_launch_config(self):
"personality": personality,
"networks": networks,
"metadata": metadata,
"user_data": userdata,
"config_drive": config_drive,
},
"loadBalancers": lbs,
},
Expand All @@ -699,6 +702,8 @@ def test_mgr_replace_launch_config(self):
"name": new_name,
"imageRef": new_img,
"flavorRef": new_flv,
"user_data": userdata,
"config_drive": config_drive,
},
"loadBalancers": []
}
Expand All @@ -708,7 +713,8 @@ def test_mgr_replace_launch_config(self):
uri = "/%s/%s/launch" % (mgr.uri_base, sg.id)

mgr.replace_launch_config(sg.id, launch_config_type=new_typ,
server_name=new_name, flavor=new_flv, image=new_img)
server_name=new_name, flavor=new_flv, image=new_img,
user_data=userdata, config_drive=config_drive)
mgr.api.method_put.assert_called_once_with(uri, body=expected)

def test_mgr_update_launch_metadata(self):
Expand Down Expand Up @@ -1532,15 +1538,19 @@ def test_clt_replace_launch_config(self):
networks = utils.random_unicode()
load_balancers = utils.random_unicode()
key_name = utils.random_unicode()
userdata = utils.random_unicode()
config_drive = utils.random_unicode()
clt.replace_launch_config(sg, launch_config_type, server_name, image,
flavor, disk_config=disk_config, metadata=metadata,
personality=personality, networks=networks,
load_balancers=load_balancers, key_name=key_name)
load_balancers=load_balancers, key_name=key_name,
user_data=userdata, config_drive=config_drive)
mgr.replace_launch_config.assert_called_once_with(sg,
launch_config_type, server_name, image, flavor,
disk_config=disk_config, metadata=metadata,
personality=personality, networks=networks,
load_balancers=load_balancers, key_name=key_name)
load_balancers=load_balancers, key_name=key_name,
user_data=userdata, config_drive=config_drive)

def test_clt_update_launch_config(self):
clt = fakes.FakeAutoScaleClient()
Expand Down