Linux ip-148-66-134-25.ip.secureserver.net 3.10.0-1160.119.1.el7.tuxcare.els10.x86_64 #1 SMP Fri Oct 11 21:40:41 UTC 2024 x86_64
Apache
: 148.66.134.25 | : 3.15.228.171
66 Domain
8.0.30
amvm
www.github.com/MadExploits
Terminal
AUTO ROOT
Adminer
Backdoor Destroyer
Linux Exploit
Lock Shell
Lock File
Create User
CREATE RDP
PHP Mailer
BACKCONNECT
UNLOCK SHELL
HASH IDENTIFIER
CPANEL RESET
BLACK DEFEND!
README
+ Create Folder
+ Create File
/
usr /
lib /
python2.7 /
site-packages /
cloudinit /
config /
[ HOME SHELL ]
Name
Size
Permission
Action
__init__.py
1.4
KB
-rw-r--r--
__init__.pyc
1.3
KB
-rw-r--r--
__init__.pyo
1.3
KB
-rw-r--r--
cc_apt_configure.py
32.06
KB
-rw-r--r--
cc_apt_configure.pyc
29.4
KB
-rw-r--r--
cc_apt_configure.pyo
29.4
KB
-rw-r--r--
cc_apt_pipelining.py
2.43
KB
-rw-r--r--
cc_apt_pipelining.pyc
2.49
KB
-rw-r--r--
cc_apt_pipelining.pyo
2.49
KB
-rw-r--r--
cc_bootcmd.py
2.04
KB
-rw-r--r--
cc_bootcmd.pyc
2.06
KB
-rw-r--r--
cc_bootcmd.pyo
2.06
KB
-rw-r--r--
cc_byobu.py
3.09
KB
-rw-r--r--
cc_byobu.pyc
3.08
KB
-rw-r--r--
cc_byobu.pyo
3.08
KB
-rw-r--r--
cc_ca_certs.py
4.09
KB
-rw-r--r--
cc_ca_certs.pyc
4.1
KB
-rw-r--r--
cc_ca_certs.pyo
4.1
KB
-rw-r--r--
cc_chef.py
12.51
KB
-rw-r--r--
cc_chef.pyc
9.98
KB
-rw-r--r--
cc_chef.pyo
9.98
KB
-rw-r--r--
cc_debug.py
3.05
KB
-rw-r--r--
cc_debug.pyc
3.31
KB
-rw-r--r--
cc_debug.pyo
3.31
KB
-rw-r--r--
cc_disable_ec2_metadata.py
1.17
KB
-rw-r--r--
cc_disable_ec2_metadata.pyc
1.28
KB
-rw-r--r--
cc_disable_ec2_metadata.pyo
1.28
KB
-rw-r--r--
cc_disk_setup.py
30.52
KB
-rw-r--r--
cc_disk_setup.pyc
28.24
KB
-rw-r--r--
cc_disk_setup.pyo
28.24
KB
-rw-r--r--
cc_emit_upstart.py
2
KB
-rw-r--r--
cc_emit_upstart.pyc
2.14
KB
-rw-r--r--
cc_emit_upstart.pyo
2.14
KB
-rw-r--r--
cc_fan.py
2.82
KB
-rw-r--r--
cc_fan.pyc
3.09
KB
-rw-r--r--
cc_fan.pyo
3.09
KB
-rw-r--r--
cc_final_message.py
2.35
KB
-rw-r--r--
cc_final_message.pyc
2.39
KB
-rw-r--r--
cc_final_message.pyo
2.39
KB
-rw-r--r--
cc_foo.py
2.07
KB
-rw-r--r--
cc_foo.pyc
702
B
-rw-r--r--
cc_foo.pyo
702
B
-rw-r--r--
cc_growpart.py
11
KB
-rw-r--r--
cc_growpart.pyc
10.83
KB
-rw-r--r--
cc_growpart.pyo
10.83
KB
-rw-r--r--
cc_grub_dpkg.py
2.87
KB
-rw-r--r--
cc_grub_dpkg.pyc
2.63
KB
-rw-r--r--
cc_grub_dpkg.pyo
2.63
KB
-rw-r--r--
cc_keys_to_console.py
2.39
KB
-rw-r--r--
cc_keys_to_console.pyc
2.42
KB
-rw-r--r--
cc_keys_to_console.pyo
2.42
KB
-rw-r--r--
cc_landscape.py
3.96
KB
-rw-r--r--
cc_landscape.pyc
3.98
KB
-rw-r--r--
cc_landscape.pyo
3.98
KB
-rw-r--r--
cc_locale.py
1.16
KB
-rw-r--r--
cc_locale.pyc
1.16
KB
-rw-r--r--
cc_locale.pyo
1.16
KB
-rw-r--r--
cc_lxd.py
8.47
KB
-rw-r--r--
cc_lxd.pyc
6.55
KB
-rw-r--r--
cc_lxd.pyo
6.55
KB
-rw-r--r--
cc_mcollective.py
5.08
KB
-rw-r--r--
cc_mcollective.pyc
3.8
KB
-rw-r--r--
cc_mcollective.pyo
3.8
KB
-rw-r--r--
cc_migrator.py
3.07
KB
-rw-r--r--
cc_migrator.pyc
3.18
KB
-rw-r--r--
cc_migrator.pyo
3.18
KB
-rw-r--r--
cc_mounts.py
15.43
KB
-rw-r--r--
cc_mounts.pyc
13.19
KB
-rw-r--r--
cc_mounts.pyo
13.19
KB
-rw-r--r--
cc_ntp.py
3.45
KB
-rw-r--r--
cc_ntp.pyc
3.94
KB
-rw-r--r--
cc_ntp.pyo
3.94
KB
-rw-r--r--
cc_package_update_upgrade_inst...
4.07
KB
-rw-r--r--
cc_package_update_upgrade_inst...
4.01
KB
-rw-r--r--
cc_package_update_upgrade_inst...
4.01
KB
-rw-r--r--
cc_phone_home.py
3.89
KB
-rw-r--r--
cc_phone_home.pyc
3.23
KB
-rw-r--r--
cc_phone_home.pyo
3.23
KB
-rw-r--r--
cc_power_state_change.py
7.66
KB
-rw-r--r--
cc_power_state_change.pyc
7.83
KB
-rw-r--r--
cc_power_state_change.pyo
7.83
KB
-rw-r--r--
cc_puppet.py
6.26
KB
-rw-r--r--
cc_puppet.pyc
4.7
KB
-rw-r--r--
cc_puppet.pyo
4.7
KB
-rw-r--r--
cc_resizefs.py
6.06
KB
-rw-r--r--
cc_resizefs.pyc
5.65
KB
-rw-r--r--
cc_resizefs.pyo
5.65
KB
-rw-r--r--
cc_resolv_conf.py
3.41
KB
-rw-r--r--
cc_resolv_conf.pyc
3.42
KB
-rw-r--r--
cc_resolv_conf.pyo
3.42
KB
-rw-r--r--
cc_rh_subscription.py
15.9
KB
-rw-r--r--
cc_rh_subscription.pyc
13.5
KB
-rw-r--r--
cc_rh_subscription.pyo
13.5
KB
-rw-r--r--
cc_rightscale_userdata.py
3.75
KB
-rw-r--r--
cc_rightscale_userdata.pyc
2.82
KB
-rw-r--r--
cc_rightscale_userdata.pyo
2.82
KB
-rw-r--r--
cc_rsyslog.py
14.06
KB
-rw-r--r--
cc_rsyslog.pyc
10.55
KB
-rw-r--r--
cc_rsyslog.pyo
10.55
KB
-rw-r--r--
cc_runcmd.py
1.64
KB
-rw-r--r--
cc_runcmd.pyc
1.69
KB
-rw-r--r--
cc_runcmd.pyo
1.69
KB
-rw-r--r--
cc_salt_minion.py
2.86
KB
-rw-r--r--
cc_salt_minion.pyc
2.39
KB
-rw-r--r--
cc_salt_minion.pyo
2.39
KB
-rw-r--r--
cc_scripts_per_boot.py
1.2
KB
-rw-r--r--
cc_scripts_per_boot.pyc
1.2
KB
-rw-r--r--
cc_scripts_per_boot.pyo
1.2
KB
-rw-r--r--
cc_scripts_per_instance.py
1.23
KB
-rw-r--r--
cc_scripts_per_instance.pyc
1.24
KB
-rw-r--r--
cc_scripts_per_instance.pyo
1.24
KB
-rw-r--r--
cc_scripts_per_once.py
1.17
KB
-rw-r--r--
cc_scripts_per_once.pyc
1.18
KB
-rw-r--r--
cc_scripts_per_once.pyo
1.18
KB
-rw-r--r--
cc_scripts_user.py
1.42
KB
-rw-r--r--
cc_scripts_user.pyc
1.38
KB
-rw-r--r--
cc_scripts_user.pyo
1.38
KB
-rw-r--r--
cc_scripts_vendor.py
1.38
KB
-rw-r--r--
cc_scripts_vendor.pyc
1.46
KB
-rw-r--r--
cc_scripts_vendor.pyo
1.46
KB
-rw-r--r--
cc_seed_random.py
4.36
KB
-rw-r--r--
cc_seed_random.pyc
4.5
KB
-rw-r--r--
cc_seed_random.pyo
4.5
KB
-rw-r--r--
cc_set_hostname.py
1.65
KB
-rw-r--r--
cc_set_hostname.pyc
1.67
KB
-rw-r--r--
cc_set_hostname.pyo
1.67
KB
-rw-r--r--
cc_set_passwords.py
6.7
KB
-rw-r--r--
cc_set_passwords.pyc
5.59
KB
-rw-r--r--
cc_set_passwords.pyo
5.59
KB
-rw-r--r--
cc_snap_config.py
5
KB
-rw-r--r--
cc_snap_config.pyc
4.75
KB
-rw-r--r--
cc_snap_config.pyo
4.75
KB
-rw-r--r--
cc_snappy.py
9.36
KB
-rw-r--r--
cc_snappy.pyc
9
KB
-rw-r--r--
cc_snappy.pyo
9
KB
-rw-r--r--
cc_spacewalk.py
2.89
KB
-rw-r--r--
cc_spacewalk.pyc
2.91
KB
-rw-r--r--
cc_spacewalk.pyo
2.91
KB
-rw-r--r--
cc_ssh.py
8.14
KB
-rw-r--r--
cc_ssh.pyc
7.35
KB
-rw-r--r--
cc_ssh.pyo
7.35
KB
-rw-r--r--
cc_ssh_authkey_fingerprints.py
3.46
KB
-rw-r--r--
cc_ssh_authkey_fingerprints.py...
3.98
KB
-rw-r--r--
cc_ssh_authkey_fingerprints.py...
3.98
KB
-rw-r--r--
cc_ssh_import_id.py
2.88
KB
-rw-r--r--
cc_ssh_import_id.pyc
2.72
KB
-rw-r--r--
cc_ssh_import_id.pyo
2.72
KB
-rw-r--r--
cc_timezone.py
1.15
KB
-rw-r--r--
cc_timezone.pyc
1.15
KB
-rw-r--r--
cc_timezone.pyo
1.15
KB
-rw-r--r--
cc_ubuntu_init_switch.py
4.53
KB
-rw-r--r--
cc_ubuntu_init_switch.pyc
4.72
KB
-rw-r--r--
cc_ubuntu_init_switch.pyo
4.72
KB
-rw-r--r--
cc_update_etc_hosts.py
3.28
KB
-rw-r--r--
cc_update_etc_hosts.pyc
2.95
KB
-rw-r--r--
cc_update_etc_hosts.pyo
2.95
KB
-rw-r--r--
cc_update_hostname.py
1.58
KB
-rw-r--r--
cc_update_hostname.pyc
1.66
KB
-rw-r--r--
cc_update_hostname.pyo
1.66
KB
-rw-r--r--
cc_users_groups.py
3.77
KB
-rw-r--r--
cc_users_groups.pyc
3.83
KB
-rw-r--r--
cc_users_groups.pyo
3.83
KB
-rw-r--r--
cc_write_files.py
4.28
KB
-rw-r--r--
cc_write_files.pyc
4.47
KB
-rw-r--r--
cc_write_files.pyo
4.47
KB
-rw-r--r--
cc_yum_add_repo.py
4.05
KB
-rw-r--r--
cc_yum_add_repo.pyc
3.68
KB
-rw-r--r--
cc_yum_add_repo.pyo
3.68
KB
-rw-r--r--
Delete
Unzip
Zip
${this.title}
Close
Code Editor : cc_rh_subscription.py
# Copyright (C) 2015 Red Hat, Inc. # # Author: Brent Baude <bbaude@redhat.com> # # This file is part of cloud-init. See LICENSE file for license information. """ RedHat Subscription ------------------- **Summary:** register red hat enterprise linux based system Register a RedHat system either by username and password *or* activation and org. Following a sucessful registration, you can auto-attach subscriptions, set the service level, add subscriptions based on pool id, enable/disable yum repositories based on repo id, and alter the rhsm_baseurl and server-hostname in ``/etc/rhsm/rhs.conf``. For more details, see the ``Register RedHat Subscription`` example config. **Internal name:** ``cc_rh_subscription`` **Module frequency:** per instance **Supported distros:** rhel, fedora **Config keys**:: rh_subscription: username: <username> password: <password> activation-key: <activation key> org: <org number> auto-attach: <true/false> service-level: <service level> add-pool: <list of pool ids> enable-repo: <list of yum repo ids> disable-repo: <list of yum repo ids> rhsm-baseurl: <url> server-hostname: <hostname> """ from cloudinit import util distros = ['fedora', 'rhel'] def handle(name, cfg, _cloud, log, _args): sm = SubscriptionManager(cfg) sm.log = log if not sm.is_configured(): log.debug("%s: module not configured.", name) return None if not sm.is_registered(): try: verify, verify_msg = sm._verify_keys() if verify is not True: raise SubscriptionError(verify_msg) cont = sm.rhn_register() if not cont: raise SubscriptionError("Registration failed or did not " "run completely") # Splitting up the registration, auto-attach, and servicelevel # commands because the error codes, messages from subman are not # specific enough. # Attempt to change the service level if sm.auto_attach and sm.servicelevel is not None: if not sm._set_service_level(): raise SubscriptionError("Setting of service-level " "failed") else: sm.log.debug("Completed auto-attach with service level") elif sm.auto_attach: if not sm._set_auto_attach(): raise SubscriptionError("Setting auto-attach failed") else: sm.log.debug("Completed auto-attach") if sm.pools is not None: if not isinstance(sm.pools, list): pool_fail = "Pools must in the format of a list" raise SubscriptionError(pool_fail) return_stat = sm.addPool(sm.pools) if not return_stat: raise SubscriptionError("Unable to attach pools {0}" .format(sm.pools)) if (sm.enable_repo is not None) or (sm.disable_repo is not None): return_stat = sm.update_repos(sm.enable_repo, sm.disable_repo) if not return_stat: raise SubscriptionError("Unable to add or remove repos") sm.log_success("rh_subscription plugin completed successfully") except SubscriptionError as e: sm.log_warn(str(e)) sm.log_warn("rh_subscription plugin did not complete successfully") else: sm.log_success("System is already registered") class SubscriptionError(Exception): pass class SubscriptionManager(object): valid_rh_keys = ['org', 'activation-key', 'username', 'password', 'disable-repo', 'enable-repo', 'add-pool', 'rhsm-baseurl', 'server-hostname', 'auto-attach', 'service-level'] def __init__(self, cfg): self.cfg = cfg self.rhel_cfg = self.cfg.get('rh_subscription', {}) self.rhsm_baseurl = self.rhel_cfg.get('rhsm-baseurl') self.server_hostname = self.rhel_cfg.get('server-hostname') self.pools = self.rhel_cfg.get('add-pool') self.activation_key = self.rhel_cfg.get('activation-key') self.org = self.rhel_cfg.get('org') self.userid = self.rhel_cfg.get('username') self.password = self.rhel_cfg.get('password') self.auto_attach = self.rhel_cfg.get('auto-attach') self.enable_repo = self.rhel_cfg.get('enable-repo') self.disable_repo = self.rhel_cfg.get('disable-repo') self.servicelevel = self.rhel_cfg.get('service-level') self.subman = ['subscription-manager'] def log_success(self, msg): '''Simple wrapper for logging info messages. Useful for unittests''' self.log.info(msg) def log_warn(self, msg): '''Simple wrapper for logging warning messages. Useful for unittests''' self.log.warn(msg) def _verify_keys(self): ''' Checks that the keys in the rh_subscription dict from the user-data are what we expect. ''' for k in self.rhel_cfg: if k not in self.valid_rh_keys: bad_key = "{0} is not a valid key for rh_subscription. "\ "Valid keys are: "\ "{1}".format(k, ', '.join(self.valid_rh_keys)) return False, bad_key # Check for bad auto-attach value if (self.auto_attach is not None) and \ not (util.is_true(self.auto_attach) or util.is_false(self.auto_attach)): not_bool = "The key auto-attach must be a boolean value "\ "(True/False " return False, not_bool if (self.servicelevel is not None) and ((not self.auto_attach) or (util.is_false(str(self.auto_attach)))): no_auto = ("The service-level key must be used in conjunction " "with the auto-attach key. Please re-run with " "auto-attach: True") return False, no_auto return True, None def is_registered(self): ''' Checks if the system is already registered and returns True if so, else False ''' cmd = ['identity'] try: self._sub_man_cli(cmd) except util.ProcessExecutionError: return False return True def _sub_man_cli(self, cmd, logstring_val=False): ''' Uses the prefered cloud-init subprocess def of util.subp and runs subscription-manager. Breaking this to a separate function for later use in mocking and unittests ''' cmd = self.subman + cmd return util.subp(cmd, logstring=logstring_val) def rhn_register(self): ''' Registers the system by userid and password or activation key and org. Returns True when successful False when not. ''' if (self.activation_key is not None) and (self.org is not None): # register by activation key cmd = ['register', '--activationkey={0}'. format(self.activation_key), '--org={0}'.format(self.org)] # If the baseurl and/or server url are passed in, we register # with them. if self.rhsm_baseurl is not None: cmd.append("--baseurl={0}".format(self.rhsm_baseurl)) if self.server_hostname is not None: cmd.append("--serverurl={0}".format(self.server_hostname)) try: return_out, return_err = self._sub_man_cli(cmd, logstring_val=True) except util.ProcessExecutionError as e: if e.stdout == "": self.log_warn("Registration failed due " "to: {0}".format(e.stderr)) return False elif (self.userid is not None) and (self.password is not None): # register by username and password cmd = ['register', '--username={0}'.format(self.userid), '--password={0}'.format(self.password)] # If the baseurl and/or server url are passed in, we register # with them. if self.rhsm_baseurl is not None: cmd.append("--baseurl={0}".format(self.rhsm_baseurl)) if self.server_hostname is not None: cmd.append("--serverurl={0}".format(self.server_hostname)) # Attempting to register the system only try: return_out, return_err = self._sub_man_cli(cmd, logstring_val=True) except util.ProcessExecutionError as e: if e.stdout == "": self.log_warn("Registration failed due " "to: {0}".format(e.stderr)) return False else: self.log_warn("Unable to register system due to incomplete " "information.") self.log_warn("Use either activationkey and org *or* userid " "and password") return False reg_id = return_out.split("ID: ")[1].rstrip() self.log.debug("Registered successfully with ID {0}".format(reg_id)) return True def _set_service_level(self): cmd = ['attach', '--auto', '--servicelevel={0}' .format(self.servicelevel)] try: return_out, return_err = self._sub_man_cli(cmd) except util.ProcessExecutionError as e: if e.stdout.rstrip() != '': for line in e.stdout.split("\n"): if line is not '': self.log_warn(line) else: self.log_warn("Setting the service level failed with: " "{0}".format(e.stderr.strip())) return False for line in return_out.split("\n"): if line is not "": self.log.debug(line) return True def _set_auto_attach(self): cmd = ['attach', '--auto'] try: return_out, return_err = self._sub_man_cli(cmd) except util.ProcessExecutionError: self.log_warn("Auto-attach failed with: " "{0}]".format(return_err.strip())) return False for line in return_out.split("\n"): if line is not "": self.log.debug(line) return True def _getPools(self): ''' Gets the list pools for the active subscription and returns them in list form. ''' available = [] consumed = [] # Get all available pools cmd = ['list', '--available', '--pool-only'] results, errors = self._sub_man_cli(cmd) available = (results.rstrip()).split("\n") # Get all consumed pools cmd = ['list', '--consumed', '--pool-only'] results, errors = self._sub_man_cli(cmd) consumed = (results.rstrip()).split("\n") return available, consumed def _getRepos(self): ''' Obtains the current list of active yum repositories and returns them in list form. ''' cmd = ['repos', '--list-enabled'] return_out, return_err = self._sub_man_cli(cmd) active_repos = [] for repo in return_out.split("\n"): if "Repo ID:" in repo: active_repos.append((repo.split(':')[1]).strip()) cmd = ['repos', '--list-disabled'] return_out, return_err = self._sub_man_cli(cmd) inactive_repos = [] for repo in return_out.split("\n"): if "Repo ID:" in repo: inactive_repos.append((repo.split(':')[1]).strip()) return active_repos, inactive_repos def addPool(self, pools): ''' Takes a list of subscription pools and "attaches" them to the current subscription ''' # An empty list was passed if len(pools) == 0: self.log.debug("No pools to attach") return True pool_available, pool_consumed = self._getPools() pool_list = [] cmd = ['attach'] for pool in pools: if (pool not in pool_consumed) and (pool in pool_available): pool_list.append('--pool={0}'.format(pool)) else: self.log_warn("Pool {0} is not available".format(pool)) if len(pool_list) > 0: cmd.extend(pool_list) try: self._sub_man_cli(cmd) self.log.debug("Attached the following pools to your " "system: %s" % (", ".join(pool_list)) .replace('--pool=', '')) return True except util.ProcessExecutionError as e: self.log_warn("Unable to attach pool {0} " "due to {1}".format(pool, e)) return False def update_repos(self, erepos, drepos): ''' Takes a list of yum repo ids that need to be disabled or enabled; then it verifies if they are already enabled or disabled and finally executes the action to disable or enable ''' if (erepos is not None) and (not isinstance(erepos, list)): self.log_warn("Repo IDs must in the format of a list.") return False if (drepos is not None) and (not isinstance(drepos, list)): self.log_warn("Repo IDs must in the format of a list.") return False # Bail if both lists are not populated if (len(erepos) == 0) and (len(drepos) == 0): self.log.debug("No repo IDs to enable or disable") return True active_repos, inactive_repos = self._getRepos() # Creating a list of repoids to be enabled enable_list = [] enable_list_fail = [] for repoid in erepos: if (repoid in inactive_repos): enable_list.append("--enable={0}".format(repoid)) else: enable_list_fail.append(repoid) # Creating a list of repoids to be disabled disable_list = [] disable_list_fail = [] for repoid in drepos: if repoid in active_repos: disable_list.append("--disable={0}".format(repoid)) else: disable_list_fail.append(repoid) # Logging any repos that are already enabled or disabled if len(enable_list_fail) > 0: for fail in enable_list_fail: # Check if the repo exists or not if fail in active_repos: self.log.debug("Repo {0} is already enabled".format(fail)) else: self.log_warn("Repo {0} does not appear to " "exist".format(fail)) if len(disable_list_fail) > 0: for fail in disable_list_fail: self.log.debug("Repo {0} not disabled " "because it is not enabled".format(fail)) cmd = ['repos'] if len(disable_list) > 0: cmd.extend(disable_list) if len(enable_list) > 0: cmd.extend(enable_list) try: self._sub_man_cli(cmd) except util.ProcessExecutionError as e: self.log_warn("Unable to alter repos due to {0}".format(e)) return False if len(enable_list) > 0: self.log.debug("Enabled the following repos: %s" % (", ".join(enable_list)).replace('--enable=', '')) if len(disable_list) > 0: self.log.debug("Disabled the following repos: %s" % (", ".join(disable_list)).replace('--disable=', '')) return True def is_configured(self): return bool((self.userid and self.password) or self.activation_key) # vi: ts=4 expandtab
Close